mirror of
https://github.com/supabase/supabase.git
synced 2026-10-15 22:29:11 +03:00
## 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>
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import type { Bucket } from '@/data/storage/buckets-query'
|
|
|
|
export type BucketVersioningState = 'enabled' | 'suspended' | 'disabled'
|
|
export type ExpirationMode = 'and' | 'or'
|
|
|
|
export const PROJECT_VERSIONING_DEFAULTS = {
|
|
versionExpiryDays: 30,
|
|
maxNoncurrentVersions: 10,
|
|
} as const
|
|
|
|
export const getBucketVersioningState = (bucket?: Bucket): BucketVersioningState => {
|
|
switch (bucket?.versioning_status) {
|
|
case 'ENABLED':
|
|
return 'enabled'
|
|
case 'SUSPENDED':
|
|
return 'suspended'
|
|
default:
|
|
return 'disabled'
|
|
}
|
|
}
|
|
|
|
/**
|
|
* The bucket versions writes right now: a delete becomes a recoverable archive and an
|
|
* overwrite becomes a new version. Drives what the actions are called.
|
|
*/
|
|
export const isVersioningActive = (bucket?: Bucket) =>
|
|
getBucketVersioningState(bucket) === 'enabled'
|
|
|
|
/** A suspended bucket can still be retaining versions. */
|
|
export const hasVersioningHistory = (bucket?: Bucket) =>
|
|
getBucketVersioningState(bucket) !== 'disabled'
|
|
|
|
/**
|
|
* A suspended bucket retains a copy when the object it replaces
|
|
* was itself written while versioning was enabled.
|
|
*/
|
|
export const willRetainVersionOnWrite = ({
|
|
versioningState,
|
|
isObjectVersioned,
|
|
}: {
|
|
versioningState: BucketVersioningState
|
|
isObjectVersioned?: boolean | null
|
|
}) => {
|
|
if (versioningState === 'enabled') return true
|
|
return versioningState === 'suspended' && !!isObjectVersioned
|
|
}
|