Files
Francesco SansalvadoreandClaude Sonnet 5 cb4307f15b feat(studio): storage versioning - archived UI (#51476)
## This PR

Adds **Show archived** to the file explorer's view options and list them
in the file explorer.

- `useStoragePreference` — `showArchivedInline`, stored per project
- `ArchivedFilesContext` — owns the archived list and which object is
selected
- `FileExplorer` — merges archived rows into each column and re-sorts,
since the server-side sort never sees them
- `FileExplorerRow` — dimmed striped rendering, no checkbox, no context
menu
- `FileExplorerHeader` — the toggle, rendered only behind the feature
preview
- `StorageExplorer` — mounts the provider


https://github.com/user-attachments/assets/a26551b4-b22d-485e-9d23-3e78c4a89315

Clicking an archived row opens a preview panel: where the file used to
live, when it was archived, its retained versions, and the actions to
bring it back or delete it permanently.

- `ArchivedFilePreviewPane` — the pane, replacing `PreviewPane` while an
archived row is selected
- `ArchivedVersionRestoreWidget` — takes over the top of the pane when a
specific retained version is selected
- `ArchivedVersionRow` — one version, with its restore / delete actions
- `StorageExplorerContent` — the pane swap


https://github.com/user-attachments/assets/03c9eae6-e9e3-4bd0-8145-953625e125d1

Other additions behind the feature preview:

- The buckets list show a **Versioning** column.
- `BucketVersioningPill` — a `file-stack` badge beside the bucket name
in the breadcrumbs, brand when versioning is enabled and warning when it
is suspended, so the bucket's state is visible from inside the explorer
rather than only from the buckets list.


https://github.com/user-attachments/assets/f4827aac-a9ff-4300-92ac-073848d63606

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-12 17:13:16 +02:00

133 lines
4.0 KiB
TypeScript

import { useRef } from 'react'
import { Table, TableBody } from 'ui'
import { LoadMoreRow } from './BucketsTable.LoadMoreRow'
import type { BucketsTablePaginationProps } from './BucketsTable.types'
import {
BucketTableEmptyState,
BucketTableHeader,
BucketTableRow,
useVersioningColumnSpan,
} from './BucketTable'
import { VirtualizedTable, VirtualizedTableBody } from '@/components/ui/VirtualizedTable'
import { Bucket } from '@/data/storage/buckets-query'
type BucketsTableProps = {
buckets: Bucket[]
projectRef: string
filterString: string
formattedGlobalUploadLimit: string
pagination: BucketsTablePaginationProps
}
// [Joshen] To investigate: There's a lot of duplicate logic + components between
// this FilesBuckets/BucketsTable and BucketsPickerDialog/BucketsTable. Check separately
// if they can be cleaned up and consolidated. The latter should take precedence as it aims to
// reduce footprint on the giant StorageExplorerState.
export const BucketsTable = (props: BucketsTableProps) => {
// [Joshen] To investigate: Can't we just default to virtualized?
// Do we need to dynamically decide whether to use a virtualized or unvirtualized one?
const isVirtualized = props.buckets.length > 50
return isVirtualized ? (
<BucketsTableVirtualized {...props} />
) : (
<BucketsTableUnvirtualized {...props} />
)
}
const BucketsTableUnvirtualized = ({
buckets,
projectRef,
filterString,
formattedGlobalUploadLimit,
pagination: { hasMore = false, isLoadingMore = false, onLoadMore },
}: BucketsTableProps) => {
const showSearchEmptyState = buckets.length === 0 && filterString.length > 0
const versioningColumnSpan = useVersioningColumnSpan()
return (
<Table
containerProps={{
containerClassName: 'h-full overflow-auto',
className: 'overflow-visible',
}}
>
<BucketTableHeader mode="standard" hasBuckets={buckets.length > 0} />
<TableBody>
{showSearchEmptyState ? (
<BucketTableEmptyState mode="standard" filterString={filterString} />
) : (
buckets.map((bucket) => (
<BucketTableRow
mode="standard"
key={bucket.id}
bucket={bucket}
projectRef={projectRef}
formattedGlobalUploadLimit={formattedGlobalUploadLimit}
/>
))
)}
<LoadMoreRow
mode="standard"
colSpan={6 + versioningColumnSpan}
hasMore={hasMore}
isLoadingMore={isLoadingMore}
onLoadMore={onLoadMore}
/>
</TableBody>
</Table>
)
}
const BucketsTableVirtualized = ({
buckets,
projectRef,
filterString,
formattedGlobalUploadLimit,
pagination: { hasMore = false, isLoadingMore = false, onLoadMore },
}: BucketsTableProps) => {
const showSearchEmptyState = buckets.length === 0 && filterString.length > 0
const versioningColumnSpan = useVersioningColumnSpan()
const scrollContainerRef = useRef<HTMLDivElement>(null)
return (
<VirtualizedTable
data={buckets}
estimateSize={() => 59}
getItemKey={(bucket) => bucket.id}
scrollContainerRef={scrollContainerRef}
>
<BucketTableHeader mode="virtualized" hasBuckets={buckets.length > 0} />
<VirtualizedTableBody<Bucket>
paddingColSpan={5 + versioningColumnSpan}
emptyContent={
showSearchEmptyState ? (
<BucketTableEmptyState mode="virtualized" filterString={filterString} />
) : undefined
}
trailingContent={
<LoadMoreRow
mode="virtualized"
colSpan={6 + versioningColumnSpan}
hasMore={hasMore}
isLoadingMore={isLoadingMore}
onLoadMore={onLoadMore}
/>
}
>
{(bucket) => (
<BucketTableRow
mode="virtualized"
key={bucket.id}
bucket={bucket}
projectRef={projectRef}
formattedGlobalUploadLimit={formattedGlobalUploadLimit}
/>
)}
</VirtualizedTableBody>
</VirtualizedTable>
)
}