mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
Moves the project home, `/merge`, `/api` and all `/database/*` page bodies into their route files and deletes the pages (FE-3106). Part 6 of the stack. **Depends on:** #53214 **Changed:** - `routes/project/$ref/{index,merge,api/index}.tsx`, `routes/project/$ref/database/**` – 26 page bodies inlined; redirects use `<Navigate>`/`useNavigate` with typed params and `search`; `next/link` → `Link` - `database/pipelines/new` – same-origin header links navigate client-side via `splitInternalUrl`, external ones via `href`, matching the old shim - `PipelineCreationPage.test.tsx` – renders the route with `renderRoute` **Removed:** - 26 page files, and `DatabaseTriggersLayout`/`PipelinesLayout`, which only the deleted pages' `getLayout` used (the route shells already inline them) Addresses [FE-3106](https://linear.app/supabase/issue/FE-3106/move-page-bodies-into-route-files-and-delete-pages). ## To test - Click through Database (Tables, Functions, Triggers, Indexes, Roles, Policies, Backups, Pipelines, Publications) – same layout, titles and sidebar - `/project/<ref>/database/triggers` – redirects to `triggers/data` - `/project/<ref>/api` – redirects to the Data API docs, keeping the query - Create a pipeline and leave the wizard – unsaved-changes guard and navigation behave as before --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
165 lines
5.8 KiB
TypeScript
165 lines
5.8 KiB
TypeScript
import { createFileRoute } from '@tanstack/react-router'
|
|
import { useParams } from 'common'
|
|
import { AlertCircleIcon, DatabaseBackupIcon } from 'lucide-react'
|
|
import { Alert, AlertDescription, AlertTitle } from 'ui'
|
|
import { Admonition } from 'ui-patterns/Admonition'
|
|
import { PageContainer } from 'ui-patterns/PageContainer'
|
|
import {
|
|
PageHeader,
|
|
PageHeaderMeta,
|
|
PageHeaderNavigationTabs,
|
|
PageHeaderSummary,
|
|
PageHeaderTitle,
|
|
} from 'ui-patterns/PageHeader'
|
|
import { PageSection, PageSectionContent } from 'ui-patterns/PageSection'
|
|
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
|
|
|
|
import DatabaseBackupsNav from '@/components/interfaces/Database/Backups/DatabaseBackupsNav'
|
|
import { PITRNotice } from '@/components/interfaces/Database/Backups/PITR/PITRNotice'
|
|
import { PITRSelection } from '@/components/interfaces/Database/Backups/PITR/PITRSelection'
|
|
import { AlertError } from '@/components/ui/AlertError'
|
|
import { DocsButton } from '@/components/ui/DocsButton'
|
|
import { HighAvailabilityDisabledEmptyState } from '@/components/ui/HighAvailability/HighAvailabilityDisabledEmptyState'
|
|
import { NoPermission } from '@/components/ui/NoPermission'
|
|
import { UpgradeToPro } from '@/components/ui/UpgradeToPro'
|
|
import { useBackupsQuery } from '@/data/database/backups-query'
|
|
import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements'
|
|
import { FGA_PERMISSIONS, useAsyncCheckPermissionsV2 } from '@/hooks/misc/useCheckPermissionsV2'
|
|
import { useHighAvailability } from '@/hooks/misc/useHighAvailability'
|
|
import {
|
|
useIsOrioleDbInAws,
|
|
useOrioleDbReleaseStage,
|
|
useSelectedProjectQuery,
|
|
} from '@/hooks/misc/useSelectedProject'
|
|
import { DOCS_URL, PROJECT_STATUS } from '@/lib/constants'
|
|
|
|
export const Route = createFileRoute('/project/$ref/database/backups/pitr')({
|
|
component: DatabasePhysicalBackups,
|
|
staticData: {
|
|
databaseLayoutTitle: 'Backups',
|
|
},
|
|
})
|
|
|
|
function DatabasePhysicalBackups() {
|
|
return (
|
|
<>
|
|
<PageHeader>
|
|
<PageHeaderMeta>
|
|
<PageHeaderSummary>
|
|
<PageHeaderTitle>Database Backups</PageHeaderTitle>
|
|
</PageHeaderSummary>
|
|
</PageHeaderMeta>
|
|
<PageHeaderNavigationTabs>
|
|
<DatabaseBackupsNav active="pitr" />
|
|
</PageHeaderNavigationTabs>
|
|
</PageHeader>
|
|
<PageContainer>
|
|
<PageSection>
|
|
<PageSectionContent>
|
|
<div className="space-y-8">
|
|
<PITR />
|
|
</div>
|
|
</PageSectionContent>
|
|
</PageSection>
|
|
</PageContainer>
|
|
</>
|
|
)
|
|
}
|
|
|
|
const PITR = () => {
|
|
const { ref: projectRef } = useParams()
|
|
const { data: project, isPending: isProjectPending } = useSelectedProjectQuery()
|
|
const { isHighAvailability } = useHighAvailability()
|
|
const { hasAccess: hasAccessToPitr, isLoading: isLoadingEntitlements } =
|
|
useCheckEntitlements('pitr.available_variants')
|
|
const isOrioleDbInAws = useIsOrioleDbInAws()
|
|
const orioleDbReleaseStage = useOrioleDbReleaseStage()
|
|
const {
|
|
data: backups,
|
|
error,
|
|
isPending: isLoadingBackups,
|
|
isError,
|
|
isSuccess,
|
|
} = useBackupsQuery({ projectRef })
|
|
|
|
const isLoading = isLoadingBackups || isLoadingEntitlements || isProjectPending
|
|
const isEnabled = backups?.pitr_enabled
|
|
const isActiveHealthy = project?.status === PROJECT_STATUS.ACTIVE_HEALTHY
|
|
|
|
const { can: canReadPhysicalBackups, isSuccess: isPermissionsLoaded } =
|
|
useAsyncCheckPermissionsV2(FGA_PERMISSIONS.PROJECT.BACKUPS_READ)
|
|
|
|
if (isPermissionsLoaded && !canReadPhysicalBackups) {
|
|
return <NoPermission resourceText="view PITR backups" />
|
|
}
|
|
|
|
if (isOrioleDbInAws) {
|
|
return (
|
|
<Admonition
|
|
type="default"
|
|
title="Point-in-Time Recovery is not available for OrioleDB"
|
|
description={`OrioleDB is currently in public ${orioleDbReleaseStage} and Point-in-Time Recovery is unavailable on OrioleDB projects`}
|
|
>
|
|
<DocsButton abbrev={false} className="mt-2" href={DOCS_URL} />
|
|
</Admonition>
|
|
)
|
|
}
|
|
|
|
if (isLoading) {
|
|
return <GenericSkeletonLoader />
|
|
}
|
|
|
|
if (isHighAvailability) {
|
|
return (
|
|
<HighAvailabilityDisabledEmptyState
|
|
icon={DatabaseBackupIcon}
|
|
title="Point-in-Time Recovery unavailable on High Availability projects"
|
|
description="We're working to bring point-in-time recovery to High Availability projects. Contact support if this is blocking your work."
|
|
className="max-w-none mx-0"
|
|
/>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<>
|
|
{isError && <AlertError error={error} subject="Failed to retrieve PITR backups" />}
|
|
{isSuccess && (
|
|
<>
|
|
{!isEnabled ? (
|
|
<UpgradeToPro
|
|
addon={hasAccessToPitr ? 'pitr' : undefined}
|
|
source="pitr"
|
|
featureProposition="enable Point-in-Time Recovery"
|
|
primaryText={
|
|
hasAccessToPitr
|
|
? 'Point in Time Recovery is available as an add-on'
|
|
: 'Point in Time Recovery is a Pro Plan add-on'
|
|
}
|
|
secondaryText={
|
|
!hasAccessToPitr
|
|
? 'Roll back your database to a specific second. Starts at $100/month. Pro Plan already includes daily backups at no extra cost.'
|
|
: 'Enable the add-on to add point-in-time recovery to your project.'
|
|
}
|
|
/>
|
|
) : !isActiveHealthy ? (
|
|
<Alert>
|
|
<AlertCircleIcon />
|
|
<AlertTitle>
|
|
Point in Time Recovery is not available while project is offline
|
|
</AlertTitle>
|
|
<AlertDescription>
|
|
Your project needs to be online to restore your database with Point in Time Recovery
|
|
</AlertDescription>
|
|
</Alert>
|
|
) : (
|
|
<>
|
|
<PITRNotice />
|
|
<PITRSelection />
|
|
</>
|
|
)}
|
|
</>
|
|
)}
|
|
</>
|
|
)
|
|
}
|