Skip to content

Commit

Permalink
MAINT - More descriptive artifact names
Browse files Browse the repository at this point in the history
Change artifact link names
  • Loading branch information
trallard authored Aug 24, 2023
2 parents 01c4827 + 64611df commit 57f9d71
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 20 deletions.
19 changes: 19 additions & 0 deletions src/features/artifacts/components/ArtifactList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@ export interface IArtifactsProps {
export const ArtifactList = ({ artifacts }: IArtifactsProps) => {
const { typography } = useTheme();

// Groups all the artifacts that start with "Show" at the beginning - this is to ensure consistency across display and naming
const order = (artifact_list: Artifact[]) => {
console.log(artifact_list);
const ordered_list = [];
for (let i = 0; i < artifact_list.length; i++) {
const item = artifact_list[i];
if (item.name.includes("Show")) {
ordered_list.unshift(item);
} else {
ordered_list.push(item);
}
}
return ordered_list;
};

if (artifacts) {
artifacts = order(artifacts);
}

return (
<BlockContainer title="Logs and Artifacts">
{artifacts.length ? (
Expand Down
12 changes: 6 additions & 6 deletions src/features/artifacts/stories/ArtifactsList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import { ArtifactList } from "../components";

const artifactList = [
{
name: "Link to lockfile",
name: "Show lockfile",
route: "/api/v1/build/1/lockfile/"
},
{
name: "Link to yml file",
name: "Show yml file",
route: "/api/v1/build/1/yaml/"
},
{
name: "Link to archive",
route: "/api/v1/build/1/archive/"
name: "Show Conda environment 1 log",
route: "/api/v1/build/1/logs"
},
{
name: "Conda Env 1 log",
route: "/api/v1/build/1/logs"
name: "Download archive",
route: "/api/v1/build/1/archive/"
}
];

Expand Down
16 changes: 8 additions & 8 deletions src/utils/helpers/artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ const artifactList = (
}
const artifact_map = {
LOCKFILE: {
name: "Link to lockfile",
name: "Show lockfile",
route: `api/v1/build/${currentBuildId}/lockfile/`
},
YAML: {
name: "Link to yml file",
name: "Show yml file",
route: `api/v1/build/${currentBuildId}/yaml/`
},
CONDA_PACK: {
name: "Link to archive",
route: `api/v1/build/${currentBuildId}/archive/`
},
LOGS: {
name: `Conda Env ${currentBuildId} log`,
name: `Show Conda environment ${currentBuildId} log`,
route: `api/v1/build/${currentBuildId}/logs/`
},
DOCKER_MANIFEST: {
name: "Docker image",
name: "Show Docker image",
route: `api/v1/build/${currentBuildId}/docker/`
},
CONDA_PACK: {
name: "Download archive",
route: `api/v1/build/${currentBuildId}/archive/`
}
};

Expand Down
2 changes: 1 addition & 1 deletion test/artifacts/ArtifactItem.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ArtifactItem } from "../../src/features/artifacts/components/ArtifactsI
describe("<ArtifactItem />", () => {
it("should render component", () => {
const artifactItem = {
name: "Link to lockfile",
name: "Show lockfile",
route: "/api/v1/build/{build_id}/lockfile/"
};
const component = render(<ArtifactItem artifact={artifactItem} />);
Expand Down
6 changes: 3 additions & 3 deletions test/artifacts/ArtifactsList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { mockTheme } from "../testutils";

const ARTIFACTS = [
{
name: "Link to lockfile",
name: "Show lockfile",
route: "/api/v1/build/1/lockfile/"
}
];
Expand All @@ -17,8 +17,8 @@ describe("<ArtifactList />", () => {
);

expect(screen.getByText("Logs and Artifacts")).toBeInTheDocument();
expect(screen.getByText("Link to lockfile")).toBeVisible();
expect(screen.getByText("Link to lockfile")).toHaveAttribute(
expect(screen.getByText("Show lockfile")).toBeVisible();
expect(screen.getByText("Show lockfile")).toHaveAttribute(
"href",
"http://localhost:5000/api/v1/build/1/lockfile/"
);
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/artifact.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ describe("artifactList", () => {
it("should return the artifact list", () => {
const list = artifactList(CURRENT_BUILD_ID, ARTIFACTS_TYPES);
expect(list).toEqual([
{ name: "Link to lockfile", route: "api/v1/build/1/lockfile/" },
{ name: "Link to yml file", route: "api/v1/build/1/yaml/" }
{ name: "Show lockfile", route: "api/v1/build/1/lockfile/" },
{ name: "Show yml file", route: "api/v1/build/1/yaml/" }
]);
});

Expand Down

0 comments on commit 57f9d71

Please sign in to comment.