improve comments

This commit is contained in:
Francesco Sansalvadore authored and GitHub committed 2026-10-05 15:04:14 +02:00
1 parent 0f4cd1ea03
commit 87362e6ba9
7 files changed
+2 -47

No files matched your search

@@ -17,9 +17,6 @@ export const ConfirmDeleteModal = () => {
} = useStorageExplorerStateSnapshot()
const isStorageVersioningEnabled = useIsStorageVersioningEnabled()
// On a versioned bucket a delete is a soft delete: the object is hidden but
// every version stays recoverable, so the usual "cannot be undone" warning
// would be wrong.
const isVersionedBucket =
isStorageVersioningEnabled && getBucketVersioningState(selectedBucket) !== 'disabled'
@@ -200,11 +200,6 @@ const CurrentFilePreview = ({
}: CurrentFilePreviewProps) => (
<div className="border-b border-overlay p-3">
<div
/*
* ~144px of chrome sits above, so the preview takes 40% of what's left of
* the viewport. The floor keeps the sections below scrollable; the cap
* stops the preview dominating tall viewports.
*/
className="flex items-center justify-center overflow-hidden rounded-md border border-overlay"
style={{ height: 'clamp(120px, calc((100vh - 144px) * 0.4), 180px)' }}
>
@@ -282,8 +277,7 @@ const CurrentFilePreview = ({
</DropdownMenu>
)}
{/* A delete here is a soft delete, so the button says so and the real
destructive action moves behind the split menu. */}
{/* A delete in a versioned bucket is a soft delete/archive, unless specified explicitly */}
{canUpdateFiles && isVersionedBucket && (
<div className="flex">
<Button
@@ -354,8 +348,6 @@ export const PreviewPane = () => {
const { can: canUpdateFiles } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*')
const isStorageVersioningEnabled = useIsStorageVersioningEnabled()
// The bucket page owns `?edit=true` and mounts the modal on it, so routing
// through the URL avoids threading a callback down the explorer tree.
const [, setShowEditBucketModal] = useQueryState(
'edit',
parseAsBoolean.withDefault(false).withOptions({ history: 'push', clearOnDefault: true })
@@ -9,7 +9,6 @@ interface PreviewSectionProps {
children: ReactNode
}
/** A collapsible section in the file preview panel. */
export const PreviewSection = ({
title,
count,
@@ -15,10 +15,6 @@ interface VersionCompareWidgetProps {
onDismiss: () => void
}
/**
* Takes over the top of the preview panel when a noncurrent version is selected:
* comparison and restore confirmation in one, so there is no modal.
*/
export const VersionCompareWidget = ({
mimeType,
selectedVersion,
@@ -34,10 +34,6 @@ import { formatBytes } from '@/lib/helpers'
/** Version IDs are long opaque strings; show enough to tell two rows apart. */
export const shortVersion = (versionId: string) => `${versionId.slice(0, 6)}…${versionId.slice(-2)}`
/**
* A row's removal outlook. `retained` renders nothing — saying "Retained" on
* every unflagged row repeats what the absence of a warning already says.
*/
const VersionFateLabel = ({ fate }: { fate: VersionFate }) => {
switch (fate.type) {
case 'retained':
@@ -132,17 +128,13 @@ interface VersionHistoryProps {
projectRef?: string
bucketId?: string
objectName: string
/** The bucket's versioning state, for the suspended notice. */
versioningState: BucketVersioningState
/** The bucket's lifecycle policy, which drives the per-row expiry outlook. */
lifecyclePolicy: LifecyclePolicy
expirationMode: ExpirationMode
/** Drives the row thumbnail glyph — falls back to a generic file icon. */
mimeType?: string
previewedVersionId?: string
onPreview?: (version: ObjectVersion) => void
clearPreview: () => void
/** Opens the bucket settings, where the lifecycle policy is configured. */
onEditBucket: () => void
}
@@ -275,12 +267,7 @@ export const VersionHistory = ({
!isComparing && !isDeleteMarker && 'hover:bg-surface-200'
)}
>
{/*
* A marker has no content to preview, so it renders as plain
* content rather than a control that does nothing when pressed.
* A real button elsewhere, so Enter/Space and screen readers
* work for free.
*/}
{/* A marker has no content to preview */}
{isDeleteMarker ? (
<span className="flex min-w-0 flex-1 items-center gap-x-2.5">{rowContent}</span>
) : (
@@ -5,7 +5,6 @@ import { Button, cn, HoverCard, HoverCardContent, HoverCardTrigger } from 'ui'
import { BroomSparklesIcon } from '../BroomSparklesIcon'
import type { ExpirationMode } from '../StorageVersioning.constants'
/** Shared chip styling so the tokens and the operator badge read as one family. */
const POLICY_CHIP_CLASSNAME = 'rounded-sm border px-1.5 py-0.5 font-mono text-[10.5px]'
const PolicyChip = ({ children }: { children: ReactNode }) => (
@@ -32,10 +31,7 @@ interface PolicyRuleProps {
mode: ExpirationMode
}
/** The policy spelled out in plain language, for the hover card. */
const PolicyFullRule = ({ cap, expiryDays, mode }: PolicyRuleProps) => {
// A cap always arrives with an age, so there are only three shapes to describe:
// age alone, or age combined with the cap under either operator.
const hasCap = cap !== null && cap > 0
if (!hasCap) {
@@ -60,15 +56,9 @@ const PolicyFullRule = ({ cap, expiryDays, mode }: PolicyRuleProps) => {
}
interface VersionHistoryPolicyRowProps extends PolicyRuleProps {
/** Opens the bucket settings, where the policy is configured. */
onEditBucket: () => void
}
/**
* The bucket's lifecycle policy as one inline row. A hover card rather than a
* tooltip because the content holds a button — tooltip content is not reachable
* by pointer or keyboard.
*/
export const VersionHistoryPolicyRow = ({
cap,
expiryDays,
@@ -17,16 +17,10 @@ const MimeTypeIcon = ({ mimeType, size }: { mimeType?: string; size: number }) =
interface VersionThumbnailProps {
mimeType?: string
isCurrent: boolean
/** An empty placeholder standing in for a soft delete in the object's history. */
isDeleteMarker?: boolean
size?: number
}
/**
* Type glyph for a version row. Noncurrent versions have no thumbnail of their
* own so they share one; the current version gets a restore glyph, and a delete
* marker a dashed outline so it reads as "nothing here".
*/
export const VersionThumbnail = ({
mimeType,
isCurrent,