From d43ca82432a6eaa1819ce38be267733d6522a13d Mon Sep 17 00:00:00 2001 From: Zackary Santana <64446617+ZackarySantana@users.noreply.github.com> Date: Thu, 29 Feb 2024 10:22:55 -0500 Subject: [PATCH] DEVPROD-4166 Add breaking commits option in previous commits dropdown (#2254) --- src/analytics/task/useTaskAnalytics.ts | 4 +- src/gql/generated/types.ts | 2 + src/gql/queries/base-version-and-task.graphql | 1 + src/gql/queries/last-mainline-commit.graphql | 1 + src/pages/task/ActionButtons.tsx | 4 +- .../RelevantCommits.test.tsx} | 122 ++++++++++++++---- .../index.tsx | 59 +++++++-- .../actionButtons/RelevantCommits/types.ts | 16 +++ .../utils.ts | 14 +- .../actionButtons/previousCommits/types.ts | 9 -- 10 files changed, 179 insertions(+), 53 deletions(-) rename src/pages/task/actionButtons/{previousCommits/PreviousCommits.test.tsx => RelevantCommits/RelevantCommits.test.tsx} (79%) rename src/pages/task/actionButtons/{previousCommits => RelevantCommits}/index.tsx (71%) create mode 100644 src/pages/task/actionButtons/RelevantCommits/types.ts rename src/pages/task/actionButtons/{previousCommits => RelevantCommits}/utils.ts (82%) delete mode 100644 src/pages/task/actionButtons/previousCommits/types.ts diff --git a/src/analytics/task/useTaskAnalytics.ts b/src/analytics/task/useTaskAnalytics.ts index 29011dd6d3..a68225c558 100644 --- a/src/analytics/task/useTaskAnalytics.ts +++ b/src/analytics/task/useTaskAnalytics.ts @@ -10,7 +10,7 @@ import { } from "gql/generated/types"; import { TASK } from "gql/queries"; import { useQueryParam } from "hooks/useQueryParam"; -import { CommitType } from "pages/task/actionButtons/previousCommits/types"; +import { CommitType } from "pages/task/actionButtons/RelevantCommits/types"; import { RequiredQueryParams, LogTypes } from "types/task"; type LogViewer = "raw" | "html" | "parsley"; @@ -70,7 +70,7 @@ type Action = | { name: "Click Last Failing Stepback Task Link" } | { name: "Click Previous Stepback Task Link" } | { name: "Click Next Stepback Task Link" } - | { name: "Submit Previous Commit Selector"; type: CommitType }; + | { name: "Submit Relevant Commit Selector"; type: CommitType }; export const useTaskAnalytics = () => { const { id } = useParams<{ id: string }>(); diff --git a/src/gql/generated/types.ts b/src/gql/generated/types.ts index 1da6c84f44..bc6a8b8af2 100644 --- a/src/gql/generated/types.ts +++ b/src/gql/generated/types.ts @@ -5409,6 +5409,7 @@ export type BaseVersionAndTaskQuery = { execution: number; id: string; projectIdentifier?: string | null; + status: string; baseTask?: { __typename?: "Task"; execution: number; @@ -6173,6 +6174,7 @@ export type LastMainlineCommitQuery = { __typename?: "Task"; execution: number; id: string; + order: number; status: string; } | null> | null; } | null> | null; diff --git a/src/gql/queries/base-version-and-task.graphql b/src/gql/queries/base-version-and-task.graphql index 3452491b5e..1371d48913 100644 --- a/src/gql/queries/base-version-and-task.graphql +++ b/src/gql/queries/base-version-and-task.graphql @@ -10,6 +10,7 @@ query BaseVersionAndTask($taskId: String!) { execution id projectIdentifier + status versionMetadata { baseVersion { id diff --git a/src/gql/queries/last-mainline-commit.graphql b/src/gql/queries/last-mainline-commit.graphql index ef6daa28ac..098e78d78f 100644 --- a/src/gql/queries/last-mainline-commit.graphql +++ b/src/gql/queries/last-mainline-commit.graphql @@ -18,6 +18,7 @@ query LastMainlineCommit( tasks { execution id + order status } } diff --git a/src/pages/task/ActionButtons.tsx b/src/pages/task/ActionButtons.tsx index 776fb9848b..48b7592925 100644 --- a/src/pages/task/ActionButtons.tsx +++ b/src/pages/task/ActionButtons.tsx @@ -38,7 +38,7 @@ import { import { useLGButtonRouterLink } from "hooks/useLGButtonRouterLink"; import { useQueryParam } from "hooks/useQueryParam"; import { TaskStatus } from "types/task"; -import { PreviousCommits } from "./actionButtons/previousCommits"; +import { RelevantCommits } from "./actionButtons/RelevantCommits"; import { TaskNotificationModal } from "./actionButtons/TaskNotificationModal"; interface Props { @@ -254,7 +254,7 @@ export const ActionButtons: React.FC = ({ {!isExecutionTask && ( <> - + } > - No previous versions available. + No relevant versions available. ) : ( } size={Size.Small}> - Previous commits + Relevant commits } > @@ -148,7 +174,7 @@ export const PreviousCommits: React.FC = ({ taskId }) => { disabled={parentLoading} onClick={() => sendEvent({ - name: "Submit Previous Commit Selector", + name: "Submit Relevant Commit Selector", type: CommitType.Base, }) } @@ -156,12 +182,25 @@ export const PreviousCommits: React.FC = ({ taskId }) => { > Go to {versionMetadata?.isPatch ? "base" : "previous"} commit + + sendEvent({ + name: "Submit Relevant Commit Selector", + type: CommitType.Breaking, + }) + } + to={linkObject[CommitType.Breaking]} + > + Go to breaking commit + sendEvent({ - name: "Submit Previous Commit Selector", + name: "Submit Relevant Commit Selector", type: CommitType.LastPassing, }) } @@ -174,7 +213,7 @@ export const PreviousCommits: React.FC = ({ taskId }) => { disabled={executedLoading} onClick={() => sendEvent({ - name: "Submit Previous Commit Selector", + name: "Submit Relevant Commit Selector", type: CommitType.LastExecuted, }) } diff --git a/src/pages/task/actionButtons/RelevantCommits/types.ts b/src/pages/task/actionButtons/RelevantCommits/types.ts new file mode 100644 index 0000000000..15e5cce2a5 --- /dev/null +++ b/src/pages/task/actionButtons/RelevantCommits/types.ts @@ -0,0 +1,16 @@ +import { + BaseVersionAndTaskQuery, + LastMainlineCommitQuery, +} from "gql/generated/types"; + +export enum CommitType { + Base = "base", + LastPassing = "lastPassing", + Breaking = "breaking", + LastExecuted = "lastExecuted", +} + +export type BaseTask = BaseVersionAndTaskQuery["task"]["baseTask"]; + +export type CommitTask = + LastMainlineCommitQuery["mainlineCommits"]["versions"][number]["version"]["buildVariants"][number]["tasks"][number]; diff --git a/src/pages/task/actionButtons/previousCommits/utils.ts b/src/pages/task/actionButtons/RelevantCommits/utils.ts similarity index 82% rename from src/pages/task/actionButtons/previousCommits/utils.ts rename to src/pages/task/actionButtons/RelevantCommits/utils.ts index fa2b2510b3..a18f0770c3 100644 --- a/src/pages/task/actionButtons/previousCommits/utils.ts +++ b/src/pages/task/actionButtons/RelevantCommits/utils.ts @@ -1,23 +1,26 @@ import { getTaskRoute } from "constants/routes"; import { LastMainlineCommitQuery } from "gql/generated/types"; import { reportError } from "utils/errorReporting"; -import { CommitTask, CommitType } from "./types"; +import { BaseTask, CommitTask, CommitType } from "./types"; // a link cannot be null, so it's common to use # as a substitute. const nullLink = "#"; export const getLinks = ({ + breakingTask, lastExecutedTask, lastPassingTask, parentTask, }: { - lastExecutedTask: CommitTask; - lastPassingTask: CommitTask; - parentTask: CommitTask; + breakingTask: BaseTask; + lastExecutedTask: BaseTask; + lastPassingTask: BaseTask; + parentTask: BaseTask; }) => { if (!parentTask) { return { [CommitType.Base]: nullLink, + [CommitType.Breaking]: nullLink, [CommitType.LastPassing]: nullLink, [CommitType.LastExecuted]: nullLink, }; @@ -25,6 +28,9 @@ export const getLinks = ({ return { [CommitType.Base]: getTaskRoute(parentTask.id), + [CommitType.Breaking]: breakingTask + ? getTaskRoute(breakingTask.id) + : nullLink, [CommitType.LastPassing]: getTaskRoute( lastPassingTask?.id || parentTask.id, ), diff --git a/src/pages/task/actionButtons/previousCommits/types.ts b/src/pages/task/actionButtons/previousCommits/types.ts deleted file mode 100644 index 2e1f5c629b..0000000000 --- a/src/pages/task/actionButtons/previousCommits/types.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { BaseVersionAndTaskQuery } from "gql/generated/types"; - -export enum CommitType { - Base = "base", - LastPassing = "lastPassing", - LastExecuted = "lastExecuted", -} - -export type CommitTask = BaseVersionAndTaskQuery["task"]["baseTask"];