Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Support downloading storage objects in project paused state (#29339)

Joshen Lim9e0e4f652b77
diff --git a/apps/studio/components/interfaces/Organization/NewProject/FreeProjectLimitWarning.tsx b/apps/studio/components/interfaces/Organization/NewProject/FreeProjectLimitWarning.tsx
index 72dbdb99a4e..b1ed5fb61f2 100644
--- a/apps/studio/components/interfaces/Organization/NewProject/FreeProjectLimitWarning.tsx
+++ b/apps/studio/components/interfaces/Organization/NewProject/FreeProjectLimitWarning.tsx
@@ -1,8 +1,8 @@
import Link from 'next/link'
-import { Button } from 'ui'
-import { Admonition } from 'ui-patterns/admonition'
import type { MemberWithFreeProjectLimit } from 'data/organizations/free-project-limit-check-query'
+import { Button } from 'ui'
+import { Admonition } from 'ui-patterns/admonition'
interface FreeProjectLimitWarningProps {
membersExceededLimit: MemberWithFreeProjectLimit[]
@@ -14,70 +14,36 @@ const FreeProjectLimitWarning = ({
orgSlug,
}: FreeProjectLimitWarningProps) => {
return (
- <>
- <Admonition
- type={'default'}
- title={'The organization has members who have exceeded their free project limits'}
- description={
- <div className="space-y-3">
- <p className="text-sm leading-normal">
- The following members have reached their maximum limits for the number of active free
- plan projects within organizations where they are an administrator or owner:
- </p>
- <ul className="pl-5 list-disc">
- {membersExceededLimit.map((member, idx: number) => (
- <li key={`member-${idx}`}>
- {member.username || member.primary_email} (Limit: {member.free_project_limit} free
- projects)
- </li>
- ))}
- </ul>
- <p className="text-sm leading-normal">
- These members will need to either delete, pause, or upgrade one or more of these
- projects before you're able to create a free project within this organization.
- </p>
-
- <div>
- <Button asChild type="secondary">
- <Link href={`/org/${orgSlug}/billing?panel=subscriptionPlan`}>Upgrade plan</Link>
- </Button>
- </div>
- </div>
- }
- ></Admonition>
- {/* <InformationBox
- icon={<AlertCircle className="text-foreground" size="large" strokeWidth={1.5} />}
- defaultVisibility={true}
- hideCollapse
- title="The organization has members who have exceeded their free project limits"
- description={
- <div className="space-y-3">
- <p className="text-sm leading-normal">
- The following members have reached their maximum limits for the number of active free
- plan projects within organizations where they are an administrator or owner:
- </p>
- <ul className="pl-5 list-disc">
- {membersExceededLimit.map((member, idx: number) => (
- <li key={`member-${idx}`}>
- {member.username || member.primary_email} (Limit: {member.free_project_limit} free
- projects)
- </li>
- ))}
- </ul>
- <p className="text-sm leading-normal">
- These members will need to either delete, pause, or upgrade one or more of these
- projects before you're able to create a free project within this organization.
- </p>
+ <Admonition
+ type={'default'}
+ title={'The organization has members who have exceeded their free project limits'}
+ description={
+ <div className="space-y-3">
+ <p className="text-sm leading-normal">
+ The following members have reached their maximum limits for the number of active free
+ plan projects within organizations where they are an administrator or owner:
+ </p>
+ <ul className="pl-5 list-disc">
+ {membersExceededLimit.map((member, idx: number) => (
+ <li key={`member-${idx}`}>
+ {member.username || member.primary_email} (Limit: {member.free_project_limit} free
+ projects)
+ </li>
+ ))}
+ </ul>
+ <p className="text-sm leading-normal">
+ These members will need to either delete, pause, or upgrade one or more of these
+ projects before you're able to create a free project within this organization.
+ </p>
- <div>
- <Button asChild type="primary">
- <Link href={`/org/${orgSlug}/billing?panel=subscriptionPlan`}>Upgrade plan</Link>
- </Button>
- </div>
+ <div>
+ <Button asChild type="secondary">
+ <Link href={`/org/${orgSlug}/billing?panel=subscriptionPlan`}>Upgrade plan</Link>
+ </Button>
</div>
- }
- /> */}
- </>
+ </div>
+ }
+ />
)
}
diff --git a/apps/studio/components/layouts/ProjectLayout/PausedState/PauseDisabledState.tsx b/apps/studio/components/layouts/ProjectLayout/PausedState/PauseDisabledState.tsx
new file mode 100644
index 00000000000..9d989bfa371
--- /dev/null
+++ b/apps/studio/components/layouts/ProjectLayout/PausedState/PauseDisabledState.tsx
@@ -0,0 +1,186 @@
+import { ChevronDown, Download } from 'lucide-react'
+import { useState } from 'react'
+import { toast } from 'sonner'
+
+import { useParams } from 'common'
+import { DropdownMenuItemTooltip } from 'components/ui/DropdownMenuItemTooltip'
+import { useBackupDownloadMutation } from 'data/database/backup-download-mutation'
+import { useProjectPauseStatusQuery } from 'data/projects/project-pause-status-query'
+import { useStorageArchiveCreateMutation } from 'data/storage/storage-archive-create-mutation'
+import { useStorageArchiveQuery } from 'data/storage/storage-archive-query'
+import { useFlag } from 'hooks/ui/useFlag'
+import { Database, Storage } from 'icons'
+import { PROJECT_STATUS } from 'lib/constants'
+import {
+ Alert_Shadcn_,
+ AlertDescription_Shadcn_,
+ AlertTitle_Shadcn_,
+ Button,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ WarningIcon,
+} from 'ui'
+import { useProjectContext } from '../ProjectContext'
+
+export const PauseDisabledState = () => {
+ const { ref } = useParams()
+ const { project } = useProjectContext()
+ const [toastId, setToastId] = useState<string | number>()
+ const [refetchInterval, setRefetchInterval] = useState<number | false>(false)
+
+ const enforceNinetyDayUnpauseExpiry = useFlag('enforceNinetyDayUnpauseExpiry')
+ const allowStorageObjectsDownload = useFlag('enableNinetyDayStorageDownload')
+
+ const { data: pauseStatus } = useProjectPauseStatusQuery(
+ { ref },
+ {
+ enabled: project?.status === PROJECT_STATUS.INACTIVE && enforceNinetyDayUnpauseExpiry,
+ }
+ )
+ const latestBackup = pauseStatus?.latest_downloadable_backup_id
+
+ const { data: storageArchive } = useStorageArchiveQuery(
+ { projectRef: ref },
+ {
+ refetchInterval,
+ refetchOnWindowFocus: false,
+ onSuccess: (data) => {
+ if (data.fileUrl && refetchInterval !== false) {
+ toast.success('Downloading storage objects', { id: toastId })
+ setToastId(undefined)
+ setRefetchInterval(false)
+ downloadStorageArchive(data.fileUrl)
+ }
+ },
+ }
+ )
+ const storageArchiveUrl = storageArchive?.fileUrl
+
+ const { mutate: downloadBackup } = useBackupDownloadMutation({
+ onSuccess: (res) => {
+ const { fileUrl } = res
+
+ // Trigger browser download by create,trigger and remove tempLink
+ const tempLink = document.createElement('a')
+ tempLink.href = fileUrl
+ document.body.appendChild(tempLink)
+ tempLink.click()
+ document.body.removeChild(tempLink)
+ },
+ })
+
+ const { mutate: createStorageArchive } = useStorageArchiveCreateMutation({
+ onSuccess: () => {
+ const toastId = toast.loading(
+ 'Retrieving storage archive. This may take a few minutes depending on the size of your storage objects.'
+ )
+ setToastId(toastId)
+ setRefetchInterval(5000)
+ },
+ })
+
+ const onSelectDownloadBackup = () => {
+ if (ref === undefined) return console.error('Project ref is required')
+ if (!latestBackup) return toast.error('No backups available for download')
+
+ const toastId = toast.loading('Fetching database backup')
+
+ downloadBackup(
+ {
+ ref,
+ backup: {
+ id: latestBackup,
+ // [Joshen] Just FYI these params aren't required for the download backup request
+ // API types need to be updated
+ project_id: -1,
+ inserted_at: '',
+ isPhysicalBackup: false,
+ status: {},
+ },
+ },
+ {
+ onSuccess: () => {
+ toast.success('Downloading database backup', { id: toastId })
+ },
+ }
+ )
+ }
+
+ const downloadStorageArchive = (url: string) => {
+ const tempLink = document.createElement('a')
+ tempLink.href = url
+ document.body.appendChild(tempLink)
+ tempLink.click()
+ document.body.removeChild(tempLink)
+ }
+
+ const onSelectDownloadStorageArchive = () => {
+ if (!storageArchiveUrl) {
+ createStorageArchive({ projectRef: ref })
+ } else {
+ toast.success('Downloading storage objects')
+ downloadStorageArchive(storageArchiveUrl)
+ }
+ }
+
+ return (
+ <Alert_Shadcn_ variant="warning">
+ <WarningIcon />
+ <AlertTitle_Shadcn_>Project cannot be restored through the dashboard</AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ This project has been paused for over{' '}
+ <span className="text-foreground">
+ {pauseStatus?.max_days_till_restore_disabled ?? 90} days
+ </span>{' '}
+ and cannot be restored through the dashboard. However, your data remains intact and can be
+ downloaded as a backup.
+ </AlertDescription_Shadcn_>
+ <AlertDescription_Shadcn_ className="flex items-center gap-x-2 mt-3">
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button type="default" icon={<Download />} iconRight={<ChevronDown />}>
+ Download backup
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent className="w-56" align="start">
+ <DropdownMenuItemTooltip
+ className="gap-x-2"
+ disabled={!latestBackup}
+ onClick={() => onSelectDownloadBackup()}
+ tooltip={{
+ content: {
+ side: 'right',
+ text: 'No backups available, please reach out via support for assistance',
+ },
+ }}
+ >
+ <Database size={16} />
+ Download database backup
+ </DropdownMenuItemTooltip>
+ <DropdownMenuItemTooltip
+ className="gap-x-2"
+ disabled={!allowStorageObjectsDownload}
+ onClick={() => onSelectDownloadStorageArchive()}
+ tooltip={{
+ content: {
+ side: 'right',
+ text: 'This feature is not available yet, please reach out to support for assistance',
+ },
+ }}
+ >
+ <Storage size={16} />
+ Download storage objects
+ </DropdownMenuItemTooltip>
+ {/* [Joshen] Once storage object download is supported, can just use the below component */}
+ {/* <DropdownMenuItem className="gap-x-2" onClick={() => onSelectDownloadStorageArchive()}>
+ <Storage size={16} />
+ Download storage objects
+ </DropdownMenuItem> */}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
+ )
+}
diff --git a/apps/studio/components/layouts/ProjectLayout/ProjectPausedState.tsx b/apps/studio/components/layouts/ProjectLayout/PausedState/ProjectPausedState.tsx
similarity index 73%
rename from apps/studio/components/layouts/ProjectLayout/ProjectPausedState.tsx
rename to apps/studio/components/layouts/ProjectLayout/PausedState/ProjectPausedState.tsx
index a0f59a33192..0ad02e30d4d 100644
--- a/apps/studio/components/layouts/ProjectLayout/ProjectPausedState.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/PausedState/ProjectPausedState.tsx
@@ -1,7 +1,7 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useQueryClient } from '@tanstack/react-query'
import dayjs from 'dayjs'
-import { Download, PauseCircle } from 'lucide-react'
+import { PauseCircle } from 'lucide-react'
import Link from 'next/link'
import { useState } from 'react'
import { toast } from 'sonner'
@@ -9,7 +9,6 @@ import { toast } from 'sonner'
import { useParams } from 'common'
import AlertError from 'components/ui/AlertError'
import { ButtonTooltip } from 'components/ui/ButtonTooltip'
-import { useBackupDownloadMutation } from 'data/database/backup-download-mutation'
import { useFreeProjectLimitCheckQuery } from 'data/organizations/free-project-limit-check-query'
import { useProjectPauseStatusQuery } from 'data/projects/project-pause-status-query'
import { useProjectRestoreMutation } from 'data/projects/project-restore-mutation'
@@ -19,27 +18,18 @@ import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
import { useFlag } from 'hooks/ui/useFlag'
import { PROJECT_STATUS } from 'lib/constants'
-import {
- AlertDescription_Shadcn_,
- AlertTitle_Shadcn_,
- Alert_Shadcn_,
- Button,
- Modal,
- TooltipContent_Shadcn_,
- TooltipTrigger_Shadcn_,
- Tooltip_Shadcn_,
- WarningIcon,
-} from 'ui'
+import { AlertDescription_Shadcn_, AlertTitle_Shadcn_, Alert_Shadcn_, Button, Modal } from 'ui'
import { GenericSkeletonLoader } from 'ui-patterns'
import ConfirmModal from 'ui-patterns/Dialogs/ConfirmDialog'
-import { useProjectContext } from './ProjectContext'
-import { RestorePaidPlanProjectNotice } from './RestorePaidPlanProjectNotice'
+import { useProjectContext } from '../ProjectContext'
+import { RestorePaidPlanProjectNotice } from '../RestorePaidPlanProjectNotice'
+import { PauseDisabledState } from './PauseDisabledState'
export interface ProjectPausedStateProps {
product?: string
}
-const ProjectPausedState = ({ product }: ProjectPausedStateProps) => {
+export const ProjectPausedState = ({ product }: ProjectPausedStateProps) => {
const { ref } = useParams()
const queryClient = useQueryClient()
const { project } = useProjectContext()
@@ -68,7 +58,6 @@ const ProjectPausedState = ({ product }: ProjectPausedStateProps) => {
const isFreePlan = subscription?.plan?.id === 'free'
const isRestoreDisabled = enforceNinetyDayUnpauseExpiry && isSuccess && !pauseStatus.can_restore
- const latestBackup = pauseStatus?.latest_downloadable_backup_id
const { data: membersExceededLimit } = useFreeProjectLimitCheckQuery(
{ slug: orgSlug },
@@ -86,19 +75,6 @@ const ProjectPausedState = ({ product }: ProjectPausedStateProps) => {
},
})
- const { mutate: downloadBackup, isLoading: isDownloading } = useBackupDownloadMutation({
- onSuccess: (res) => {
- const { fileUrl } = res
-
- // Trigger browser download by create,trigger and remove tempLink
- const tempLink = document.createElement('a')
- tempLink.href = fileUrl
- document.body.appendChild(tempLink)
- tempLink.click()
- document.body.removeChild(tempLink)
- },
- })
-
const canResumeProject = useCheckPermissions(
PermissionAction.INFRA_EXECUTE,
'queue_jobs.projects.initialize_or_resume'
@@ -118,24 +94,6 @@ const ProjectPausedState = ({ product }: ProjectPausedStateProps) => {
restoreProject({ ref: project.ref })
}
- const onSelectDownloadBackup = () => {
- if (ref === undefined) return console.error('Project ref is required')
- if (!latestBackup) return toast.error('No backups available for download')
-
- downloadBackup({
- ref,
- backup: {
- id: latestBackup,
- // [Joshen] Just FYI these params aren't required for the download backup request
- // API types need to be updated
- project_id: -1,
- inserted_at: '',
- isPhysicalBackup: false,
- status: {},
- },
- })
- }
-
return (
<>
<div className="space-y-4">
@@ -177,42 +135,7 @@ const ProjectPausedState = ({ product }: ProjectPausedStateProps) => {
{isSuccess && (
<>
{isRestoreDisabled ? (
- <Alert_Shadcn_ variant="warning">
- <WarningIcon />
- <AlertTitle_Shadcn_>
- Project cannot be restored through the dashboard
- </AlertTitle_Shadcn_>
- <AlertDescription_Shadcn_>
- This project has been paused for over{' '}
- <span className="text-foreground">
- {pauseStatus?.max_days_till_restore_disabled ?? 90} days
- </span>{' '}
- and cannot be restored through the dashboard. However, your data
- remains intact and can be downloaded as a backup.
- </AlertDescription_Shadcn_>
- <AlertDescription_Shadcn_ className="flex items-center gap-x-2 mt-3">
- <Tooltip_Shadcn_>
- <TooltipTrigger_Shadcn_ asChild>
- <Button
- type="default"
- icon={<Download />}
- loading={isDownloading}
- disabled={!latestBackup}
- className="pointer-events-auto"
- onClick={() => onSelectDownloadBackup()}
- >
- Download backup
- </Button>
- </TooltipTrigger_Shadcn_>
- {!latestBackup && (
- <TooltipContent_Shadcn_ side="bottom">
- No backups available, please reach out via support for
- assistance
- </TooltipContent_Shadcn_>
- )}
- </Tooltip_Shadcn_>
- </AlertDescription_Shadcn_>
- </Alert_Shadcn_>
+ <PauseDisabledState />
) : isFreePlan ? (
<>
<p className="text-sm text-foreground-light text-center">
@@ -337,5 +260,3 @@ const ProjectPausedState = ({ product }: ProjectPausedStateProps) => {
</>
)
}
-
-export default ProjectPausedState
diff --git a/apps/studio/components/layouts/ProjectLayout/ProjectLayout.tsx b/apps/studio/components/layouts/ProjectLayout/ProjectLayout.tsx
index 525ef25f29b..a908a87eade 100644
--- a/apps/studio/components/layouts/ProjectLayout/ProjectLayout.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/ProjectLayout.tsx
@@ -25,7 +25,7 @@ import PauseFailedState from './PauseFailedState'
import PausingState from './PausingState'
import ProductMenuBar from './ProductMenuBar'
import { ProjectContextProvider } from './ProjectContext'
-import ProjectPausedState from './ProjectPausedState'
+import { ProjectPausedState } from './PausedState/ProjectPausedState'
import RestartingState from './RestartingState'
import RestoreFailedState from './RestoreFailedState'
import RestoringState from './RestoringState'
diff --git a/apps/studio/data/config/project-api-query.ts b/apps/studio/data/config/project-api-query.ts
index 51ab33af0a8..4aabfe86796 100644
--- a/apps/studio/data/config/project-api-query.ts
+++ b/apps/studio/data/config/project-api-query.ts
@@ -4,6 +4,8 @@ import { components } from 'api-types'
import { get, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { configKeys } from './keys'
+import { useSelectedProject } from 'hooks/misc/useSelectedProject'
+import { PROJECT_STATUS } from 'lib/constants'
export type ProjectApiVariables = {
projectRef?: string
@@ -17,6 +19,7 @@ export type ProjectApiResponse = {
export async function getProjectApi({ projectRef }: ProjectApiVariables, signal?: AbortSignal) {
if (!projectRef) throw new Error('projectRef is required')
+ console.log('SSS')
const { data, error } = await get('/platform/props/project/{ref}/api', {
params: { path: { ref: projectRef } },
@@ -33,12 +36,16 @@ export type ProjectApiError = ResponseError
export const useProjectApiQuery = <TData = ProjectApiData>(
{ projectRef }: ProjectApiVariables,
{ enabled = true, ...options }: UseQueryOptions<ProjectApiData, ProjectApiError, TData> = {}
-) =>
- useQuery<ProjectApiData, ProjectApiError, TData>(
+) => {
+ const project = useSelectedProject()
+ return useQuery<ProjectApiData, ProjectApiError, TData>(
configKeys.api(projectRef),
({ signal }) => getProjectApi({ projectRef }, signal),
{
- enabled: enabled && typeof projectRef !== 'undefined',
+ enabled:
+ enabled &&
+ typeof projectRef !== 'undefined' &&
+ project?.status === PROJECT_STATUS.ACTIVE_HEALTHY,
refetchInterval(data, query) {
if (!data) {
return false
@@ -54,3 +61,4 @@ export const useProjectApiQuery = <TData = ProjectApiData>(
...options,
}
)
+}
diff --git a/apps/studio/data/storage/keys.ts b/apps/studio/data/storage/keys.ts
index 112eff0e10b..5fa399773f4 100644
--- a/apps/studio/data/storage/keys.ts
+++ b/apps/studio/data/storage/keys.ts
@@ -1,3 +1,4 @@
export const storageKeys = {
buckets: (projectRef: string | undefined) => ['projects', projectRef, 'buckets'] as const,
+ archive: (projectRef: string | undefined) => ['projects', projectRef, 'archive'] as const,
}
diff --git a/apps/studio/data/storage/s3-access-key-create-mutation.ts b/apps/studio/data/storage/s3-access-key-create-mutation.ts
index 44372aae383..b1e3a9d37ee 100644
--- a/apps/studio/data/storage/s3-access-key-create-mutation.ts
+++ b/apps/studio/data/storage/s3-access-key-create-mutation.ts
@@ -25,19 +25,19 @@ const createS3AccessKeyCredential = async ({
return data
}
-type S3AccessKeyDeleteData = Awaited<ReturnType<typeof createS3AccessKeyCredential>>
+type S3AccessKeyCreateData = Awaited<ReturnType<typeof createS3AccessKeyCredential>>
export function useS3AccessKeyCreateMutation({
onSuccess,
onError,
...options
}: Omit<
- UseMutationOptions<S3AccessKeyDeleteData, ResponseError, CreateS3AccessKeyCredentialVariables>,
+ UseMutationOptions<S3AccessKeyCreateData, ResponseError, CreateS3AccessKeyCredentialVariables>,
'mutationFn'
> = {}) {
const queryClient = useQueryClient()
- return useMutation<S3AccessKeyDeleteData, ResponseError, CreateS3AccessKeyCredentialVariables>(
+ return useMutation<S3AccessKeyCreateData, ResponseError, CreateS3AccessKeyCredentialVariables>(
(vars) => createS3AccessKeyCredential(vars),
{
async onSuccess(data, variables, context) {
diff --git a/apps/studio/data/storage/storage-archive-create-mutation.ts b/apps/studio/data/storage/storage-archive-create-mutation.ts
new file mode 100644
index 00000000000..bf193ab0189
--- /dev/null
+++ b/apps/studio/data/storage/storage-archive-create-mutation.ts
@@ -0,0 +1,53 @@
+import { UseMutationOptions, useMutation, useQueryClient } from '@tanstack/react-query'
+import { toast } from 'sonner'
+
+import { handleError, post } from 'data/fetchers'
+import { ResponseError } from 'types'
+import { storageKeys } from './keys'
+
+type StorageArchiveCreateVariables = {
+ projectRef?: string
+}
+
+const createStorageArchive = async ({ projectRef }: StorageArchiveCreateVariables) => {
+ if (!projectRef) throw new Error('projectRef is required')
+
+ const { data, error } = await post('/platform/storage/{ref}/archive', {
+ params: { path: { ref: projectRef } },
+ })
+
+ if (error) handleError(error)
+ return data
+}
+
+type StorageArchiveCreateData = Awaited<ReturnType<typeof createStorageArchive>>
+
+export function useStorageArchiveCreateMutation({
+ onSuccess,
+ onError,
+ ...options
+}: Omit<
+ UseMutationOptions<StorageArchiveCreateData, ResponseError, StorageArchiveCreateVariables>,
+ 'mutationFn'
+> = {}) {
+ const queryClient = useQueryClient()
+
+ return useMutation<StorageArchiveCreateData, ResponseError, StorageArchiveCreateVariables>(
+ (vars) => createStorageArchive(vars),
+ {
+ async onSuccess(data, variables, context) {
+ const { projectRef } = variables
+ await queryClient.invalidateQueries(storageKeys.archive(projectRef))
+ await onSuccess?.(data, variables, context)
+ },
+ async onError(data, variables, context) {
+ if (onError === undefined) {
+ toast.error(`Failed to create storage archive: ${data.message}`)
+ } else {
+ onError(data, variables, context)
+ }
+ },
+ ...options,
+ }
+ )
+}
diff --git a/apps/studio/data/storage/storage-archive-query.ts b/apps/studio/data/storage/storage-archive-query.ts
new file mode 100644
index 00000000000..3d22152af0c
--- /dev/null
+++ b/apps/studio/data/storage/storage-archive-query.ts
@@ -0,0 +1,36 @@
+import { UseQueryOptions, useQuery } from '@tanstack/react-query'
+
+import { get, handleError } from 'data/fetchers'
+import { ResponseError } from 'types'
+import { storageKeys } from './keys'
+
+type StorageArchiveVariables = { projectRef?: string }
+
+async function fetchStorageArchive({ projectRef }: StorageArchiveVariables, signal?: AbortSignal) {
+ if (!projectRef) throw new Error('projectRef is required')
+
+ const { data, error } = await get('/platform/storage/{ref}/archive', {
+ params: { path: { ref: projectRef } },
+ signal,
+ })
+ if (error) {
+ if ((error as ResponseError)?.message?.includes('Storage archive not found')) {
+ return { fileUrl: undefined }
+ } else {
+ handleError(error)
+ }
+ }
+ return data
+}
+
+export type StorageArchiveData = Awaited<ReturnType<typeof fetchStorageArchive>>
+
+export const useStorageArchiveQuery = <TData = StorageArchiveData>(
+ { projectRef }: StorageArchiveVariables,
+ { enabled = true, ...options }: UseQueryOptions<StorageArchiveData, ResponseError, TData> = {}
+) =>
+ useQuery<StorageArchiveData, ResponseError, TData>(
+ storageKeys.archive(projectRef),
+ ({ signal }) => fetchStorageArchive({ projectRef }, signal),
+ { enabled: enabled && typeof projectRef !== 'undefined', ...options }
+ )
diff --git a/apps/studio/pages/project/[ref]/index.tsx b/apps/studio/pages/project/[ref]/index.tsx
index 19a2c24459e..a2cc5b1b70e 100644
--- a/apps/studio/pages/project/[ref]/index.tsx
+++ b/apps/studio/pages/project/[ref]/index.tsx
@@ -8,7 +8,7 @@ import ProjectUsageSection from 'components/interfaces/Home/ProjectUsageSection'
import { SecurityStatus } from 'components/interfaces/Home/SecurityStatus'
import ServiceStatus from 'components/interfaces/Home/ServiceStatus'
import { ProjectLayoutWithAuth } from 'components/layouts/ProjectLayout/ProjectLayout'
-import ProjectPausedState from 'components/layouts/ProjectLayout/ProjectPausedState'
+import { ProjectPausedState } from 'components/layouts/ProjectLayout/PausedState/ProjectPausedState'
import { ComputeBadgeWrapper } from 'components/ui/ComputeBadgeWrapper'
import ProjectUpgradeFailedBanner from 'components/ui/ProjectUpgradeFailedBanner'
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'