Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(renterd): files directory mode page select ignores parent dir #866

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading