Files
supabase/apps/studio/components/layouts/ProjectLayout/PausedState/ProjectPausedState.tsx
Alaister YoungandAlaister Young 6dd7062496 [FE-5108] (part 2) refactor(studio): migrate layouts & shell off next/link (#54305)
Part 2 of a 6-PR stack migrating all `next/link` imports in
`apps/studio` onto TanStack Router's `Link` (or plain `<a>` for known
external URLs) and removing `compat/next/link.tsx`.

| Part | PR | Scope |
| --- | --- | --- |
| 1 | #54304 | `data/prefetchers/PrefetchableLink.tsx` and
`components/ui/**` |
| **2** | **#54305 ← this PR** | **`components/layouts/**` and top-level
shell components** |
| 3 | #54306 | Database, TableGridEditor, Storage, SQLEditor,
BranchManagement, Branching, Functions, Realtime |
| 4 | #54307 | Integrations, Settings, Observability, LogDrains, Issues,
Linter, Reports, QueryPerformance, QuerySources, ConfigDrift,
DiskManagement, Compute |
| 5 | #54308 | Remaining `components/interfaces/**` (Org, Billing, Auth,
Support, Home, SignIn, ConnectSheet, etc.) |
| 6 | #54309 | Remove `compat/next/link.tsx` shim, Vite alias, and
update basePath tests/docs |

Migrates all `apps/studio/components/layouts/**` files and top-level
navigation shell components off `next/link`.

**Changed:**

- Replaced `next/link` across `components/layouts/**` (`AccountLayout`,
`AppLayout`, `AuthLayout`, `BranchLayout`, `DatabaseLayout`,
`EdgeFunctionsLayout`, `ExplorerLayout`, `IssuesLayout`, `LogsLayout`,
`Navigation`, `ObservabilityLayout`, `ProjectLayout`,
`ProjectNeedsSecuring`, `SQLEditorLayout`, `SignInLayout`,
`TableEditorLayout`, `Tabs`) and top-level shell components
(`Sidebar.tsx`, `UserDropdown.tsx`, `LocalDropdown.tsx`,
`HomePageActions.tsx`)
- Removed `vi.mock('next/link', ...)` from `LocalDropdown.test.tsx` and
`ProjectNeedsSecuring.test.tsx`
- Added accessible labels where external icon/logo links switched from
`<Link>` to plain `<a>` (`AdminStudioButton.tsx`,
`ForgotPasswordLayout.tsx`)

Addresses
[FE-5108](https://linear.app/supabase/issue/FE-5108/replace-the-nextlink-shim-with-tanstack-link)

## To test

- [ ] Navigate across top header, left sidebar, user/local dropdown, and
project/org/branch switchers
- [ ] Verify mobile navigation menu items and recent-tab links navigate
with expected query params
- [ ] Verify sign-in and forgot-password layout links work cleanly

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-12-01 16:36:09 +08:00

165 lines
6.5 KiB
TypeScript

import { Link } from '@tanstack/react-router'
import { useParams } from 'common'
import dayjs from 'dayjs'
import { PauseCircleIcon } from 'lucide-react'
import { Button, Card, CardContent, CardFooter } from 'ui'
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
import { TimestampInfo } from 'ui-patterns/TimestampInfo'
import { DownloadBackupsSection } from './DownloadBackupsSection'
import { PauseDisabledState } from './PauseDisabledState'
import { ResumeProjectButton } from '@/components/interfaces/Project/ResumeProjectButton'
import { AlertError } from '@/components/ui/AlertError'
import { UpgradePlanButton } from '@/components/ui/UpgradePlanButton'
import { useProjectPauseStatusQuery } from '@/data/projects/project-pause-status-query'
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { usePHFlag } from '@/hooks/ui/useFlag'
import { PROJECT_STATUS } from '@/lib/constants'
export interface ProjectPausedStateProps {
product?: string
}
export const ProjectPausedState = ({ product }: ProjectPausedStateProps) => {
const { ref } = useParams()
const { data: project } = useSelectedProjectQuery()
const { data: selectedOrganization } = useSelectedOrganizationQuery()
const enableProBenefitWording = usePHFlag('proBenefitWording')
const {
data: pauseStatus,
error: pauseStatusError,
isError,
isSuccess: isPauseStatusSuccess,
isPending: isLoading,
} = useProjectPauseStatusQuery({ ref }, { enabled: project?.status === PROJECT_STATUS.INACTIVE })
// null when there is no expiry (e.g. paid plans can always restore)
const restoreExpiresAt =
pauseStatus?.remaining_days_till_restore_disabled != null
? dayjs().utc().add(pauseStatus.remaining_days_till_restore_disabled, 'day').toISOString()
: null
const isFreePlan = selectedOrganization?.plan?.id === 'free'
const isRestoreDisabled = isPauseStatusSuccess && !pauseStatus.can_restore
return (
<Card className="w-full max-w-160 mx-auto">
<CardContent>
<PauseCircleIcon
size={48}
strokeWidth={1}
className="text-foreground-lighter shrink-0 mb-4"
/>
<div className="flex-1">
<div>
<h2 className="mb-4">Project "{project?.name}" is paused</h2>
<div className="text-foreground-light max-w-4xl">
{isLoading && <GenericSkeletonLoader className="mt-3" />}
{isPauseStatusSuccess && !isRestoreDisabled ? (
isFreePlan ? (
<ul className="text-sm list-disc pl-4 space-y-2">
<li>All data, including backups and storage objects, remains safe.</li>
{restoreExpiresAt ? (
<>
<li>
You can resume this project from the dashboard until{' '}
<TimestampInfo
displayAs="local"
utcTimestamp={restoreExpiresAt}
className="text-sm text-foreground"
labelFormat="DD MMM YYYY"
/>
.
</li>
<li>
After that, this project will not be resumable, but data will still be
available for download.
</li>
</>
) : (
<li>You can resume this project from the dashboard.</li>
)}
<li>
{enableProBenefitWording === 'variant-a'
? 'Upgrade to Pro to prevent pauses and unlock features like branching, compute upgrades, and daily backups.'
: 'To prevent future pauses, consider upgrading to Pro.'}
</li>
</ul>
) : (
<>
<p className="text-sm">
Your project data is safe
{restoreExpiresAt ? (
<>
{' '}
and available until{' '}
<TimestampInfo
displayAs="local"
utcTimestamp={restoreExpiresAt}
className="text-sm text-foreground"
labelFormat="DD MMM YYYY"
/>
</>
) : null}
<span>, but inaccessible while paused.</span>
</p>
<p className="text-sm mt-2">
Once resumed, usage will be billed by compute size and hours active.
</p>
</>
)
) : !isLoading ? (
<p className="text-sm">
All of your project's data is still intact, but your project is inaccessible while
paused.{' '}
{product !== undefined ? (
<>
Resume this project to access the{' '}
<span className="text-primary">{product}</span> page.
</>
) : !isRestoreDisabled ? (
<span>Resume this project and get back to building!</span>
) : null}
</p>
) : null}
</div>
</div>
</div>
</CardContent>
{isError && (
<AlertError
className="rounded-none border-0"
error={pauseStatusError}
subject="Failed to retrieve pause status"
/>
)}
{isPauseStatusSuccess && !isRestoreDisabled && (
<>
<CardFooter className="flex flex-wrap justify-end items-center gap-2">
<ResumeProjectButton size="tiny" variant="default" source="project_layout_paused" />
{isFreePlan ? (
<UpgradePlanButton source="projectPausedStateRestore" />
) : (
<Button asChild>
<Link to="/project/$ref/settings/general" params={{ ref: ref ?? '_' }}>
View project settings
</Link>
</Button>
)}
</CardFooter>
<DownloadBackupsSection />
</>
)}
{isPauseStatusSuccess && isRestoreDisabled && <PauseDisabledState />}
</Card>
)
}