refactor(storage): drop the unreachable cap-only lifecycle branch

Follows the same change in the version-fate helper: a version cap always arrives
alongside an expiration age, so the policy summary only has three shapes to
describe (age alone, or age plus cap under either operator). Removes the
cap-only sentence and the "no age limit" chip, and `daysRemaining` on
`expires-on-next-upload` no longer needs an undefined guard.

Also adds the explicit `tabIndex={0}` that `supabase/require-explicit-tabindex`
wants on the four raw buttons in this feature. These were lint *errors*, not
warnings, so the ratchet never surfaced them.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Francesco SansalvadoreandClaude Sonnet 5 authored and GitHub committed 2026-10-05 15:04:14 +02:00
1 parent c738d4dd6a
commit 0f4cd1ea03
4 files changed
+16 -24

No files matched your search

@@ -23,6 +23,7 @@ export const PreviewSection = ({
<CollapsibleTrigger asChild>
<button
type="button"
tabIndex={0}
className="flex w-full items-center justify-between py-3 text-left text-sm font-medium text-foreground transition-colors hover:text-foreground-light"
>
<span className="flex items-center gap-x-2">
@@ -35,6 +35,7 @@ export const VersionCompareWidget = ({
</p>
<button
type="button"
tabIndex={0}
className="ml-auto shrink-0 text-foreground-lighter transition-colors hover:text-foreground"
onClick={onDismiss}
aria-label="Cancel comparison"
@@ -52,9 +52,7 @@ const VersionFateLabel = ({ fate }: { fate: VersionFate }) => {
return (
<div className="flex flex-col items-end">
<span className="shrink-0 text-xs text-warning-600">Expires on next upload</span>
{fate.daysRemaining !== undefined && (
<span className="shrink-0 text-xs text-warning-600">or in {fate.daysRemaining}d</span>
)}
<span className="shrink-0 text-xs text-warning-600">or in {fate.daysRemaining}d</span>
</div>
)
case 'expiring-now':
@@ -288,6 +286,7 @@ export const VersionHistory = ({
) : (
<button
type="button"
tabIndex={0}
className="flex min-w-0 flex-1 items-center gap-x-2.5 text-left"
onClick={() => (version.isCurrent ? clearPreview() : onPreview?.(version))}
>
@@ -34,34 +34,27 @@ interface PolicyRuleProps {
/** 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
const hasExpiryDays = expiryDays !== null && expiryDays > 0
if (hasCap && hasExpiryDays) {
if (mode === 'and') {
return (
<>
A noncurrent version is permanently deleted only once it is <em>both</em> older than{' '}
{expiryDays} days and beyond the {cap} newest noncurrent versions.
</>
)
}
if (!hasCap) {
return <>A noncurrent version is permanently deleted once it is older than {expiryDays} days.</>
}
if (mode === 'and') {
return (
<>
A noncurrent version is permanently deleted as soon as it is <em>either</em> older than{' '}
{expiryDays} days <em>or</em> beyond the {cap} newest noncurrent versions.
A noncurrent version is permanently deleted only once it is <em>both</em> older than{' '}
{expiryDays} days and beyond the {cap} newest noncurrent versions.
</>
)
}
if (hasExpiryDays) {
return <>A noncurrent version is permanently deleted once it is older than {expiryDays} days.</>
}
return (
<>
Only the {cap} newest noncurrent versions are retained. Older ones are deleted on the next
upload.
A noncurrent version is permanently deleted as soon as it is <em>either</em> older than{' '}
{expiryDays} days <em>or</em> beyond the {cap} newest noncurrent versions.
</>
)
}
@@ -91,6 +84,7 @@ export const VersionHistoryPolicyRow = ({
<HoverCardTrigger asChild>
<button
type="button"
tabIndex={0}
onClick={onEditBucket}
className="flex items-center gap-x-2 text-left"
aria-label="Lifecycle policy details"
@@ -106,9 +100,6 @@ export const VersionHistoryPolicyRow = ({
— no retention cap
</span>
)}
{hasCap && !hasExpiryDays && (
<span className="font-mono text-[11px] text-foreground-lighter">— no age limit</span>
)}
<Info size={13} className="text-foreground-lighter" />
</button>
</HoverCardTrigger>