diff --git a/apps/parsley/src/components/SubHeader/EvergreenTaskSubHeader.tsx b/apps/parsley/src/components/SubHeader/EvergreenTaskSubHeader.tsx index c15893728..92eeb2abf 100644 --- a/apps/parsley/src/components/SubHeader/EvergreenTaskSubHeader.tsx +++ b/apps/parsley/src/components/SubHeader/EvergreenTaskSubHeader.tsx @@ -1,6 +1,7 @@ import { useQuery } from "@apollo/client"; import { InlineCode } from "@leafygreen-ui/typography"; import TaskStatusBadge from "@evg-ui/lib/components/Badge/TaskStatusBadge"; +import { TaskStatus } from "@evg-ui/lib/types/task"; import { usePreferencesAnalytics } from "analytics"; import { TestStatusBadge } from "components/Badge"; import Breadcrumbs from "components/Breadcrumbs"; @@ -115,7 +116,7 @@ export const EvergreenTaskSubHeader: React.FC = ({ text: ( <> {trimStringFromMiddle(displayName, 30)}{" "} - + ), tooltipText: displayName.length > 30 && displayName, diff --git a/apps/spruce/src/components/GroupedTaskStatusBadge/GroupedTaskStatusBadge.stories.tsx b/apps/spruce/src/components/GroupedTaskStatusBadge/GroupedTaskStatusBadge.stories.tsx index 4da0f0354..e014dc9f6 100644 --- a/apps/spruce/src/components/GroupedTaskStatusBadge/GroupedTaskStatusBadge.stories.tsx +++ b/apps/spruce/src/components/GroupedTaskStatusBadge/GroupedTaskStatusBadge.stories.tsx @@ -1,7 +1,7 @@ import styled from "@emotion/styled"; import { action } from "@storybook/addon-actions"; import { CustomStoryObj, CustomMeta } from "@evg-ui/lib/test_utils/types"; -import { TaskStatus } from "@evg-ui/lib/types/task"; +import { TaskStatus, TaskStatusUmbrella } from "@evg-ui/lib/types/task"; import { GroupedTaskStatusBadge } from "."; @@ -29,13 +29,13 @@ export const Default: CustomStoryObj = { const groupedTaskStats = [ { status: TaskStatus.Succeeded, count: 20 }, { status: TaskStatus.Succeeded, count: 1 }, - { status: TaskStatus.FailedUmbrella, count: 1 }, - { status: TaskStatus.RunningUmbrella, count: 2 }, - { status: TaskStatus.SystemFailureUmbrella, count: 3 }, + { status: TaskStatusUmbrella.Failed, count: 1 }, + { status: TaskStatusUmbrella.Running, count: 2 }, + { status: TaskStatusUmbrella.SystemFailure, count: 3 }, { status: TaskStatus.SetupFailed, count: 4 }, { status: TaskStatus.SetupFailed, count: 1 }, - { status: TaskStatus.UndispatchedUmbrella, count: 5 }, - { status: TaskStatus.ScheduledUmbrella, count: 5 }, + { status: TaskStatusUmbrella.Undispatched, count: 5 }, + { status: TaskStatusUmbrella.Scheduled, count: 5 }, ]; const Container = styled.div` diff --git a/apps/spruce/src/components/GroupedTaskStatusBadge/GroupedTaskStatusBadge.test.tsx b/apps/spruce/src/components/GroupedTaskStatusBadge/GroupedTaskStatusBadge.test.tsx index e991a47f8..71e86af6e 100644 --- a/apps/spruce/src/components/GroupedTaskStatusBadge/GroupedTaskStatusBadge.test.tsx +++ b/apps/spruce/src/components/GroupedTaskStatusBadge/GroupedTaskStatusBadge.test.tsx @@ -4,7 +4,7 @@ import { userEvent, waitFor, } from "@evg-ui/lib/test_utils"; -import { TaskStatus } from "@evg-ui/lib/types/task"; +import { TaskStatus, TaskStatusUmbrella } from "@evg-ui/lib/types/task"; import { getVersionRoute } from "constants/routes"; import { GroupedTaskStatusBadge } from "."; @@ -19,7 +19,7 @@ describe("groupedTaskStatusBadgeIcon", () => { count={400} href={`/version/${versionId}`} onClick={onClick} - status={TaskStatus.SystemFailureUmbrella} + status={TaskStatusUmbrella.SystemFailure} />, { path: "/version/:versionId/:tab", @@ -38,7 +38,7 @@ describe("groupedTaskStatusBadgeIcon", () => { , ); expect(screen.getByText("System Failed")).toBeInTheDocument(); @@ -52,7 +52,7 @@ describe("groupedTaskStatusBadgeIcon", () => { href={getVersionRoute(versionId, { statuses: [TaskStatus.SystemFailed], })} - status={TaskStatus.SystemFailureUmbrella} + status={TaskStatusUmbrella.SystemFailure} />, ); expect(screen.queryByDataCy("grouped-task-status-badge")).toHaveAttribute( @@ -72,7 +72,7 @@ describe("groupedTaskStatusBadgeIcon", () => { , ); diff --git a/apps/spruce/src/components/GroupedTaskStatusBadge/index.tsx b/apps/spruce/src/components/GroupedTaskStatusBadge/index.tsx index abf5b867e..4bcf28300 100644 --- a/apps/spruce/src/components/GroupedTaskStatusBadge/index.tsx +++ b/apps/spruce/src/components/GroupedTaskStatusBadge/index.tsx @@ -1,7 +1,6 @@ import styled from "@emotion/styled"; import Tooltip from "@leafygreen-ui/tooltip"; import { Link } from "react-router-dom"; -import { TaskStatus } from "@evg-ui/lib/types/task"; import { TaskStatusIcon } from "components/TaskStatusIcon"; import { taskStatusToCopy, mapUmbrellaStatusColors } from "constants/task"; import { fontSize, size, zIndex } from "constants/tokens"; @@ -9,7 +8,7 @@ import { fontSize, size, zIndex } from "constants/tokens"; interface GroupedTaskStatusBadgeProps { count: number; onClick?: () => void; - status: TaskStatus; + status: keyof typeof mapUmbrellaStatusColors; statusCounts?: { [key: string]: number }; href: string; isActive?: boolean; @@ -23,7 +22,6 @@ export const GroupedTaskStatusBadge: React.FC = ({ status, statusCounts, }) => { - // @ts-expect-error: FIXME. This comment was added by an automated script. const { border, fill, text } = mapUmbrellaStatusColors[status]; return ( @@ -62,7 +60,6 @@ export const GroupedTaskStatusBadge: React.FC = ({ {taskCount}{" "} - {/* @ts-expect-error: FIXME. This comment was added by an automated script. */} {taskStatusToCopy[taskStatus] ?? taskStatus} diff --git a/apps/spruce/src/components/TaskStatusBadgeWithLink/TaskStatusBadgeWithLink.stories.tsx b/apps/spruce/src/components/TaskStatusBadgeWithLink/TaskStatusBadgeWithLink.stories.tsx index b18ea1b4e..023f43c6a 100644 --- a/apps/spruce/src/components/TaskStatusBadgeWithLink/TaskStatusBadgeWithLink.stories.tsx +++ b/apps/spruce/src/components/TaskStatusBadgeWithLink/TaskStatusBadgeWithLink.stories.tsx @@ -10,10 +10,7 @@ export default { export const Default: CustomStoryObj = { render: () => { - // filter out umbrella statuses - const taskStatuses = Object.values(TaskStatus).filter( - (taskName) => !taskName.includes("Umbrella"), - ); + const taskStatuses = Object.values(TaskStatus); return ( {taskStatuses.map((status) => ( diff --git a/apps/spruce/src/components/TaskStatusBadgeWithLink/__snapshots__/TaskStatusBadgeWithLink_Default.storyshot b/apps/spruce/src/components/TaskStatusBadgeWithLink/__snapshots__/TaskStatusBadgeWithLink_Default.storyshot index d895d5ee7..9005876ea 100644 --- a/apps/spruce/src/components/TaskStatusBadgeWithLink/__snapshots__/TaskStatusBadgeWithLink_Default.storyshot +++ b/apps/spruce/src/components/TaskStatusBadgeWithLink/__snapshots__/TaskStatusBadgeWithLink_Default.storyshot @@ -283,75 +283,5 @@ - - - - - \ No newline at end of file diff --git a/apps/spruce/src/components/TaskStatusBadgeWithLink/index.tsx b/apps/spruce/src/components/TaskStatusBadgeWithLink/index.tsx index b552da49f..b2689f578 100644 --- a/apps/spruce/src/components/TaskStatusBadgeWithLink/index.tsx +++ b/apps/spruce/src/components/TaskStatusBadgeWithLink/index.tsx @@ -20,7 +20,7 @@ const TaskStatusBadgeWithLink: React.FC = ({ tab: status === TaskStatus.KnownIssue ? TaskTab.Annotations : undefined, })} > - + ); diff --git a/apps/spruce/src/components/TasksTable/Columns.tsx b/apps/spruce/src/components/TasksTable/Columns.tsx index c60052cae..86c73d160 100644 --- a/apps/spruce/src/components/TasksTable/Columns.tsx +++ b/apps/spruce/src/components/TasksTable/Columns.tsx @@ -118,7 +118,7 @@ export const getColumnsTemplate = ({ status={getValue() as string} /> ) : ( - + ), meta: { treeSelect: { diff --git a/apps/spruce/src/constants/task.ts b/apps/spruce/src/constants/task.ts index 8a59698c3..d7c388316 100644 --- a/apps/spruce/src/constants/task.ts +++ b/apps/spruce/src/constants/task.ts @@ -1,15 +1,15 @@ import { palette } from "@leafygreen-ui/palette"; -import { TaskStatus } from "@evg-ui/lib/types/task"; +import { TaskStatus, TaskStatusUmbrella } from "@evg-ui/lib/types/task"; import { ALL_VALUE, TreeDataEntry } from "components/TreeSelect"; const { gray, green, purple, red, yellow } = palette; -export const taskStatusToCopy = { - [TaskStatus.ScheduledUmbrella]: "Scheduled", - [TaskStatus.FailedUmbrella]: "Failed", - [TaskStatus.RunningUmbrella]: "Running", - [TaskStatus.SystemFailureUmbrella]: "System Failed", - [TaskStatus.UndispatchedUmbrella]: "Undispatched", +export const taskStatusToCopy: Record = { + [TaskStatusUmbrella.Scheduled]: "Scheduled", + [TaskStatusUmbrella.Failed]: "Failed", + [TaskStatusUmbrella.Running]: "Running", + [TaskStatusUmbrella.SystemFailure]: "System Failed", + [TaskStatusUmbrella.Undispatched]: "Undispatched", [TaskStatus.Aborted]: "Aborted", [TaskStatus.Blocked]: "Blocked", [TaskStatus.Dispatched]: "Dispatched", @@ -33,9 +33,9 @@ export const taskStatusToCopy = { const taskStatuses: TreeDataEntry[] = [ { - title: taskStatusToCopy[TaskStatus.FailedUmbrella], - value: TaskStatus.FailedUmbrella, - key: TaskStatus.FailedUmbrella, + title: taskStatusToCopy[TaskStatusUmbrella.Failed], + value: TaskStatusUmbrella.Failed, + key: TaskStatusUmbrella.Failed, children: [ { title: taskStatusToCopy[TaskStatus.Failed], @@ -65,9 +65,9 @@ const taskStatuses: TreeDataEntry[] = [ key: TaskStatus.Succeeded, }, { - title: taskStatusToCopy[TaskStatus.RunningUmbrella], - value: TaskStatus.RunningUmbrella, - key: TaskStatus.RunningUmbrella, + title: taskStatusToCopy[TaskStatusUmbrella.Running], + value: TaskStatusUmbrella.Running, + key: TaskStatusUmbrella.Running, children: [ { title: taskStatusToCopy[TaskStatus.Started], @@ -82,9 +82,9 @@ const taskStatuses: TreeDataEntry[] = [ ], }, { - title: taskStatusToCopy[TaskStatus.ScheduledUmbrella], - value: TaskStatus.ScheduledUmbrella, - key: TaskStatus.ScheduledUmbrella, + title: taskStatusToCopy[TaskStatusUmbrella.Scheduled], + value: TaskStatusUmbrella.Scheduled, + key: TaskStatusUmbrella.Scheduled, children: [ { title: taskStatusToCopy[TaskStatus.WillRun], @@ -104,9 +104,9 @@ const taskStatuses: TreeDataEntry[] = [ ], }, { - title: taskStatusToCopy[TaskStatus.SystemFailureUmbrella], - value: TaskStatus.SystemFailureUmbrella, - key: TaskStatus.SystemFailureUmbrella, + title: taskStatusToCopy[TaskStatusUmbrella.SystemFailure], + value: TaskStatusUmbrella.SystemFailure, + key: TaskStatusUmbrella.SystemFailure, children: [ { title: taskStatusToCopy[TaskStatus.SystemFailed], @@ -126,9 +126,9 @@ const taskStatuses: TreeDataEntry[] = [ ], }, { - title: taskStatusToCopy[TaskStatus.UndispatchedUmbrella], - value: TaskStatus.UndispatchedUmbrella, - key: TaskStatus.UndispatchedUmbrella, + title: taskStatusToCopy[TaskStatusUmbrella.Undispatched], + value: TaskStatusUmbrella.Undispatched, + key: TaskStatus.Undispatched, children: [ { title: taskStatusToCopy[TaskStatus.Unscheduled], @@ -195,38 +195,28 @@ type ColorScheme = { text: string; }; -export const mapUmbrellaStatusColors: Pick< - Record, - | TaskStatus.UndispatchedUmbrella - | TaskStatus.RunningUmbrella - | TaskStatus.FailedUmbrella - | TaskStatus.SystemFailureUmbrella - | TaskStatus.UndispatchedUmbrella - | TaskStatus.ScheduledUmbrella - | TaskStatus.Succeeded - | TaskStatus.SetupFailed -> = { - [TaskStatus.UndispatchedUmbrella]: { +export const mapUmbrellaStatusColors: Record = { + [TaskStatusUmbrella.Undispatched]: { fill: gray.light3, border: gray.light2, text: gray.dark1, }, - [TaskStatus.RunningUmbrella]: { + [TaskStatusUmbrella.Running]: { fill: yellow.light3, border: yellow.light2, text: yellow.dark2, }, - [TaskStatus.SystemFailureUmbrella]: { + [TaskStatusUmbrella.SystemFailure]: { fill: purple.dark2, border: purple.dark3, text: purple.light3, }, - [TaskStatus.ScheduledUmbrella]: { + [TaskStatusUmbrella.Scheduled]: { fill: gray.dark1, border: gray.dark2, text: gray.light3, }, - [TaskStatus.FailedUmbrella]: { + [TaskStatusUmbrella.Failed]: { fill: red.light3, border: red.light2, text: red.dark2, @@ -244,11 +234,11 @@ export const mapUmbrellaStatusColors: Pick< }; export const mapTaskToBarchartColor = { - [TaskStatus.UndispatchedUmbrella]: gray.dark1, - [TaskStatus.RunningUmbrella]: yellow.base, - [TaskStatus.SystemFailureUmbrella]: purple.dark2, - [TaskStatus.ScheduledUmbrella]: gray.base, - [TaskStatus.FailedUmbrella]: red.base, + [TaskStatusUmbrella.Undispatched]: gray.dark1, + [TaskStatusUmbrella.Running]: yellow.base, + [TaskStatusUmbrella.SystemFailure]: purple.dark2, + [TaskStatusUmbrella.Scheduled]: gray.base, + [TaskStatusUmbrella.Failed]: red.base, [TaskStatus.Succeeded]: green.dark1, [TaskStatus.SetupFailed]: purple.light2, }; @@ -256,12 +246,12 @@ export const mapTaskToBarchartColor = { // Represents order for waterfall barchart export const sortedUmbrellaStatus = [ TaskStatus.Succeeded, - TaskStatus.FailedUmbrella, - TaskStatus.SystemFailureUmbrella, + TaskStatusUmbrella.Failed, + TaskStatusUmbrella.SystemFailure, TaskStatus.SetupFailed, - TaskStatus.RunningUmbrella, - TaskStatus.ScheduledUmbrella, - TaskStatus.UndispatchedUmbrella, + TaskStatusUmbrella.Running, + TaskStatusUmbrella.Scheduled, + TaskStatusUmbrella.Undispatched, ]; export const failedTaskStatuses = [ diff --git a/apps/spruce/src/pages/commits/ActiveCommits/CommitBarChart/CommitChartTooltip.tsx b/apps/spruce/src/pages/commits/ActiveCommits/CommitBarChart/CommitChartTooltip.tsx index 80764b4c5..20342558a 100644 --- a/apps/spruce/src/pages/commits/ActiveCommits/CommitBarChart/CommitChartTooltip.tsx +++ b/apps/spruce/src/pages/commits/ActiveCommits/CommitBarChart/CommitChartTooltip.tsx @@ -3,7 +3,7 @@ import styled from "@emotion/styled"; import { palette } from "@leafygreen-ui/palette"; import Tooltip from "@leafygreen-ui/tooltip"; import { Disclaimer } from "@leafygreen-ui/typography"; -import { TaskStatus } from "@evg-ui/lib/types/task"; +import { TaskStatus, TaskStatusUmbrella } from "@evg-ui/lib/types/task"; import { inactiveElementStyle } from "components/styles"; import { taskStatusToCopy, mapTaskToBarchartColor } from "constants/task"; import { size, zIndex } from "constants/tokens"; @@ -42,7 +42,7 @@ export const CommitChartTooltip: React.FC = ({ count={count} // @ts-expect-error: FIXME. This comment was added by an automated script. eta={ - umbrellaStatus === TaskStatus.RunningUmbrella && eta + umbrellaStatus === TaskStatusUmbrella.Running && eta ? eta : null } @@ -87,7 +87,6 @@ export const TotalCount: React.FC = ({ - {/* @ts-expect-error: FIXME. This comment was added by an automated script. */}
{`Total ${taskStatusToCopy[status]}`}
{eta && `(${msToDuration(new Date(eta).valueOf() - Date.now())} remaining)`} diff --git a/apps/spruce/src/pages/commits/ActiveCommits/utils.test.ts b/apps/spruce/src/pages/commits/ActiveCommits/utils.test.ts index 6107898c5..ca37359b8 100644 --- a/apps/spruce/src/pages/commits/ActiveCommits/utils.test.ts +++ b/apps/spruce/src/pages/commits/ActiveCommits/utils.test.ts @@ -1,4 +1,4 @@ -import { TaskStatus } from "@evg-ui/lib/types/task"; +import { TaskStatus, TaskStatusUmbrella } from "@evg-ui/lib/types/task"; import { groupedTaskStats, groupedTaskStatsAll } from "../testData"; import { getStatusesWithZeroCount, @@ -11,11 +11,11 @@ import { describe("getStatusesWithZeroCount", () => { it("return an array of umbrella statuses that have 0 count", () => { expect(getStatusesWithZeroCount(groupedTaskStats)).toStrictEqual([ - TaskStatus.FailedUmbrella, - TaskStatus.RunningUmbrella, - TaskStatus.ScheduledUmbrella, - TaskStatus.SystemFailureUmbrella, - TaskStatus.UndispatchedUmbrella, + TaskStatusUmbrella.Failed, + TaskStatusUmbrella.Running, + TaskStatusUmbrella.Scheduled, + TaskStatusUmbrella.SystemFailure, + TaskStatusUmbrella.Undispatched, ]); }); it("should return an empty array when all umbrella statuses are present", () => { @@ -23,12 +23,12 @@ describe("getStatusesWithZeroCount", () => { }); it("return an array of all umbrella statuses when no umbrella status exists", () => { expect(getStatusesWithZeroCount([])).toStrictEqual([ - TaskStatus.FailedUmbrella, + TaskStatusUmbrella.Failed, TaskStatus.Succeeded, - TaskStatus.RunningUmbrella, - TaskStatus.ScheduledUmbrella, - TaskStatus.SystemFailureUmbrella, - TaskStatus.UndispatchedUmbrella, + TaskStatusUmbrella.Running, + TaskStatusUmbrella.Scheduled, + TaskStatusUmbrella.SystemFailure, + TaskStatusUmbrella.Undispatched, TaskStatus.SetupFailed, ]); }); diff --git a/apps/spruce/src/pages/commits/testData.ts b/apps/spruce/src/pages/commits/testData.ts index cfce4d44d..6e63b5620 100644 --- a/apps/spruce/src/pages/commits/testData.ts +++ b/apps/spruce/src/pages/commits/testData.ts @@ -1,5 +1,5 @@ import { palette } from "@leafygreen-ui/palette"; -import { TaskStatus } from "@evg-ui/lib/types/task"; +import { TaskStatus, TaskStatusUmbrella } from "@evg-ui/lib/types/task"; const { gray, green, purple, red, yellow } = palette; @@ -179,13 +179,13 @@ const groupedTaskStatsAll = [ color: green.dark1, }, { - umbrellaStatus: TaskStatus.FailedUmbrella, + umbrellaStatus: TaskStatusUmbrella.Failed, count: 1, statuses: [TaskStatus.Failed], color: red.base, }, { - umbrellaStatus: TaskStatus.SystemFailureUmbrella, + umbrellaStatus: TaskStatusUmbrella.SystemFailure, count: 3, statuses: [TaskStatus.SystemFailed], color: purple.dark2, @@ -203,7 +203,7 @@ const groupedTaskStatsAll = [ color: gray.dark1, }, { - umbrellaStatus: TaskStatus.RunningUmbrella, + umbrellaStatus: TaskStatusUmbrella.Running, count: 6, statuses: [TaskStatus.Started], color: yellow.base, @@ -221,13 +221,13 @@ const groupedTaskStatsAll = [ color: gray.dark1, }, { - umbrellaStatus: TaskStatus.ScheduledUmbrella, + umbrellaStatus: TaskStatusUmbrella.Scheduled, count: 7, statuses: [TaskStatus.WillRun], color: gray.dark1, }, { - umbrellaStatus: TaskStatus.UndispatchedUmbrella, + umbrellaStatus: TaskStatusUmbrella.Undispatched, count: 7, statuses: [TaskStatus.Unscheduled], color: gray.dark1, diff --git a/apps/spruce/src/pages/commits/utils.test.ts b/apps/spruce/src/pages/commits/utils.test.ts index 9eaa00169..efbbdf00d 100644 --- a/apps/spruce/src/pages/commits/utils.test.ts +++ b/apps/spruce/src/pages/commits/utils.test.ts @@ -1,5 +1,5 @@ import { palette } from "@leafygreen-ui/palette"; -import { TaskStatus } from "@evg-ui/lib/types/task"; +import { TaskStatus, TaskStatusUmbrella } from "@evg-ui/lib/types/task"; import { taskStatusToCopy } from "constants/task"; import { ProjectHealthView } from "gql/generated/types"; import { @@ -780,7 +780,7 @@ describe("getAllTaskStatsGroupedByColor", () => { taskStatusToCopy[TaskStatus.Failed], ], color: red.base, - umbrellaStatus: TaskStatus.FailedUmbrella, + umbrellaStatus: TaskStatusUmbrella.Failed, statusCounts: { [TaskStatus.TestTimedOut]: 6, [TaskStatus.Failed]: 2, @@ -793,7 +793,7 @@ describe("getAllTaskStatsGroupedByColor", () => { taskStatusToCopy[TaskStatus.SystemUnresponsive], ], color: purple.dark2, - umbrellaStatus: TaskStatus.SystemFailureUmbrella, + umbrellaStatus: TaskStatusUmbrella.SystemFailure, statusCounts: { [TaskStatus.SystemTimedOut]: 5, [TaskStatus.SystemUnresponsive]: 2, @@ -803,14 +803,14 @@ describe("getAllTaskStatsGroupedByColor", () => { count: 4, statuses: [taskStatusToCopy[TaskStatus.Dispatched]], color: yellow.base, - umbrellaStatus: TaskStatus.RunningUmbrella, + umbrellaStatus: TaskStatusUmbrella.Running, statusCounts: { [TaskStatus.Dispatched]: 4 }, }, { count: 2, statuses: [taskStatusToCopy[TaskStatus.WillRun]], color: gray.base, - umbrellaStatus: TaskStatus.ScheduledUmbrella, + umbrellaStatus: TaskStatusUmbrella.Scheduled, statusCounts: { [TaskStatus.WillRun]: 2 }, }, ], @@ -830,7 +830,7 @@ describe("getAllTaskStatsGroupedByColor", () => { count: 2, statuses: [taskStatusToCopy[TaskStatus.Failed]], color: red.base, - umbrellaStatus: TaskStatus.FailedUmbrella, + umbrellaStatus: TaskStatusUmbrella.Failed, statusCounts: { [TaskStatus.Failed]: 2 }, }, { @@ -840,7 +840,7 @@ describe("getAllTaskStatsGroupedByColor", () => { taskStatusToCopy[TaskStatus.Started], ], color: yellow.base, - umbrellaStatus: TaskStatus.RunningUmbrella, + umbrellaStatus: TaskStatusUmbrella.Running, statusCounts: { [TaskStatus.Dispatched]: 4, [TaskStatus.Started]: 5, @@ -863,7 +863,7 @@ describe("getAllTaskStatsGroupedByColor", () => { count: 6, statuses: [taskStatusToCopy[TaskStatus.TaskTimedOut]], color: red.base, - umbrellaStatus: TaskStatus.FailedUmbrella, + umbrellaStatus: TaskStatusUmbrella.Failed, statusCounts: { [TaskStatus.TaskTimedOut]: 6 }, }, { @@ -873,7 +873,7 @@ describe("getAllTaskStatsGroupedByColor", () => { taskStatusToCopy[TaskStatus.SystemUnresponsive], ], color: purple.dark2, - umbrellaStatus: TaskStatus.SystemFailureUmbrella, + umbrellaStatus: TaskStatusUmbrella.SystemFailure, statusCounts: { [TaskStatus.SystemFailed]: 5, [TaskStatus.SystemUnresponsive]: 2, @@ -890,14 +890,14 @@ describe("getAllTaskStatsGroupedByColor", () => { count: 3, statuses: [taskStatusToCopy[TaskStatus.Started]], color: yellow.base, - umbrellaStatus: TaskStatus.RunningUmbrella, + umbrellaStatus: TaskStatusUmbrella.Running, statusCounts: { started: 3 }, }, { count: 2, statuses: [taskStatusToCopy[TaskStatus.Unscheduled]], color: gray.dark1, - umbrellaStatus: TaskStatus.UndispatchedUmbrella, + umbrellaStatus: TaskStatusUmbrella.Undispatched, statusCounts: { [TaskStatus.Unscheduled]: 2 }, }, ], @@ -917,7 +917,7 @@ describe("getAllTaskStatsGroupedByColor", () => { count: 6, statuses: [taskStatusToCopy[TaskStatus.TaskTimedOut]], color: red.base, - umbrellaStatus: TaskStatus.FailedUmbrella, + umbrellaStatus: TaskStatusUmbrella.Failed, statusCounts: { [TaskStatus.TaskTimedOut]: 6 }, }, { @@ -927,7 +927,7 @@ describe("getAllTaskStatsGroupedByColor", () => { taskStatusToCopy[TaskStatus.SystemUnresponsive], ], color: purple.dark2, - umbrellaStatus: TaskStatus.SystemFailureUmbrella, + umbrellaStatus: TaskStatusUmbrella.SystemFailure, statusCounts: { [TaskStatus.SystemFailed]: 5, [TaskStatus.SystemUnresponsive]: 2, @@ -944,14 +944,14 @@ describe("getAllTaskStatsGroupedByColor", () => { count: 3, statuses: [taskStatusToCopy[TaskStatus.Started]], color: yellow.base, - umbrellaStatus: TaskStatus.RunningUmbrella, + umbrellaStatus: TaskStatusUmbrella.Running, statusCounts: { started: 3 }, }, { count: 2, statuses: [taskStatusToCopy[TaskStatus.Unscheduled]], color: gray.dark1, - umbrellaStatus: TaskStatus.UndispatchedUmbrella, + umbrellaStatus: TaskStatusUmbrella.Undispatched, statusCounts: { [TaskStatus.Unscheduled]: 2 }, }, ], diff --git a/apps/spruce/src/pages/version/BuildVariantCard/VariantTaskGroup/VariantTaskGroup.test.tsx b/apps/spruce/src/pages/version/BuildVariantCard/VariantTaskGroup/VariantTaskGroup.test.tsx index 3941d5a01..d6ddf56de 100644 --- a/apps/spruce/src/pages/version/BuildVariantCard/VariantTaskGroup/VariantTaskGroup.test.tsx +++ b/apps/spruce/src/pages/version/BuildVariantCard/VariantTaskGroup/VariantTaskGroup.test.tsx @@ -3,7 +3,7 @@ import { renderWithRouterMatch as render, screen, } from "@evg-ui/lib/test_utils"; -import { TaskStatus } from "@evg-ui/lib/types/task"; +import { TaskStatus, TaskStatusUmbrella } from "@evg-ui/lib/types/task"; import { getVersionRoute } from "constants/routes"; import { mapUmbrellaStatusToQueryParam } from "constants/task"; import { applyStrictRegex } from "utils/string"; @@ -215,7 +215,7 @@ describe("variantTaskGroup", () => { expect(failedBadge).toHaveAttribute( "href", getVersionRoute("1", { - statuses: mapUmbrellaStatusToQueryParam[TaskStatus.FailedUmbrella], + statuses: mapUmbrellaStatusToQueryParam[TaskStatusUmbrella.Failed], variant: applyStrictRegex("some_variant"), page: 0, }), @@ -251,7 +251,7 @@ describe("variantTaskGroup", () => { expect(failedBadge).toHaveAttribute( "href", getVersionRoute("1", { - statuses: mapUmbrellaStatusToQueryParam[TaskStatus.FailedUmbrella], + statuses: mapUmbrellaStatusToQueryParam[TaskStatusUmbrella.Failed], variant: applyStrictRegex("some_variant"), page: 0, }), @@ -287,7 +287,7 @@ describe("variantTaskGroup", () => { expect(failedBadge).toHaveAttribute( "href", getVersionRoute("1", { - statuses: mapUmbrellaStatusToQueryParam[TaskStatus.FailedUmbrella], + statuses: mapUmbrellaStatusToQueryParam[TaskStatusUmbrella.Failed], variant: applyStrictRegex("some_variant"), page: 0, }), diff --git a/apps/spruce/src/pages/version/BuildVariantCard/VariantTaskGroup/index.tsx b/apps/spruce/src/pages/version/BuildVariantCard/VariantTaskGroup/index.tsx index bed3ce9f3..3a2de8e6b 100644 --- a/apps/spruce/src/pages/version/BuildVariantCard/VariantTaskGroup/index.tsx +++ b/apps/spruce/src/pages/version/BuildVariantCard/VariantTaskGroup/index.tsx @@ -1,5 +1,5 @@ import styled from "@emotion/styled"; -import { TaskStatus } from "@evg-ui/lib/types/task"; +import { TaskStatusUmbrella } from "@evg-ui/lib/types/task"; import { arraySymmetricDifference } from "@evg-ui/lib/utils/array"; import { useVersionAnalytics } from "analytics"; import { GroupedTaskStatusBadge } from "components/GroupedTaskStatusBadge"; @@ -123,7 +123,7 @@ const VariantTaskGroup: React.FC = ({ }; const isUmbrellaStatusSet = ( - status: TaskStatus, + status: TaskStatusUmbrella, activeStatusSearch: string[], ) => arraySymmetricDifference( diff --git a/apps/spruce/src/pages/waterfall/BuildRow.tsx b/apps/spruce/src/pages/waterfall/BuildRow.tsx index d2ae1107a..f64a29bde 100644 --- a/apps/spruce/src/pages/waterfall/BuildRow.tsx +++ b/apps/spruce/src/pages/waterfall/BuildRow.tsx @@ -98,7 +98,9 @@ const BuildGrid: React.FC<{ > {build.tasks.map(({ displayName, id, status }) => { // If the entire build is inactive, use inactive status for all tasks - const taskStatus = build.activated ? status : TaskStatus.Inactive; + const taskStatus = build.activated + ? (status as TaskStatus) + : TaskStatus.Inactive; return ( ` +const Square = styled(Link)<{ status: TaskStatus }>` width: ${SQUARE_SIZE}px; height: ${SQUARE_SIZE}px; border: 1px solid ${white}; diff --git a/apps/spruce/src/pages/waterfall/icons/index.ts b/apps/spruce/src/pages/waterfall/icons/index.ts index ecec02ebd..773f76ea5 100644 --- a/apps/spruce/src/pages/waterfall/icons/index.ts +++ b/apps/spruce/src/pages/waterfall/icons/index.ts @@ -8,7 +8,7 @@ import whiteX from "./WhiteX"; const { blue, gray, green, purple, red, yellow } = palette; -export const statusColorMap: Record = { +export const statusColorMap: Record = { [TaskStatus.Succeeded]: green.dark1, [TaskStatus.Started]: yellow.base, [TaskStatus.Dispatched]: yellow.base, @@ -30,7 +30,7 @@ export const statusColorMap: Record = { [TaskStatus.Unstarted]: gray.dark1, }; -export const statusIconMap: Record = { +export const statusIconMap: Partial> = { [TaskStatus.Failed]: whiteX, [TaskStatus.TaskTimedOut]: whiteClockWithArrow, [TaskStatus.TestTimedOut]: whiteClockWithArrow, diff --git a/apps/spruce/src/utils/statuses/groupStatusesByUmbrellaStatus.test.ts b/apps/spruce/src/utils/statuses/groupStatusesByUmbrellaStatus.test.ts index 7a297eb28..8b764119a 100644 --- a/apps/spruce/src/utils/statuses/groupStatusesByUmbrellaStatus.test.ts +++ b/apps/spruce/src/utils/statuses/groupStatusesByUmbrellaStatus.test.ts @@ -1,5 +1,5 @@ import { palette } from "@leafygreen-ui/palette"; -import { TaskStatus } from "@evg-ui/lib/types/task"; +import { TaskStatus, TaskStatusUmbrella } from "@evg-ui/lib/types/task"; import { taskStatusToCopy } from "constants/task"; import { groupStatusesByUmbrellaStatus } from "./groupStatusesByUmbrellaStatus"; @@ -27,7 +27,7 @@ describe("groupStatusesByUmbrellaStatus", () => { count: 2, statuses: [taskStatusToCopy[TaskStatus.Failed]], color: red.base, - umbrellaStatus: TaskStatus.FailedUmbrella, + umbrellaStatus: TaskStatusUmbrella.Failed, statusCounts: { failed: 2 }, }, { @@ -37,7 +37,7 @@ describe("groupStatusesByUmbrellaStatus", () => { taskStatusToCopy[TaskStatus.Started], ], color: yellow.base, - umbrellaStatus: TaskStatus.RunningUmbrella, + umbrellaStatus: TaskStatusUmbrella.Running, statusCounts: { [TaskStatus.Dispatched]: 4, [TaskStatus.Started]: 5 }, }, ], @@ -65,7 +65,7 @@ describe("groupStatusesByUmbrellaStatus", () => { taskStatusToCopy[TaskStatus.Failed], ], color: red.base, - umbrellaStatus: TaskStatus.FailedUmbrella, + umbrellaStatus: TaskStatusUmbrella.Failed, statusCounts: { [TaskStatus.TestTimedOut]: 6, [TaskStatus.Failed]: 2, @@ -78,7 +78,7 @@ describe("groupStatusesByUmbrellaStatus", () => { taskStatusToCopy[TaskStatus.SystemUnresponsive], ], color: purple.dark2, - umbrellaStatus: TaskStatus.SystemFailureUmbrella, + umbrellaStatus: TaskStatusUmbrella.SystemFailure, statusCounts: { [TaskStatus.SystemTimedOut]: 5, [TaskStatus.SystemUnresponsive]: 2, @@ -88,14 +88,14 @@ describe("groupStatusesByUmbrellaStatus", () => { count: 4, statuses: [taskStatusToCopy[TaskStatus.Dispatched]], color: yellow.base, - umbrellaStatus: TaskStatus.RunningUmbrella, + umbrellaStatus: TaskStatusUmbrella.Running, statusCounts: { [TaskStatus.Dispatched]: 4 }, }, { count: 2, statuses: [taskStatusToCopy[TaskStatus.WillRun]], color: gray.base, - umbrellaStatus: TaskStatus.ScheduledUmbrella, + umbrellaStatus: TaskStatusUmbrella.Scheduled, statusCounts: { [TaskStatus.WillRun]: 2 }, }, ], @@ -127,7 +127,7 @@ describe("groupStatusesByUmbrellaStatus", () => { count: 6, statuses: [taskStatusToCopy[TaskStatus.TaskTimedOut]], color: red.base, - umbrellaStatus: TaskStatus.FailedUmbrella, + umbrellaStatus: TaskStatusUmbrella.Failed, statusCounts: { [TaskStatus.TaskTimedOut]: 6 }, }, { @@ -137,7 +137,7 @@ describe("groupStatusesByUmbrellaStatus", () => { taskStatusToCopy[TaskStatus.SystemUnresponsive], ], color: purple.dark2, - umbrellaStatus: TaskStatus.SystemFailureUmbrella, + umbrellaStatus: TaskStatusUmbrella.SystemFailure, statusCounts: { [TaskStatus.SystemFailed]: 5, [TaskStatus.SystemUnresponsive]: 2, @@ -154,14 +154,14 @@ describe("groupStatusesByUmbrellaStatus", () => { count: 3, statuses: [taskStatusToCopy[TaskStatus.Started]], color: yellow.base, - umbrellaStatus: TaskStatus.RunningUmbrella, + umbrellaStatus: TaskStatusUmbrella.Running, statusCounts: { [TaskStatus.Started]: 3 }, }, { count: 2, statuses: [taskStatusToCopy[TaskStatus.Unscheduled]], color: gray.dark1, - umbrellaStatus: TaskStatus.UndispatchedUmbrella, + umbrellaStatus: TaskStatusUmbrella.Undispatched, statusCounts: { [TaskStatus.Unscheduled]: 2 }, }, ], diff --git a/apps/spruce/src/utils/statuses/groupStatusesByUmbrellaStatus.ts b/apps/spruce/src/utils/statuses/groupStatusesByUmbrellaStatus.ts index 054b03c77..9b59e6a99 100644 --- a/apps/spruce/src/utils/statuses/groupStatusesByUmbrellaStatus.ts +++ b/apps/spruce/src/utils/statuses/groupStatusesByUmbrellaStatus.ts @@ -1,4 +1,4 @@ -import { TaskStatus } from "@evg-ui/lib/types/task"; +import { TaskStatusUmbrella } from "@evg-ui/lib/types/task"; import { taskStatusToCopy, mapTaskStatusToUmbrellaStatus, @@ -11,7 +11,7 @@ type ColorCount = { count: number; statuses: string[]; color: string; - umbrellaStatus: TaskStatus; + umbrellaStatus: TaskStatusUmbrella; statusCounts: { [key: string]: number }; }; @@ -28,18 +28,16 @@ export const groupStatusesByUmbrellaStatus = ( if (counts[umbrellaStatus]) { counts[umbrellaStatus].count += stat.count; counts[umbrellaStatus].statuses = deduplicatedAppend( - // @ts-expect-error: FIXME. This comment was added by an automated script. taskStatusToCopy[stat.status], counts[umbrellaStatus].statuses, ); } else { counts[umbrellaStatus] = { count: stat.count, - // @ts-expect-error: FIXME. This comment was added by an automated script. statuses: toArray(taskStatusToCopy[stat.status]), // @ts-expect-error: FIXME. This comment was added by an automated script. color: mapTaskToBarchartColor[umbrellaStatus], - umbrellaStatus: umbrellaStatus as TaskStatus, + umbrellaStatus: umbrellaStatus as TaskStatusUmbrella, statusCounts: {}, }; } diff --git a/packages/lib/src/components/Badge/TaskStatusBadge/TaskStatusBadge.stories.tsx b/packages/lib/src/components/Badge/TaskStatusBadge/TaskStatusBadge.stories.tsx index 34fe72cbb..8f5296bcf 100644 --- a/packages/lib/src/components/Badge/TaskStatusBadge/TaskStatusBadge.stories.tsx +++ b/packages/lib/src/components/Badge/TaskStatusBadge/TaskStatusBadge.stories.tsx @@ -1,18 +1,23 @@ import styled from "@emotion/styled"; import { size } from "constants/tokens"; import { CustomMeta, CustomStoryObj } from "test_utils/types"; -import { TaskStatus } from "types/task"; +import { TaskStatus, TaskStatusUmbrella } from "types/task"; import TaskStatusBadge from "."; export default { component: TaskStatusBadge, } satisfies CustomMeta; +const statuses = [ + ...Object.values(TaskStatus), + ...Object.values(TaskStatusUmbrella), +]; + export const Default: CustomStoryObj = { argTypes: { status: { control: "select", - options: Object.values(TaskStatus), + options: statuses, }, }, args: { @@ -24,7 +29,7 @@ export const Default: CustomStoryObj = { export const AllBadges: CustomStoryObj = { render: () => ( - {Object.values(TaskStatus).map((status) => ( + {statuses.map((status) => ( ))} diff --git a/packages/lib/src/components/Badge/TaskStatusBadge/index.tsx b/packages/lib/src/components/Badge/TaskStatusBadge/index.tsx index 1c284b2e6..068f3d3db 100644 --- a/packages/lib/src/components/Badge/TaskStatusBadge/index.tsx +++ b/packages/lib/src/components/Badge/TaskStatusBadge/index.tsx @@ -3,7 +3,7 @@ import styled from "@emotion/styled"; import Badge, { Variant } from "@leafygreen-ui/badge"; import { palette } from "@leafygreen-ui/palette"; import { taskStatusToCopy } from "../../../constants/task"; -import { TaskStatus } from "../../../types/task"; +import { TaskStatus, TaskStatusUmbrella } from "../../../types/task"; const { purple, red, white } = palette; @@ -26,7 +26,7 @@ const StyledBadge = styled(Badge)` `; interface TaskStatusBadgeProps { - status: string; + status: TaskStatus | TaskStatusUmbrella; } const TaskStatusBadge: React.FC = ({ status }) => { if (!status) { diff --git a/packages/lib/src/constants/task.ts b/packages/lib/src/constants/task.ts index e4d9d11db..d9d3bb2a9 100644 --- a/packages/lib/src/constants/task.ts +++ b/packages/lib/src/constants/task.ts @@ -1,28 +1,30 @@ -import { TaskStatus } from "../types/task"; +import { TaskStatus, TaskStatusUmbrella } from "../types/task"; -export const taskStatusToCopy: Record = { - [TaskStatus.ScheduledUmbrella]: "Scheduled", - [TaskStatus.FailedUmbrella]: "Failed", - [TaskStatus.RunningUmbrella]: "Running", - [TaskStatus.SystemFailureUmbrella]: "System Failed", - [TaskStatus.UndispatchedUmbrella]: "Undispatched", - [TaskStatus.Aborted]: "Aborted", - [TaskStatus.Blocked]: "Blocked", - [TaskStatus.Dispatched]: "Dispatched", - [TaskStatus.Failed]: "Failed", - [TaskStatus.KnownIssue]: "Known Issue", - [TaskStatus.Pending]: "Pending", - [TaskStatus.Started]: "Running", - [TaskStatus.SystemFailed]: "System Failed", - [TaskStatus.SystemTimedOut]: "System Timed Out", - [TaskStatus.SystemUnresponsive]: "System Unresponsive", - [TaskStatus.SetupFailed]: "Setup Failed", - [TaskStatus.Succeeded]: "Succeeded", - [TaskStatus.TaskTimedOut]: "Task Timed Out", - [TaskStatus.TestTimedOut]: "Test Timed Out", - [TaskStatus.Unstarted]: "Unstarted", - [TaskStatus.Unscheduled]: "Unscheduled", - [TaskStatus.WillRun]: "Will Run", - [TaskStatus.Inactive]: "Inactive", - [TaskStatus.Undispatched]: "Undispatched", -}; +export const taskStatusToCopy: Record = + { + [TaskStatus.Aborted]: "Aborted", + [TaskStatus.Blocked]: "Blocked", + [TaskStatus.Dispatched]: "Dispatched", + [TaskStatus.Failed]: "Failed", + [TaskStatus.KnownIssue]: "Known Issue", + [TaskStatus.Pending]: "Pending", + [TaskStatus.Started]: "Running", + [TaskStatus.SystemFailed]: "System Failed", + [TaskStatus.SystemTimedOut]: "System Timed Out", + [TaskStatus.SystemUnresponsive]: "System Unresponsive", + [TaskStatus.SetupFailed]: "Setup Failed", + [TaskStatus.Succeeded]: "Succeeded", + [TaskStatus.TaskTimedOut]: "Task Timed Out", + [TaskStatus.TestTimedOut]: "Test Timed Out", + [TaskStatus.Unstarted]: "Unstarted", + [TaskStatus.Unscheduled]: "Unscheduled", + [TaskStatus.WillRun]: "Will Run", + [TaskStatus.Inactive]: "Inactive", + [TaskStatus.Undispatched]: "Undispatched", + + [TaskStatusUmbrella.Scheduled]: "Scheduled", + [TaskStatusUmbrella.Failed]: "Failed", + [TaskStatusUmbrella.Running]: "Running", + [TaskStatusUmbrella.SystemFailure]: "System Failed", + [TaskStatusUmbrella.Undispatched]: "Undispatched", + }; diff --git a/packages/lib/src/types/task.ts b/packages/lib/src/types/task.ts index c82f577a1..5d76adb56 100644 --- a/packages/lib/src/types/task.ts +++ b/packages/lib/src/types/task.ts @@ -46,10 +46,12 @@ export enum TaskStatus { Aborted = "aborted", KnownIssue = "known-issue", +} - FailedUmbrella = "failed-umbrella", - SystemFailureUmbrella = "system-failure-umbrella", - RunningUmbrella = "running-umbrella", - UndispatchedUmbrella = "undispatched-umbrella", - ScheduledUmbrella = "scheduled-umbrella", +export enum TaskStatusUmbrella { + Failed = "failed-umbrella", + SystemFailure = "system-failure-umbrella", + Running = "running-umbrella", + Undispatched = "undispatched-umbrella", + Scheduled = "scheduled-umbrella", }