Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
DEVPROD-835: Add "Depends On" tooltip (#2256)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophstad authored Feb 23, 2024
1 parent cde0efd commit 1f73e92
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
16 changes: 16 additions & 0 deletions cypress/integration/version/task_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,22 @@ describe("Task table", () => {
});
});
});

describe("blocked tasks", () => {
beforeEach(() => {
cy.visit(pathTasks);
waitForTaskTable();
});

it("shows the blocking tasks when hovering over status badge", () => {
cy.dataCy("depends-on-tooltip").should("not.exist");
cy.dataCy("task-status-badge").contains("Blocked").trigger("mouseover");
cy.dataCy("depends-on-tooltip").should("be.visible");
cy.dataCy("depends-on-tooltip").contains(
"Depends on tasks: “test-migrations”, “test-graphql”",
);
});
});
});

const dataCyTableDataRows = ".ant-table-cell > .cy-task-table-col-NAME";
Expand Down
28 changes: 24 additions & 4 deletions src/components/TasksTable/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Tooltip from "@leafygreen-ui/tooltip";
import { Table } from "antd";
import { ColumnProps } from "antd/es/table";
import { SortOrder as antSortOrder } from "antd/lib/table/interface";
import pluralize from "pluralize";
import { ConditionalWrapper } from "components/ConditionalWrapper";
import { StyledRouterLink } from "components/styles";
import {
Expand All @@ -12,13 +14,14 @@ import TaskStatusBadge from "components/TaskStatusBadge";
import { TreeSelectProps } from "components/TreeSelect";
import { getVariantHistoryRoute } from "constants/routes";
import { mergeTaskVariant } from "constants/task";
import { zIndex } from "constants/tokens";
import {
Task,
SortDirection,
SortOrder,
TaskSortCategory,
} from "gql/generated/types";
import { TableOnChange } from "types/task";
import { TableOnChange, TaskStatus } from "types/task";
import { sortTasks } from "utils/statuses";
import { TaskLink } from "./TaskLink";

Expand All @@ -27,6 +30,7 @@ type TaskTableInfo = {
status: string;
};
buildVariantDisplayName?: string;
dependsOn?: Array<{ name: string }>;
displayName: string;
executionTasksFull?: TaskTableInfo[];
id: string;
Expand Down Expand Up @@ -172,9 +176,25 @@ const getColumnDefs = ({
multiple: 4,
},
className: "cy-task-table-col-STATUS",
render: (status: string, { execution, id }) =>
status && (
<TaskStatusBadge status={status} id={id} execution={execution} />
render: (status: string, { dependsOn, execution, id }) =>
dependsOn?.length && status === TaskStatus.Blocked ? (
<Tooltip
data-cy="depends-on-tooltip"
justify="middle"
popoverZIndex={zIndex.tooltip}
trigger={
<span>
<TaskStatusBadge status={status} id={id} execution={execution} />
</span>
}
>
Depends on {pluralize("task", dependsOn.length)}:{" "}
{dependsOn.map(({ name }) => `“${name}”`).join(", ")}
</Tooltip>
) : (
status && (
<TaskStatusBadge status={status} id={id} execution={execution} />
)
),
...(statusSelectorProps && {
...getColumnTreeSelectFilterProps({
Expand Down
1 change: 1 addition & 0 deletions src/gql/generated/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8870,6 +8870,7 @@ export type VersionTasksQuery = {
id: string;
status: string;
} | null;
dependsOn?: Array<{ __typename?: "Dependency"; name: string }> | null;
executionTasksFull?: Array<{
__typename?: "Task";
buildVariant: string;
Expand Down
3 changes: 3 additions & 0 deletions src/gql/queries/version-tasks.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ query VersionTasks(
blocked
buildVariant
buildVariantDisplayName
dependsOn {
name
}
displayName
execution
executionTasksFull {
Expand Down

0 comments on commit 1f73e92

Please sign in to comment.