From d9a839090e5c8a43e5dd9acf51211661cc36e8e4 Mon Sep 17 00:00:00 2001 From: minnakt <47064971+minnakt@users.noreply.github.com> Date: Tue, 10 Sep 2024 19:19:03 -0400 Subject: [PATCH] DEVPROD-7660: Add link to image page in task metadata (#365) --- .../integration/distroSettings/navigation.ts | 2 +- .../cypress/integration/hosts/select_hosts.ts | 2 +- .../cypress/integration/image/navigation.ts | 11 +++++ apps/spruce/cypress/integration/nav_bar.ts | 2 +- apps/spruce/src/gql/generated/types.ts | 1 + apps/spruce/src/gql/mocks/taskData.ts | 1 + apps/spruce/src/gql/queries/task.graphql | 1 + .../Metadata_ContainerizedTask.storyshot | 1 + .../__snapshots__/Metadata_Default.storyshot | 36 +++++++++++---- .../Metadata_OOMTracker.storyshot | 36 +++++++++++---- .../Metadata_WithAbortMessage.storyshot | 36 +++++++++++---- .../Metadata_WithDependencies.storyshot | 36 +++++++++++---- apps/spruce/src/pages/task/metadata/index.tsx | 44 ++++++++++++++----- apps/spruce/src/pages/version/Metadata.tsx | 3 +- 14 files changed, 163 insertions(+), 49 deletions(-) diff --git a/apps/spruce/cypress/integration/distroSettings/navigation.ts b/apps/spruce/cypress/integration/distroSettings/navigation.ts index 36b6fe409..769fd4c84 100644 --- a/apps/spruce/cypress/integration/distroSettings/navigation.ts +++ b/apps/spruce/cypress/integration/distroSettings/navigation.ts @@ -95,7 +95,7 @@ describe("distroSettings/navigation", () => { cy.location("pathname").should("not.contain", "/distros"); cy.location("pathname").should( "eq", - "/distro/localhost/settings/general", + "/distro/archlinux-test/settings/general", ); }); }); diff --git a/apps/spruce/cypress/integration/hosts/select_hosts.ts b/apps/spruce/cypress/integration/hosts/select_hosts.ts index 8c5a65263..e95c99af2 100644 --- a/apps/spruce/cypress/integration/hosts/select_hosts.ts +++ b/apps/spruce/cypress/integration/hosts/select_hosts.ts @@ -75,6 +75,6 @@ describe("Select hosts in hosts page table", () => { cy.dataCy("reprovision-button").should("be.visible").click(); cy.dataCy("reprovision-button-popover").should("be.visible"); cy.contains("button", "Yes").click(); - cy.validateToast("success", "Marked hosts to reprovision for 0 hosts"); + cy.validateToast("success", "Marked hosts to reprovision for 3 hosts"); }); }); diff --git a/apps/spruce/cypress/integration/image/navigation.ts b/apps/spruce/cypress/integration/image/navigation.ts index 559851f04..0e4463abc 100644 --- a/apps/spruce/cypress/integration/image/navigation.ts +++ b/apps/spruce/cypress/integration/image/navigation.ts @@ -22,4 +22,15 @@ describe("/image/imageId/random redirect route", () => { }); }); }); + + it("navigates to the image page from the task page", () => { + cy.visit( + "/task/evergreen_ubuntu1604_test_annotations_b_5e4ff3abe3c3317e352062e4_20_02_21_15_13_48", + ); + cy.dataCy("task-image-link") + .should("have.attr", "href") + .and("eq", "/image/ubuntu1604/build-information"); + cy.dataCy("task-image-link").click(); + cy.location("pathname").should("eq", "/image/ubuntu1604/build-information"); + }); }); diff --git a/apps/spruce/cypress/integration/nav_bar.ts b/apps/spruce/cypress/integration/nav_bar.ts index 629db209e..2f331ab18 100644 --- a/apps/spruce/cypress/integration/nav_bar.ts +++ b/apps/spruce/cypress/integration/nav_bar.ts @@ -55,7 +55,7 @@ describe("Nav Bar", () => { cy.dataCy("auxiliary-dropdown-distro-settings").should( "have.attr", "href", - "/distro/localhost/settings/general", + "/distro/archlinux-test/settings/general", ); }); it("Nav Dropdown should link to patches page of default project in SpruceConfig if cookie does not exist", () => { diff --git a/apps/spruce/src/gql/generated/types.ts b/apps/spruce/src/gql/generated/types.ts index 03918e2ce..401313f4a 100644 --- a/apps/spruce/src/gql/generated/types.ts +++ b/apps/spruce/src/gql/generated/types.ts @@ -8807,6 +8807,7 @@ export type TaskQuery = { generatedBy?: string | null; generatedByName?: string | null; hostId?: string | null; + imageId: string; ingestTime?: Date | null; isPerfPluginEnabled: boolean; latestExecution: number; diff --git a/apps/spruce/src/gql/mocks/taskData.ts b/apps/spruce/src/gql/mocks/taskData.ts index 0a420c204..5f4218957 100644 --- a/apps/spruce/src/gql/mocks/taskData.ts +++ b/apps/spruce/src/gql/mocks/taskData.ts @@ -58,6 +58,7 @@ export const taskQuery: TaskQueryType = { canUnschedule: false, dependsOn: [], displayName: "e2e_test", + imageId: "ubuntu1604", distroId: "ubuntu1604-small", estimatedStart: 1000, pod: null, diff --git a/apps/spruce/src/gql/queries/task.graphql b/apps/spruce/src/gql/queries/task.graphql index 094711042..455a64be9 100644 --- a/apps/spruce/src/gql/queries/task.graphql +++ b/apps/spruce/src/gql/queries/task.graphql @@ -84,6 +84,7 @@ query Task($taskId: String!, $execution: Int) { generatedBy generatedByName hostId + imageId ingestTime isPerfPluginEnabled latestExecution diff --git a/apps/spruce/src/pages/task/metadata/__snapshots__/Metadata_ContainerizedTask.storyshot b/apps/spruce/src/pages/task/metadata/__snapshots__/Metadata_ContainerizedTask.storyshot index fa2666bce..027b6fd15 100644 --- a/apps/spruce/src/pages/task/metadata/__snapshots__/Metadata_ContainerizedTask.storyshot +++ b/apps/spruce/src/pages/task/metadata/__snapshots__/Metadata_ContainerizedTask.storyshot @@ -139,6 +139,7 @@ class="css-qqg5h5-Divider eb6szep0" /> +

diff --git a/apps/spruce/src/pages/task/metadata/__snapshots__/Metadata_Default.storyshot b/apps/spruce/src/pages/task/metadata/__snapshots__/Metadata_Default.storyshot index 32aad269f..ca4d6b59a 100644 --- a/apps/spruce/src/pages/task/metadata/__snapshots__/Metadata_Default.storyshot +++ b/apps/spruce/src/pages/task/metadata/__snapshots__/Metadata_Default.storyshot @@ -139,17 +139,26 @@ class="css-qqg5h5-Divider eb6szep0" /> +

- AMI: + ID: - ami-0c83bb0a9f48c15bf + + + i-0e0e62799806e037d + +

- ID: + Image: - i-0e0e62799806e037d + ubuntu1604

+

+ + AMI: + + + ami-0c83bb0a9f48c15bf +

diff --git a/apps/spruce/src/pages/task/metadata/__snapshots__/Metadata_OOMTracker.storyshot b/apps/spruce/src/pages/task/metadata/__snapshots__/Metadata_OOMTracker.storyshot index 0d3da46c4..b2645aba8 100644 --- a/apps/spruce/src/pages/task/metadata/__snapshots__/Metadata_OOMTracker.storyshot +++ b/apps/spruce/src/pages/task/metadata/__snapshots__/Metadata_OOMTracker.storyshot @@ -135,17 +135,26 @@ class="css-qqg5h5-Divider eb6szep0" /> +

- AMI: + ID: - ami-0c83bb0a9f48c15bf + + + i-0e0e62799806e037d + +

- ID: + Image: - i-0e0e62799806e037d + ubuntu1604

+

+ + AMI: + + + ami-0c83bb0a9f48c15bf +

diff --git a/apps/spruce/src/pages/task/metadata/__snapshots__/Metadata_WithAbortMessage.storyshot b/apps/spruce/src/pages/task/metadata/__snapshots__/Metadata_WithAbortMessage.storyshot index 32aad269f..ca4d6b59a 100644 --- a/apps/spruce/src/pages/task/metadata/__snapshots__/Metadata_WithAbortMessage.storyshot +++ b/apps/spruce/src/pages/task/metadata/__snapshots__/Metadata_WithAbortMessage.storyshot @@ -139,17 +139,26 @@ class="css-qqg5h5-Divider eb6szep0" /> +

- AMI: + ID: - ami-0c83bb0a9f48c15bf + + + i-0e0e62799806e037d + +

- ID: + Image: - i-0e0e62799806e037d + ubuntu1604

+

+ + AMI: + + + ami-0c83bb0a9f48c15bf +

diff --git a/apps/spruce/src/pages/task/metadata/__snapshots__/Metadata_WithDependencies.storyshot b/apps/spruce/src/pages/task/metadata/__snapshots__/Metadata_WithDependencies.storyshot index dc0d59063..114fd2035 100644 --- a/apps/spruce/src/pages/task/metadata/__snapshots__/Metadata_WithDependencies.storyshot +++ b/apps/spruce/src/pages/task/metadata/__snapshots__/Metadata_WithDependencies.storyshot @@ -139,17 +139,26 @@ class="css-qqg5h5-Divider eb6szep0" /> +

- AMI: + ID: - ami-0c83bb0a9f48c15bf + + + i-0e0e62799806e037d + +

- ID: + Image: - i-0e0e62799806e037d + ubuntu1604

+

+ + AMI: + + + ami-0c83bb0a9f48c15bf +

diff --git a/apps/spruce/src/pages/task/metadata/index.tsx b/apps/spruce/src/pages/task/metadata/index.tsx index d534b22fc..90ecdf15a 100644 --- a/apps/spruce/src/pages/task/metadata/index.tsx +++ b/apps/spruce/src/pages/task/metadata/index.tsx @@ -17,6 +17,7 @@ import { getHoneycombTraceUrl, getHoneycombSystemMetricsUrl, } from "constants/externalResources"; +import { showImageVisibilityPage } from "constants/featureFlags"; import { getDistroSettingsRoute, getTaskQueueRoute, @@ -26,6 +27,7 @@ import { getVersionRoute, getProjectPatchesRoute, getPodRoute, + getImageRoute, } from "constants/routes"; import { zIndex } from "constants/tokens"; import { TaskQuery } from "gql/generated/types"; @@ -70,6 +72,7 @@ export const Metadata: React.FC = ({ error, loading, task, taskId }) => { generatedBy, generatedByName, hostId, + imageId, ingestTime, minQueuePosition: taskQueuePosition, pod, @@ -353,10 +356,22 @@ export const Metadata: React.FC = ({ error, loading, task, taskId }) => { {!isDisplayTask && ( - Host Information - {ami && ( - - AMI: {ami} + Host Information{" "} + {!isContainerTask && hostId && ( + + ID:{" "} + + taskAnalytics.sendEvent({ + name: "Clicked metadata link", + "link.type": "host link", + }) + } + > + {hostId} + )} {!isContainerTask && distroId && ( @@ -376,21 +391,26 @@ export const Metadata: React.FC = ({ error, loading, task, taskId }) => { )} - {!isContainerTask && hostId && ( + {showImageVisibilityPage && !isContainerTask && imageId && ( - ID:{" "} - Image:{" "} + taskAnalytics.sendEvent({ name: "Clicked metadata link", - "link.type": "host link", + "link.type": "image link", }) } + to={getImageRoute(imageId)} > - {hostId} - + {imageId} + + + )} + {ami && ( + + AMI: {ami} )} {isContainerTask && ( diff --git a/apps/spruce/src/pages/version/Metadata.tsx b/apps/spruce/src/pages/version/Metadata.tsx index 6bc0a8716..db046cd56 100644 --- a/apps/spruce/src/pages/version/Metadata.tsx +++ b/apps/spruce/src/pages/version/Metadata.tsx @@ -155,7 +155,7 @@ export const Metadata: React.FC = ({ loading, version }) => { hideExternalIcon={false} href={getGithubMergeQueueUrl(owner, repo, branch)} > - GitHub Merge Queue + GitHub Merge Queue )} @@ -194,7 +194,6 @@ export const Metadata: React.FC = ({ loading, version }) => { {externalLinksForMetadata?.map(({ displayName, url }) => ( - {displayName}:{" "} {displayName}