Skip to content

Commit

Permalink
feat(renterd): uploads list local and remote
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Jan 14, 2025
1 parent 27f4730 commit 713e839
Show file tree
Hide file tree
Showing 16 changed files with 382 additions and 338 deletions.
5 changes: 5 additions & 0 deletions .changeset/sweet-onions-stare.md
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.
8 changes: 5 additions & 3 deletions apps/renterd/components/TransfersBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ export function TransfersBar() {
const { isUnlockedAndAuthedRoute } = useAppSettings()
const { downloadsList, downloadCancel, isViewingUploads, navigateToUploads } =
useFilesManager()
const { datasetPageTotal: uploadsPageTotal } = useUploads()
const {
localUploads: { datasetTotal: uploadsTotal },
} = useUploads()
const [maximized, setMaximized] = useState<boolean>(true)

const isActiveUploads = !!uploadsPageTotal
const isActiveUploads = !!uploadsTotal
const downloadCount = downloadsList.length
const isActiveDownloads = !!downloadCount

Expand All @@ -40,7 +42,7 @@ export function TransfersBar() {
className="flex gap-1"
>
<Upload16 className="opacity-50 scale-75 relative top-px" />
Active uploads
Active uploads ({uploadsTotal.toLocaleString()})
</Button>
) : null}
{isActiveDownloads ? (
Expand Down
29 changes: 0 additions & 29 deletions apps/renterd/components/Uploads/EmptyState/StateNoneMatching.tsx

This file was deleted.

29 changes: 0 additions & 29 deletions apps/renterd/components/Uploads/EmptyState/StateNoneYet.tsx

This file was deleted.

27 changes: 0 additions & 27 deletions apps/renterd/components/Uploads/EmptyState/index.tsx

This file was deleted.

47 changes: 47 additions & 0 deletions apps/renterd/components/Uploads/StateNoneYet.tsx
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>
)
}
60 changes: 60 additions & 0 deletions apps/renterd/components/Uploads/UploadsStatsMenu.tsx
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.datasetPageTotal}
isLoading={localUploads.datasetState === 'loading'}
/>
)

return (
<div className="flex gap-3 w-full">
<Button
onClick={() => setActiveView('localUploads')}
variant={activeView === 'localUploads' ? 'active' : 'inactive'}
>
Local uploads ({localUploads.datasetTotal.toLocaleString()})
</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 apps/renterd/components/Uploads/UploadsStatsMenu/index.tsx

This file was deleted.

31 changes: 20 additions & 11 deletions apps/renterd/components/Uploads/UploadsTable.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
import { Table } from '@siafoundation/design-system'
import { EmptyState } from './EmptyState'
import { EmptyState, Table } from '@siafoundation/design-system'
import { useUploads } from '../../contexts/uploads'
import { StateNoneYet } from './StateNoneYet'
import { StateError } from './StateError'

export function UploadsTable() {
const {
visibleColumns,
sortableColumns,
toggleSort,
datasetPage,
datasetState,
sortField,
sortDirection,
activeData: { datasetPage },
activeTableState: {
visibleColumns,
sortableColumns,
toggleSort,
sortField,
sortDirection,
},
activeDatasetState,
} = useUploads()
return (
<div className="relative">
<Table
testId="uploadsTable"
isLoading={datasetState === 'loading'}
emptyState={<EmptyState />}
isLoading={activeDatasetState === 'loading'}
emptyState={
<EmptyState
datasetState={activeDatasetState}
noneYet={<StateNoneYet />}
error={<StateError />}
/>
}
pageSize={10}
data={datasetPage}
columns={visibleColumns}
Expand Down
10 changes: 6 additions & 4 deletions apps/renterd/components/Uploads/UploadsViewDropdownMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import { useUploads } from '../../contexts/uploads'

export function UploadsViewDropdownMenu() {
const {
configurableColumns,
toggleColumnVisibility,
resetDefaultColumnVisibility,
visibleColumnIds,
activeTableState: {
configurableColumns,
toggleColumnVisibility,
resetDefaultColumnVisibility,
visibleColumnIds,
},
} = useUploads()
return (
<Popover
Expand Down
Loading

0 comments on commit 713e839

Please sign in to comment.