From 33a45ce29f23a7e5dc47af7d3a30dab59068fc0e Mon Sep 17 00:00:00 2001 From: Alex Freska Date: Thu, 19 Dec 2024 09:01:24 -0500 Subject: [PATCH] fix(renterd): files directory mode page select ignores parent dir --- .changeset/polite-doors-do.md | 5 +++++ apps/renterd-e2e/src/specs/files.spec.ts | 21 +++++++++++++++++++ .../contexts/filesDirectory/columns.tsx | 1 + .../renterd/contexts/filesDirectory/index.tsx | 20 +++++++++--------- 4 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 .changeset/polite-doors-do.md diff --git a/.changeset/polite-doors-do.md b/.changeset/polite-doors-do.md new file mode 100644 index 000000000..5f4c28d17 --- /dev/null +++ b/.changeset/polite-doors-do.md @@ -0,0 +1,5 @@ +--- +'renterd': patch +--- + +Fixed an issue where selecting the entire page of files would select the parent navigation row. diff --git a/apps/renterd-e2e/src/specs/files.spec.ts b/apps/renterd-e2e/src/specs/files.spec.ts index e20801353..f72d8c2d2 100644 --- a/apps/renterd-e2e/src/specs/files.spec.ts +++ b/apps/renterd-e2e/src/specs/files.spec.ts @@ -338,3 +338,24 @@ test('bulk delete using the all files explorer mode', async ({ page }) => { }, }) }) + +test('bulk selecting the entire page ignores the .. parent directory nav row', async ({ + page, +}) => { + const bucketName = 'bucket1' + await navigateToBuckets({ page }) + await createBucket(page, bucketName) + await createFilesMap(page, bucketName, { + 'file1.txt': null, + 'file2.txt': null, + 'file3.txt': null, + 'file4.txt': null, + 'file5.txt': null, + }) + await navigateToBuckets({ page }) + await openBucket(page, bucketName) + + await page.getByRole('checkbox', { name: 'select all files' }).check() + const menu = page.getByLabel('file multi-select menu') + await expect(menu.getByText('5 files selected')).toBeVisible() +}) diff --git a/apps/renterd/contexts/filesDirectory/columns.tsx b/apps/renterd/contexts/filesDirectory/columns.tsx index 089d7f227..a084daeb0 100644 --- a/apps/renterd/contexts/filesDirectory/columns.tsx +++ b/apps/renterd/contexts/filesDirectory/columns.tsx @@ -36,6 +36,7 @@ export const columns: FilesTableColumn[] = [ return ( diff --git a/apps/renterd/contexts/filesDirectory/index.tsx b/apps/renterd/contexts/filesDirectory/index.tsx index 3401c8877..e7ded0adc 100644 --- a/apps/renterd/contexts/filesDirectory/index.tsx +++ b/apps/renterd/contexts/filesDirectory/index.tsx @@ -27,6 +27,16 @@ function useFilesDirectoryMain() { const { limit, marker, isMore, response, refresh, dataset } = useDataset() + const multiSelect = useMultiSelect(dataset) + + // If the active bucket changes, clear the multi-select. + useEffect(() => { + if (activeBucket) { + multiSelect.deselectAll() + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [activeBucket]) + // Add parent directory to the dataset. const _datasetPage = useMemo(() => { if (!dataset) { @@ -55,16 +65,6 @@ function useFilesDirectoryMain() { // eslint-disable-next-line react-hooks/exhaustive-deps }, [dataset]) - const multiSelect = useMultiSelect(_datasetPage) - - // If the active bucket changes, clear the multi-select. - useEffect(() => { - if (activeBucket) { - multiSelect.deselectAll() - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [activeBucket]) - const { onDragEnd, onDragOver,