diff --git a/package.json b/package.json index 7d631e3a06..8ac518532e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "spruce", - "version": "3.0.158", + "version": "3.0.159", "private": true, "scripts": { "bootstrap-logkeeper": "./scripts/bootstrap-logkeeper.sh", diff --git a/src/analytics/task/useTaskAnalytics.ts b/src/analytics/task/useTaskAnalytics.ts index 0fd4867cdb..81c5e80ae8 100644 --- a/src/analytics/task/useTaskAnalytics.ts +++ b/src/analytics/task/useTaskAnalytics.ts @@ -1,5 +1,5 @@ import { useQuery } from "@apollo/client"; -import { useParams, useLocation } from "react-router-dom"; +import { useParams } from "react-router-dom"; import { useAnalyticsRoot } from "analytics/useAnalyticsRoot"; import { SaveSubscriptionForUserMutationVariables, @@ -9,11 +9,9 @@ import { TestSortCategory, } from "gql/generated/types"; import { TASK } from "gql/queries"; +import { useQueryParam } from "hooks/useQueryParam"; import { CommitType } from "pages/task/actionButtons/previousCommits/types"; import { RequiredQueryParams, LogTypes } from "types/task"; -import { queryString } from "utils"; - -const { parseQueryString } = queryString; type LogViewer = "raw" | "html" | "parsley" | "lobster"; type Action = @@ -61,16 +59,19 @@ type Action = | { name: "Click Display Task Link" } | { name: "Click Project Link" } | { name: "Click See History Button" } + | { + name: "Click Task File Link"; + parsleyAvailable: boolean; + fileName: string; + } | { name: "Click Trace Link" } | { name: "Click Trace Metrics Link" } | { name: "Submit Previous Commit Selector"; type: CommitType }; export const useTaskAnalytics = () => { const { id } = useParams<{ id: string }>(); - const location = useLocation(); - const parsed = parseQueryString(location.search); - const execution = Number(parsed[RequiredQueryParams.Execution]); + const [execution] = useQueryParam(RequiredQueryParams.Execution, 0); const { data: eventData } = useQuery(TASK, { variables: { taskId: id, execution }, fetchPolicy: "cache-first", diff --git a/src/components/CommitChartLabel/index.tsx b/src/components/CommitChartLabel/index.tsx index ebae349275..6f22f32c23 100644 --- a/src/components/CommitChartLabel/index.tsx +++ b/src/components/CommitChartLabel/index.tsx @@ -4,11 +4,10 @@ import { Body, BodyProps, InlineCode } from "@leafygreen-ui/typography"; import { Link } from "react-router-dom"; import ExpandedText from "components/ExpandedText"; import { StyledRouterLink } from "components/styles"; -import { getVersionRoute, getTaskRoute } from "constants/routes"; +import { getVersionRoute, getTriggerRoute } from "constants/routes"; import { size, zIndex } from "constants/tokens"; import { UpstreamProjectFragment, GitTag } from "gql/generated/types"; import { useSpruceConfig, useDateFormat } from "hooks"; -import { ProjectTriggerLevel } from "types/triggers"; import { shortenGithash } from "utils/string"; import { jiraLinkify } from "utils/string/jiraLinkify"; @@ -46,7 +45,10 @@ const CommitChartLabel: React.FC = ({ const spruceConfig = useSpruceConfig(); const jiraHost = spruceConfig?.jira?.host; const { + owner: upstreamOwner, project: upstreamProjectIdentifier, + repo: upstreamRepo, + revision: upstreamRevision, task: upstreamTask, triggerType, version: upstreamVersion, @@ -72,11 +74,14 @@ const CommitChartLabel: React.FC = ({ Triggered from:{" "} {upstreamProjectIdentifier} diff --git a/src/constants/routes.ts b/src/constants/routes.ts index 6f8305ea0e..92643e9044 100644 --- a/src/constants/routes.ts +++ b/src/constants/routes.ts @@ -1,6 +1,8 @@ +import { getGithubCommitUrl } from "constants/externalResources"; import { TestStatus, HistoryQueryParams } from "types/history"; import { PatchTab } from "types/patch"; import { PatchTasksQueryParams, TaskTab } from "types/task"; +import { ProjectTriggerLevel } from "types/triggers"; import { queryString, array } from "utils"; const { toArray } = array; @@ -310,3 +312,29 @@ export const getTaskHistoryRoute = ( selectedCommit ); }; + +interface GetTriggerRouteParams { + triggerType: string; + upstreamTask: any; + upstreamVersion: any; + upstreamRevision: string; + upstreamOwner: string; + upstreamRepo: string; +} + +export const getTriggerRoute = ({ + triggerType, + upstreamOwner, + upstreamRepo, + upstreamRevision, + upstreamTask, + upstreamVersion, +}: GetTriggerRouteParams) => { + if (triggerType === ProjectTriggerLevel.TASK) { + return getTaskRoute(upstreamTask.id); + } + if (triggerType === ProjectTriggerLevel.PUSH) { + return getGithubCommitUrl(upstreamOwner, upstreamRepo, upstreamRevision); + } + return getVersionRoute(upstreamVersion.id); +}; diff --git a/src/gql/fragments/upstreamProject.graphql b/src/gql/fragments/upstreamProject.graphql index e3d7ceed8d..86754ecbe1 100644 --- a/src/gql/fragments/upstreamProject.graphql +++ b/src/gql/fragments/upstreamProject.graphql @@ -1,7 +1,9 @@ fragment UpstreamProject on Version { upstreamProject { + owner project repo + revision task { execution id diff --git a/src/gql/generated/types.ts b/src/gql/generated/types.ts index bd327e9cbe..b7b565d995 100644 --- a/src/gql/generated/types.ts +++ b/src/gql/generated/types.ts @@ -4414,8 +4414,10 @@ export type UpstreamProjectFragment = { __typename?: "Version"; upstreamProject?: { __typename?: "UpstreamProject"; + owner: string; project: string; repo: string; + revision: string; triggerID: string; triggerType: string; task?: { __typename?: "Task"; execution: number; id: string } | null; @@ -6114,8 +6116,10 @@ export type MainlineCommitsForHistoryQuery = { }> | null; upstreamProject?: { __typename?: "UpstreamProject"; + owner: string; project: string; repo: string; + revision: string; triggerID: string; triggerType: string; task?: { __typename?: "Task"; execution: number; id: string } | null; @@ -6149,8 +6153,10 @@ export type MainlineCommitsForHistoryQuery = { }> | null; upstreamProject?: { __typename?: "UpstreamProject"; + owner: string; project: string; repo: string; + revision: string; triggerID: string; triggerType: string; task?: { __typename?: "Task"; execution: number; id: string } | null; @@ -6188,8 +6194,10 @@ export type MainlineCommitsQuery = { revision: string; upstreamProject?: { __typename?: "UpstreamProject"; + owner: string; project: string; repo: string; + revision: string; triggerID: string; triggerType: string; task?: { __typename?: "Task"; execution: number; id: string } | null; @@ -6245,8 +6253,10 @@ export type MainlineCommitsQuery = { } | null; upstreamProject?: { __typename?: "UpstreamProject"; + owner: string; project: string; repo: string; + revision: string; triggerID: string; triggerType: string; task?: { __typename?: "Task"; execution: number; id: string } | null; @@ -8819,8 +8829,10 @@ export type VersionQuery = { } | null; upstreamProject?: { __typename?: "UpstreamProject"; + owner: string; project: string; repo: string; + revision: string; triggerID: string; triggerType: string; task?: { __typename?: "Task"; execution: number; id: string } | null; diff --git a/src/pages/commits/InactiveCommits/InactiveCommits.stories.tsx b/src/pages/commits/InactiveCommits/InactiveCommits.stories.tsx index bcd30f817c..6b5dc941c4 100644 --- a/src/pages/commits/InactiveCommits/InactiveCommits.stories.tsx +++ b/src/pages/commits/InactiveCommits/InactiveCommits.stories.tsx @@ -23,6 +23,8 @@ const versions: CommitRolledUpVersions = [ revision: "4337c33fa4a0d5c747a1115f0853b5f70e46f112", ignored: false, upstreamProject: { + owner: "evergreen", + revision: "4337c33fa4a0d5c747a1115f0853b5f70e46f112", triggerID: "123", triggerType: "task", repo: "evergreen-ci", diff --git a/src/pages/commits/InactiveCommits/index.tsx b/src/pages/commits/InactiveCommits/index.tsx index 1e03188ad6..6e7528f4d6 100644 --- a/src/pages/commits/InactiveCommits/index.tsx +++ b/src/pages/commits/InactiveCommits/index.tsx @@ -7,11 +7,10 @@ import { useProjectHealthAnalytics } from "analytics/projectHealth/useProjectHea import { DisplayModal } from "components/DisplayModal"; import Icon from "components/Icon"; import { StyledRouterLink } from "components/styles"; -import { getVersionRoute, getTaskRoute } from "constants/routes"; +import { getVersionRoute, getTriggerRoute } from "constants/routes"; import { size, zIndex, fontSize } from "constants/tokens"; import { useSpruceConfig, useDateFormat } from "hooks"; import { CommitRolledUpVersions } from "types/commits"; -import { ProjectTriggerLevel } from "types/triggers"; import { Unpacked } from "types/utils"; import { string } from "utils"; import { jiraLinkify } from "utils/string/jiraLinkify"; @@ -157,11 +156,14 @@ const CommitCopy: React.FC = ({ isTooltip, v }) => { <> Triggered from:{" "} {v.upstreamProject.project} diff --git a/src/pages/projectSettings/tabs/GithubCommitQueueTab/GithubCommitQueueTab.tsx b/src/pages/projectSettings/tabs/GithubCommitQueueTab/GithubCommitQueueTab.tsx index 95880f41ee..696715a3ff 100644 --- a/src/pages/projectSettings/tabs/GithubCommitQueueTab/GithubCommitQueueTab.tsx +++ b/src/pages/projectSettings/tabs/GithubCommitQueueTab/GithubCommitQueueTab.tsx @@ -87,8 +87,9 @@ export const GithubCommitQueueTab: React.FC = ({ <> {!githubWebhooksEnabled && ( - GitHub features are disabled because webhooks are not enabled. - Webhooks are enabled after saving with a valid owner and repository. + GitHub features are disabled because the Evergreen GitHub App is not + installed on the saved owner/repo. Contact IT to install the App and + enable GitHub features. )} ; -const columns: LGColumnDef[] = [ +const columns = ( + taskAnalytics: ReturnType +): LGColumnDef[] => [ { accessorKey: "name", header: "Name", @@ -21,6 +24,13 @@ const columns: LGColumnDef[] = [ href={value.row.original.link} data-cy="file-link" target="_blank" + onClick={() => { + taskAnalytics.sendEvent({ + name: "Click Task File Link", + parsleyAvailable: false, + fileName: value.getValue() as GroupedFilesFile["name"], + }); + }} > {value.getValue()} @@ -37,11 +47,16 @@ const GroupedFileTable: React.FC = ({ taskName, }) => { const tableContainerRef = useRef(null); + const taskAnalytics = useTaskAnalytics(); + const memoizedColumns = useMemo( + () => columns(taskAnalytics), + [taskAnalytics] + ); const table = useLeafyGreenTable({ containerRef: tableContainerRef, data: files, - columns, + columns: memoizedColumns, }); return ( diff --git a/src/pages/version/Metadata.tsx b/src/pages/version/Metadata.tsx index cd3ee2c3f7..7249a00c7a 100644 --- a/src/pages/version/Metadata.tsx +++ b/src/pages/version/Metadata.tsx @@ -11,12 +11,11 @@ import { getGithubCommitUrl } from "constants/externalResources"; import { getCommitQueueRoute, getProjectPatchesRoute, - getTaskRoute, + getTriggerRoute, getVersionRoute, } from "constants/routes"; import { VersionQuery } from "gql/generated/types"; import { useDateFormat } from "hooks"; -import { ProjectTriggerLevel } from "types/triggers"; import { string } from "utils"; import { formatZeroIndexForDisplay } from "utils/numbers"; import ManifestBlob from "./ManifestBlob"; @@ -56,7 +55,10 @@ export const Metadata: React.FC = ({ loading, version }) => { const { commitQueuePosition } = patch || {}; const { makespan, timeTaken } = versionTiming || {}; const { + owner: upstreamOwner, project: upstreamProjectIdentifier, + repo: upstreamRepo, + revision: upstreamRevision, task: upstreamTask, triggerType, version: upstreamVersion, @@ -169,11 +171,14 @@ export const Metadata: React.FC = ({ loading, version }) => { Triggered from:{" "} {upstreamProjectIdentifier} diff --git a/src/types/triggers.ts b/src/types/triggers.ts index ad5396eb13..1ba9d1c51a 100644 --- a/src/types/triggers.ts +++ b/src/types/triggers.ts @@ -10,6 +10,7 @@ export enum ResourceType { export enum ProjectTriggerLevel { TASK = "task", BUILD = "build", + PUSH = "push", } export enum TriggerType {