Files
supabase/apps/studio/data/projects/project-pause-status-override.ts
Crispy 8c092185ae feat: paused project restore window copy and backup downloads (#48279)
Shows the restore deadline as a date on the paused-project screens, and
offers backup downloads while a paused project is still restorable
(previously only after the restore window ended).

Depends on a backend change — keep as draft until that is live.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Extended the paused-project restore window from 90 days to up to 1
year.
* Added clearer, downloadable options for database backups and storage
objects while a project is paused.
* Paused-project screens now show an “available until” date when
applicable (and updated resume guidance).
* **Documentation**
* Updated platform and troubleshooting guides to reflect the new 1-year
restore window and post-window recovery limitations.
* **Bug Fixes**
* Standardized restore-window wording across the pause confirmation and
paused-state UI.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-07-24 19:45:34 +07:00

59 lines
1.8 KiB
TypeScript

import type { components } from '@/data/api'
type PauseStatusResponse = components['schemas']['PauseStatusResponse']
export type PauseStateOverride = 'restorable' | 'restore-disabled'
const STORAGE_KEY = 'devToolbar:pauseStatusOverrides'
const IS_ENABLED =
process.env.NEXT_PUBLIC_ENVIRONMENT === 'local' ||
process.env.NEXT_PUBLIC_ENVIRONMENT === 'staging'
function readOverrides(): Record<string, PauseStateOverride> {
if (!IS_ENABLED || typeof window === 'undefined') return {}
try {
const raw = window.localStorage.getItem(STORAGE_KEY)
return raw ? (JSON.parse(raw) as Record<string, PauseStateOverride>) : {}
} catch {
return {}
}
}
function writeOverrides(overrides: Record<string, PauseStateOverride>) {
if (typeof window === 'undefined') return
if (Object.keys(overrides).length > 0) {
window.localStorage.setItem(STORAGE_KEY, JSON.stringify(overrides))
} else {
window.localStorage.removeItem(STORAGE_KEY)
}
}
export function getPauseStatusOverride(ref: string | undefined): PauseStateOverride | undefined {
if (!IS_ENABLED || !ref) return undefined
return readOverrides()[ref]
}
export function setPauseStatusOverride(ref: string, override: PauseStateOverride) {
if (!IS_ENABLED) return
writeOverrides({ ...readOverrides(), [ref]: override })
}
export function clearPauseStatusOverride(ref: string) {
if (!IS_ENABLED) return
const overrides = readOverrides()
delete overrides[ref]
writeOverrides(overrides)
}
export function buildPauseStatus(override: PauseStateOverride): PauseStatusResponse {
const isRestorable = override === 'restorable'
return {
can_restore: isRestorable,
last_paused_on: null,
latest_downloadable_backup_id: null,
max_days_till_restore_disabled: 400,
remaining_days_till_restore_disabled: isRestorable ? 350 : 0,
}
}