From 35df2011837acc8c3cd64e8180b451c0e83285ec Mon Sep 17 00:00:00 2001 From: Mohamed Khelif Date: Mon, 4 Mar 2024 15:07:20 -0500 Subject: [PATCH] DEVPROD-1975 Migrate TaskQueueTable to leafygreen table (#2199) --- .../integration/task/task_queue_position.ts | 2 +- cypress/integration/taskQueue/route.ts | 39 +- package.json | 2 +- src/components/Content/index.tsx | 1 - src/components/SearchableDropdown/index.tsx | 1 + src/components/Table/BaseTable.tsx | 31 +- .../__snapshots__/BaseTable.stories.storyshot | 3346 ++++++------ src/constants/routes.ts | 9 +- src/pages/taskQueue/TaskQueueTable.tsx | 172 - .../TaskQueueTable/TaskQueueTable.stories.tsx | 50 + .../TaskQueueTable.stories.storyshot | 4660 +++++++++++++++++ src/pages/taskQueue/TaskQueueTable/index.tsx | 169 + src/pages/taskQueue/index.tsx | 189 +- .../TaskDurationTable.stories.storyshot | 438 +- src/types/task.ts | 1 + yarn.lock | 68 +- 16 files changed, 6980 insertions(+), 2198 deletions(-) delete mode 100644 src/pages/taskQueue/TaskQueueTable.tsx create mode 100644 src/pages/taskQueue/TaskQueueTable/TaskQueueTable.stories.tsx create mode 100644 src/pages/taskQueue/TaskQueueTable/__snapshots__/TaskQueueTable.stories.storyshot create mode 100644 src/pages/taskQueue/TaskQueueTable/index.tsx diff --git a/cypress/integration/task/task_queue_position.ts b/cypress/integration/task/task_queue_position.ts index d8d08a947e..4cebc4cb6d 100644 --- a/cypress/integration/task/task_queue_position.ts +++ b/cypress/integration/task/task_queue_position.ts @@ -10,7 +10,7 @@ describe("Task Queue Position", () => { .should("have.attr", "href") .and( "eq", - "/task-queue/archlinux-test/evergreen_lint_lint_service_patch_5e823e1f28baeaa22ae00823d83e03082cd148ab_5e4ff3abe3c3317e352062e4_20_02_21_15_13_48", + "/task-queue/archlinux-test?taskId=evergreen_lint_lint_service_patch_5e823e1f28baeaa22ae00823d83e03082cd148ab_5e4ff3abe3c3317e352062e4_20_02_21_15_13_48", ); }); diff --git a/cypress/integration/taskQueue/route.ts b/cypress/integration/taskQueue/route.ts index 8ce8cdd562..a425813d4b 100644 --- a/cypress/integration/taskQueue/route.ts +++ b/cypress/integration/taskQueue/route.ts @@ -9,24 +9,16 @@ describe("Task Queue", () => { it("Uses distro param in url to query queue and renders table", () => { cy.visit("/task-queue/osx-108"); - - cy.get(".ant-table-row").should("have.length", 13); - - cy.visit("/task-queue/debian71-test"); - - cy.get(".ant-table-row").should("have.length", 0); + cy.dataCy("task-queue-table").should("exist"); + cy.contains("osx-108").should("exist"); }); it("Selecting a distro queries the queue for that distro", () => { cy.visit("/task-queue/debian71-test"); - - cy.get(".ant-table-row").should("have.length", 0); - + cy.contains("No tasks found in queue").should("exist"); cy.dataCy("distro-dropdown").click(); - cy.get("div").contains("osx-108").click(); - - cy.get(".ant-table-row").should("have.length", 13); + cy.dataCy("leafygreen-table-row").should("have.length", 13); }); it("Renders link to host page filtered to that particular distro", () => { @@ -38,35 +30,28 @@ describe("Task Queue", () => { it("Searching for a distro shows results that match search term", () => { cy.visit("/task-queue/debian71-test"); - - cy.dataCy("distro-dropdown").click(); + cy.dataCy("distro-dropdown").should("have.attr", "aria-disabled", "false"); + cy.dataCy("distro-dropdown").click({ force: true }); + cy.dataCy("distro-dropdown-search-input").should("exist"); cy.dataCy("distro-dropdown-search-input").type("osx"); cy.dataCy("distro-dropdown-options").within(() => { cy.contains("debian71-test").should("not.exist"); cy.contains("osx-108").should("exist"); }); }); - - it("Bogus distro url param values do not display any results", () => { - cy.visit("/task-queue/peace"); - cy.get(".ant-table-row").should("have.length", 0); - }); - it("Scrolls to current task if taskId param in url", () => { cy.visit( - "/task-queue/osx-108/evergreen_lint_lint_service_patch_5e823e1f28baeaa22ae00823d83e03082cd148ab_5e4ff3abe3c3317e352062e4_20_02_21_15_13_48", + "/task-queue/osx-108?taskId=evergreen_lint_lint_service_patch_5e823e1f28baeaa22ae00823d83e03082cd148ab_5e4ff3abe3c3317e352062e4_20_02_21_15_13_48", ); cy.dataCy("task-queue-table").should("exist"); - cy.get(".ant-table-row-selected").should("exist"); - cy.get(".ant-table-row-selected").should("contain.text", "13"); - - cy.contains("osx-108").should("not.be.visible"); - cy.get(".ant-table-row-selected").should("be.visible"); + cy.get("[data-selected='true']").should("exist"); + cy.get("[data-selected='true']").should("have.length", 1); + cy.get("[data-selected='true']").should("be.visible"); }); it("Task links goes to Spruce for both patches and mainline commits", () => { cy.visit( - "/task-queue/osx-108/evergreen_lint_lint_service_patch_5e823e1f28baeaa22ae00823d83e03082cd148ab_5e4ff3abe3c3317e352062e4_20_02_21_15_13_48", + "/task-queue/osx-108?taskId=evergreen_lint_lint_service_patch_5e823e1f28baeaa22ae00823d83e03082cd148ab_5e4ff3abe3c3317e352062e4_20_02_21_15_13_48", ); // patch diff --git a/package.json b/package.json index 78f5c928cd..1c05bfd659 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "@leafygreen-ui/select": "11.1.1", "@leafygreen-ui/side-nav": "14.1.0", "@leafygreen-ui/skeleton-loader": "1.1.0", - "@leafygreen-ui/table": "12.3.0", + "@leafygreen-ui/table": "12.5.0", "@leafygreen-ui/tabs": "11.0.4", "@leafygreen-ui/text-area": "8.0.21", "@leafygreen-ui/text-input": "12.1.24", diff --git a/src/components/Content/index.tsx b/src/components/Content/index.tsx index b6df1ed174..552e046213 100644 --- a/src/components/Content/index.tsx +++ b/src/components/Content/index.tsx @@ -80,7 +80,6 @@ export const Content: React.FC = () => ( } /> }> - } /> ({ } onClose={resetSearch} ref={DropdownRef} + aria-disabled={disabled} > , @@ -72,11 +78,10 @@ export const BaseTable = forwardRef( const { virtualRows } = table; const { rows } = table.getRowModel(); const hasVirtualRows = virtualRows && virtualRows.length > 0; - return ( <> - + {table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => { @@ -140,11 +145,21 @@ export const BaseTable = forwardRef( ? virtualRows.map((vr) => { const row = rows[vr.index]; return ( - + ); }) : rows.map((row) => ( - + ))} @@ -159,11 +174,13 @@ export const BaseTable = forwardRef( const cellPaddingStyle = { paddingBottom: size.xxs, paddingTop: size.xxs }; const RenderableRow = ({ + isSelected = false, row, virtualRow, }: { row: LeafyGreenTableRow; virtualRow: VirtualItem; + isSelected?: boolean; }) => ( ({ &[aria-hidden="false"] td > div { max-height: unset; } + ${isSelected && + ` + background-color: ${blue.light3} !important; + font-weight:bold; + `} `} + data-selected={isSelected} virtualRow={virtualRow} > {row.getVisibleCells().map((cell) => ( diff --git a/src/components/Table/__snapshots__/BaseTable.stories.storyshot b/src/components/Table/__snapshots__/BaseTable.stories.storyshot index 551c39027c..6d6ab41b08 100644 --- a/src/components/Table/__snapshots__/BaseTable.stories.storyshot +++ b/src/components/Table/__snapshots__/BaseTable.stories.storyshot @@ -14,11 +14,11 @@ exports[`Snapshot Tests BaseTable.stories Default 1`] = ` >
Name
Type
Size
Name
Type
Size
Name
Type
Size