-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(renterd): uploads list local and remote
- Loading branch information
1 parent
e526e1c
commit ecbd835
Showing
21 changed files
with
469 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'renterd': minor | ||
--- | ||
|
||
The uploads list now has two views, one for local uploads only and one for all uploads including from other devices. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { test, expect, Page } from '@playwright/test' | ||
import { navigateToBuckets } from '../fixtures/navigate' | ||
import { createBucket, openBucket } from '../fixtures/buckets' | ||
import { changeExplorerMode, createFilesMap } from '../fixtures/files' | ||
import { afterTest, beforeTest } from '../fixtures/beforeTest' | ||
import { workerMultipartKeyRoute } from '@siafoundation/renterd-types' | ||
import { getUploadRows, getUploadsTable } from '../fixtures/uploads' | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await beforeTest(page, { | ||
hostdCount: 3, | ||
}) | ||
// Simulate in progress uploads. | ||
await mockApiWorkerMultipartUploadPartHanging({ page }) | ||
}) | ||
|
||
test.afterEach(async () => { | ||
await afterTest() | ||
}) | ||
|
||
test('uploads are shown in the local and all uploads lists', async ({ | ||
page, | ||
}) => { | ||
const bucketName = 'bucket1' | ||
await navigateToBuckets({ page }) | ||
await createBucket(page, bucketName) | ||
await openBucket(page, bucketName) | ||
await createFilesMap(page, bucketName, { | ||
'file1.txt': 10, | ||
'file2.txt': 10, | ||
'file3.txt': 10, | ||
'file4.txt': 10, | ||
'file5.txt': 10, | ||
'file6.txt': 10, | ||
}) | ||
await expect( | ||
page.getByRole('button', { name: 'Active uploads' }) | ||
).toBeVisible() | ||
await changeExplorerMode(page, 'uploads') | ||
await expect(getUploadRows(page)).toHaveCount(6) | ||
await expect(getUploadsTable(page).getByText('uploading')).toHaveCount(5) | ||
await expect(getUploadsTable(page).getByText('queued')).toHaveCount(1) | ||
await expect(page.getByText('1 - 6 of 6')).toBeVisible() | ||
await expect(page.getByRole('button', { name: 'All uploads' })).toBeVisible() | ||
await page.getByRole('button', { name: 'All uploads' }).click() | ||
await expect(page.getByText('1 - 6 of 6')).toBeHidden() | ||
await expect(getUploadRows(page)).toHaveCount(5) | ||
await expect(getUploadsTable(page).getByText('uploading')).toHaveCount(5) | ||
await expect(getUploadsTable(page).getByText('queued')).toHaveCount(0) | ||
}) | ||
|
||
export async function mockApiWorkerMultipartUploadPartHanging({ | ||
page, | ||
}: { | ||
page: Page | ||
}) { | ||
await page.route( | ||
`**/api${workerMultipartKeyRoute.replace(':key', '')}*`, | ||
async () => { | ||
await new Promise(() => { | ||
// Never resolve, leaving the request hanging. | ||
}) | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 0 additions & 29 deletions
29
apps/renterd/components/Uploads/EmptyState/StateNoneMatching.tsx
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
apps/renterd/components/Uploads/EmptyState/StateNoneYet.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Code, LinkButton, Text } from '@siafoundation/design-system' | ||
import { CloudUpload32 } from '@siafoundation/react-icons' | ||
import { routes } from '../../config/routes' | ||
import { useFilesManager } from '../../contexts/filesManager' | ||
import { useUploads } from '../../contexts/uploads' | ||
|
||
export function StateNoneYet() { | ||
const { activeView } = useUploads() | ||
const { activeBucketName: activeBucket } = useFilesManager() | ||
|
||
const href = activeBucket | ||
? routes.buckets.files | ||
.replace('[bucket]', activeBucket) | ||
.replace('[path]', '') | ||
: routes.buckets.index | ||
|
||
return ( | ||
<div className="flex flex-col gap-10 justify-center items-center h-[400px]"> | ||
<Text> | ||
<CloudUpload32 className="scale-[200%]" /> | ||
</Text> | ||
<div className="flex flex-col gap-3 items-center"> | ||
<Text color="subtle" className="text-center max-w-[500px]"> | ||
{activeView === 'localUploads' ? ( | ||
<> | ||
The <Code>{activeBucket}</Code> bucket does not have any active | ||
uploads from this session. | ||
</> | ||
) : ( | ||
<> | ||
The <Code>{activeBucket}</Code> bucket does not have any active | ||
uploads. | ||
</> | ||
)} | ||
</Text> | ||
<LinkButton | ||
href={href} | ||
onClick={(e) => { | ||
e.stopPropagation() | ||
}} | ||
> | ||
{activeBucket ? 'View files' : 'View buckets list'} | ||
</LinkButton> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { | ||
Button, | ||
PaginatorKnownTotal, | ||
PaginatorMarker, | ||
} from '@siafoundation/design-system' | ||
import { useUploads } from '../../contexts/uploads' | ||
|
||
export function UploadsStatsMenu() { | ||
const { | ||
activeData, | ||
abortAll, | ||
activeView, | ||
remoteUploads, | ||
localUploads, | ||
setActiveView, | ||
} = useUploads() | ||
|
||
const paginatorEl = | ||
activeView === 'globalUploads' ? ( | ||
<PaginatorMarker | ||
marker={remoteUploads.marker} | ||
nextMarker={remoteUploads.nextMarker} | ||
isMore={remoteUploads.hasMore} | ||
limit={remoteUploads.limit} | ||
pageTotal={remoteUploads.datasetPageTotal} | ||
isLoading={remoteUploads.datasetState === 'loading'} | ||
/> | ||
) : ( | ||
<PaginatorKnownTotal | ||
offset={localUploads.offset} | ||
limit={localUploads.limit} | ||
total={localUploads.datasetTotal} | ||
isLoading={localUploads.datasetState === 'loading'} | ||
/> | ||
) | ||
|
||
return ( | ||
<div className="flex gap-3 w-full"> | ||
<Button | ||
onClick={() => setActiveView('localUploads')} | ||
variant={activeView === 'localUploads' ? 'active' : 'inactive'} | ||
> | ||
Local uploads | ||
</Button> | ||
<Button | ||
onClick={() => setActiveView('globalUploads')} | ||
variant={activeView === 'globalUploads' ? 'active' : 'inactive'} | ||
> | ||
All uploads | ||
</Button> | ||
<div className="flex-1" /> | ||
{activeData.datasetPageTotal > 0 && ( | ||
<Button onClick={abortAll}> | ||
Abort ({activeData.datasetPageTotal}) | ||
</Button> | ||
)} | ||
{paginatorEl} | ||
</div> | ||
) | ||
} |
30 changes: 0 additions & 30 deletions
30
apps/renterd/components/Uploads/UploadsStatsMenu/index.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.