Skip to content

Commit

Permalink
DEVPROD-12047: Remove umbrella statuses from TaskStatus (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophstad authored Oct 16, 2024
1 parent 2ca26d1 commit bfa1490
Show file tree
Hide file tree
Showing 23 changed files with 161 additions and 238 deletions.
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -115,7 +116,7 @@ export const EvergreenTaskSubHeader: React.FC<Props> = ({
text: (
<>
{trimStringFromMiddle(displayName, 30)}{" "}
<TaskStatusBadge status={status} />
<TaskStatusBadge status={status as TaskStatus} />
</>
),
tooltipText: displayName.length > 30 && displayName,
Expand Down
Original file line number Diff line number Diff line change
@@ -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 ".";

Expand Down Expand Up @@ -29,13 +29,13 @@ export const Default: CustomStoryObj<typeof GroupedTaskStatusBadge> = {
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`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ".";

Expand All @@ -19,7 +19,7 @@ describe("groupedTaskStatusBadgeIcon", () => {
count={400}
href={`/version/${versionId}`}
onClick={onClick}
status={TaskStatus.SystemFailureUmbrella}
status={TaskStatusUmbrella.SystemFailure}
/>,
{
path: "/version/:versionId/:tab",
Expand All @@ -38,7 +38,7 @@ describe("groupedTaskStatusBadgeIcon", () => {
<GroupedTaskStatusBadge
count={400}
href={`/version/${versionId}`}
status={TaskStatus.SystemFailureUmbrella}
status={TaskStatusUmbrella.SystemFailure}
/>,
);
expect(screen.getByText("System Failed")).toBeInTheDocument();
Expand All @@ -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(
Expand All @@ -72,7 +72,7 @@ describe("groupedTaskStatusBadgeIcon", () => {
<GroupedTaskStatusBadge
count={400}
href={`/version/${versionId}`}
status={TaskStatus.SystemFailureUmbrella}
status={TaskStatusUmbrella.SystemFailure}
statusCounts={statusCounts}
/>,
);
Expand Down
5 changes: 1 addition & 4 deletions apps/spruce/src/components/GroupedTaskStatusBadge/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
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";

interface GroupedTaskStatusBadgeProps {
count: number;
onClick?: () => void;
status: TaskStatus;
status: keyof typeof mapUmbrellaStatusColors;
statusCounts?: { [key: string]: number };
href: string;
isActive?: boolean;
Expand All @@ -23,7 +22,6 @@ export const GroupedTaskStatusBadge: React.FC<GroupedTaskStatusBadgeProps> = ({
status,
statusCounts,
}) => {
// @ts-expect-error: FIXME. This comment was added by an automated script.
const { border, fill, text } = mapUmbrellaStatusColors[status];

return (
Expand Down Expand Up @@ -62,7 +60,6 @@ export const GroupedTaskStatusBadge: React.FC<GroupedTaskStatusBadgeProps> = ({
<TaskStatusIcon size={16} status={taskStatus} />
<span>
<Count>{taskCount}</Count>{" "}
{/* @ts-expect-error: FIXME. This comment was added by an automated script. */}
{taskStatusToCopy[taskStatus] ?? taskStatus}
</span>
</Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ export default {

export const Default: CustomStoryObj<typeof TaskStatusBadgeWithLink> = {
render: () => {
// filter out umbrella statuses
const taskStatuses = Object.values(TaskStatus).filter(
(taskName) => !taskName.includes("Umbrella"),
);
const taskStatuses = Object.values(TaskStatus);
return (
<Container>
{taskStatuses.map((status) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,75 +283,5 @@
</div>
</a>
</div>
<div
class="css-1tojx22"
>
<a
href="/task/1?execution=0"
>
<div
class="css-o6pfbz-StyledBadge-badgeWidthMaxContent ehwsjr70 leafygreen-ui-c62i3c"
data-cy="task-status-badge"
>
Failed
</div>
</a>
</div>
<div
class="css-1tojx22"
>
<a
href="/task/1?execution=0"
>
<div
class="css-o6pfbz-StyledBadge-badgeWidthMaxContent ehwsjr70 leafygreen-ui-c62i3c"
data-cy="task-status-badge"
>
System Failed
</div>
</a>
</div>
<div
class="css-1tojx22"
>
<a
href="/task/1?execution=0"
>
<div
class="css-o6pfbz-StyledBadge-badgeWidthMaxContent ehwsjr70 leafygreen-ui-c62i3c"
data-cy="task-status-badge"
>
Running
</div>
</a>
</div>
<div
class="css-1tojx22"
>
<a
href="/task/1?execution=0"
>
<div
class="css-o6pfbz-StyledBadge-badgeWidthMaxContent ehwsjr70 leafygreen-ui-c62i3c"
data-cy="task-status-badge"
>
Undispatched
</div>
</a>
</div>
<div
class="css-1tojx22"
>
<a
href="/task/1?execution=0"
>
<div
class="css-o6pfbz-StyledBadge-badgeWidthMaxContent ehwsjr70 leafygreen-ui-c62i3c"
data-cy="task-status-badge"
>
Scheduled
</div>
</a>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const TaskStatusBadgeWithLink: React.FC<TaskStatusBadgeWithLinkProps> = ({
tab: status === TaskStatus.KnownIssue ? TaskTab.Annotations : undefined,
})}
>
<TaskStatusBadge status={status} />
<TaskStatusBadge status={status as TaskStatus} />
</Link>
);

Expand Down
2 changes: 1 addition & 1 deletion apps/spruce/src/components/TasksTable/Columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const getColumnsTemplate = ({
status={getValue() as string}
/>
) : (
<TaskStatusBadge status={getValue() as string} />
<TaskStatusBadge status={getValue() as TaskStatus} />
),
meta: {
treeSelect: {
Expand Down
86 changes: 38 additions & 48 deletions apps/spruce/src/constants/task.ts
Original file line number Diff line number Diff line change
@@ -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<string, string> = {
[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",
Expand All @@ -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],
Expand Down Expand Up @@ -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],
Expand All @@ -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],
Expand All @@ -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],
Expand All @@ -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],
Expand Down Expand Up @@ -195,38 +195,28 @@ type ColorScheme = {
text: string;
};

export const mapUmbrellaStatusColors: Pick<
Record<TaskStatus, ColorScheme>,
| TaskStatus.UndispatchedUmbrella
| TaskStatus.RunningUmbrella
| TaskStatus.FailedUmbrella
| TaskStatus.SystemFailureUmbrella
| TaskStatus.UndispatchedUmbrella
| TaskStatus.ScheduledUmbrella
| TaskStatus.Succeeded
| TaskStatus.SetupFailed
> = {
[TaskStatus.UndispatchedUmbrella]: {
export const mapUmbrellaStatusColors: Record<string, ColorScheme> = {
[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,
Expand All @@ -244,24 +234,24 @@ 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,
};

// 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 = [
Expand Down
Loading

0 comments on commit bfa1490

Please sign in to comment.