Files
supabase/apps/studio/routes/project/$ref/settings/api-keys/index.tsx
Alaister YoungandAlaister Young 00bd19f06c [FE-3106] (part 10) – refactor(studio): move settings, advisors and issues pages (#53219)
Moves the `/settings/*`, `/advisors/*` and `/issues/*` page bodies into
their route files and deletes the pages (FE-3106). Part 10 of the stack.

**Depends on:** #53218

**Changed:**
- `routes/project/$ref/settings/**` – 16 page bodies inlined.
`settings/api` redirects with `<Navigate>`; billing usage, dashboard and
replica pages use typed `navigate`/`Link`
- `routes/project/$ref/{advisors,issues}/**` – 7 page bodies inlined
- Settings tests moved from `tests/pages/**` to `tests/routes/**` and
rendered with `renderRoute`

-
`routes/project/$ref/advisors{.tsx,/rules.tsx,/security.tsx,/performance.tsx,/health.tsx}`
– carry master's #52993 (Advisors → Issues behind `issuesInbox`:
`IssuesCategoryRedirect`, `LegacyAdvisorsLayout`, `parseLinterLevel`,
named `LinterFilters`/`LintPageTabs`), ported from the deleted pages and
checked against master's pages + route adapters;
`LegacyAdvisorsPages.platform.test.tsx` now renders the routes
(`tests/routes/project/$ref/advisors/legacy-advisors.platform.test.tsx`)

**Removed:**
- 23 page files, and `AdvisorRulesLayout` (only the deleted rules pages
used it; `routes/project/$ref/advisors/rules.tsx` already inlines it)

Addresses
[FE-3106](https://linear.app/supabase/issue/FE-3106/move-page-bodies-into-route-files-and-delete-pages).

## To test

- Project Settings (General, Compute, Infrastructure, Add-ons, API keys,
JWT, Log drains, Webhooks, Integrations) – same layout and sidebar
- `/project/<ref>/settings/api` – redirects as before
- Advisors (Security, Performance, Rules) and Issues – same layout

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-17 16:43:20 +09:00

87 lines
3.1 KiB
TypeScript

import { useQuery } from '@tanstack/react-query'
import { createFileRoute } from '@tanstack/react-router'
import { IS_PLATFORM, useParams } from 'common'
import { useMemo } from 'react'
import { Separator } from 'ui'
import { Admonition } from 'ui-patterns/Admonition'
import { ApiKeysCreateCallout } from '@/components/interfaces/APIKeys/ApiKeysIllustrations'
import { LegacyAPIKeysRetirementNotice } from '@/components/interfaces/APIKeys/LegacyAPIKeysRetirementNotice'
import { PublishableAPIKeys } from '@/components/interfaces/APIKeys/PublishableAPIKeys'
import { SecretAPIKeys } from '@/components/interfaces/APIKeys/SecretAPIKeys'
import { DisableInteraction } from '@/components/ui/DisableInteraction'
import { DocsButton } from '@/components/ui/DocsButton'
import { apiKeysQueryOptions } from '@/data/api-keys/api-keys-query'
import { useDeploymentMode } from '@/hooks/misc/useDeploymentMode'
import { DOCS_URL } from '@/lib/constants'
import { useGrant } from '@/lib/grants'
export const Route = createFileRoute('/project/$ref/settings/api-keys/')({
component: ApiKeysNewPage,
staticData: { settingsLayoutTitle: 'API Keys' },
})
function ApiKeysNewPage() {
const { ref: projectRef } = useParams()
const { isCli, isSelfHosted } = useDeploymentMode()
const apiKeysGrant = useGrant('GET /v1/projects/{ref}/api-keys', { projectRef })
const { data: apiKeysData = [], isSuccess: isSuccessAPIKeys } = useQuery(
apiKeysQueryOptions({ projectRef, grant: apiKeysGrant.grant })
)
const newApiKeys = useMemo(
() => apiKeysData.filter(({ type }) => type === 'publishable' || type === 'secret'),
[apiKeysData]
)
const hasNewApiKeys = newApiKeys.length > 0
const shouldShowCreateCallout = isSuccessAPIKeys && !hasNewApiKeys
if (!IS_PLATFORM) {
return (
<div className="flex flex-col gap-8">
{isCli && (
<Admonition
type="default"
title="Local development with the Supabase CLI"
description={
<p>
The API keys are automatically managed by the Supabase CLI and are not manually
configurable.
</p>
}
actions={<DocsButton href={`${DOCS_URL}/guides/local-development`} />}
/>
)}
{isSelfHosted && (
<Admonition
type="default"
title="Self-hosted Supabase"
description={
<p>
<code>SUPABASE_PUBLISHABLE_KEY</code> and <code>SUPABASE_SECRET_KEY</code> are set
via environment variables.
</p>
}
actions={<DocsButton href={`${DOCS_URL}/guides/self-hosting/self-hosted-auth-keys`} />}
/>
)}
<PublishableAPIKeys />
<Separator />
<SecretAPIKeys />
</div>
)
}
return (
<>
{shouldShowCreateCallout && <ApiKeysCreateCallout />}
<LegacyAPIKeysRetirementNotice />
<DisableInteraction disabled={!hasNewApiKeys} className="flex flex-col gap-8">
<PublishableAPIKeys />
<Separator />
<SecretAPIKeys />
</DisableInteraction>
</>
)
}