Skip to content

Commit

Permalink
fix(renterd): files directory mode page select ignores parent dir
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Dec 19, 2024
1 parent a9cfe40 commit 33a45ce
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-doors-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': patch
---

Fixed an issue where selecting the entire page of files would select the parent navigation row.
21 changes: 21 additions & 0 deletions apps/renterd-e2e/src/specs/files.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
1 change: 1 addition & 0 deletions apps/renterd/contexts/filesDirectory/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const columns: FilesTableColumn[] = [
return (
<ControlGroup className="flex h-4">
<Checkbox
aria-label="select all files"
onClick={multiSelect.onSelectPage}
checked={multiSelect.isPageAllSelected}
/>
Expand Down
20 changes: 10 additions & 10 deletions apps/renterd/contexts/filesDirectory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 33a45ce

Please sign in to comment.