mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
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>
66 lines
2.6 KiB
TypeScript
66 lines
2.6 KiB
TypeScript
import { JwtSecretUpdateError, JwtSecretUpdateStatus } from '@supabase/shared-types/out/events'
|
|
import { useQueryClient } from '@tanstack/react-query'
|
|
import { createFileRoute } from '@tanstack/react-router'
|
|
import { useParams } from 'common'
|
|
import { useEffect, useRef } from 'react'
|
|
import { toast } from 'sonner'
|
|
|
|
import { JWTSettings } from '@/components/interfaces/JwtSecrets/jwt-settings'
|
|
import { JWT_SECRET_UPDATE_ERROR_MESSAGES } from '@/components/interfaces/JwtSecrets/jwt.constants'
|
|
import JWTKeysLayout from '@/components/layouts/JWTKeys/JWTKeysLayout'
|
|
import { UnknownInterface } from '@/components/ui/UnknownInterface'
|
|
import { useJwtSecretUpdatingStatusQuery } from '@/data/config/jwt-secret-updating-status-query'
|
|
import { configKeys } from '@/data/config/keys'
|
|
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
|
|
|
|
export const Route = createFileRoute('/project/$ref/settings/jwt/legacy')({
|
|
component: JWTKeysLegacyPage,
|
|
staticData: { settingsLayoutTitle: 'JWT Keys (Legacy)' },
|
|
})
|
|
|
|
function JWTKeysLegacyPage() {
|
|
const client = useQueryClient()
|
|
const { ref: projectRef } = useParams()
|
|
const { projectSettingsLegacyJwtKeys } = useIsFeatureEnabled(['project_settings:legacy_jwt_keys'])
|
|
|
|
const { data } = useJwtSecretUpdatingStatusQuery(
|
|
{ projectRef },
|
|
{ enabled: projectSettingsLegacyJwtKeys }
|
|
)
|
|
const jwtSecretUpdateStatus = data?.jwtSecretUpdateStatus
|
|
const jwtSecretUpdateError = data?.jwtSecretUpdateError
|
|
|
|
const previousJwtSecretUpdateStatus = useRef<JwtSecretUpdateStatus>(undefined)
|
|
const { Failed, Updated, Updating } = JwtSecretUpdateStatus
|
|
const jwtSecretUpdateErrorMessage =
|
|
JWT_SECRET_UPDATE_ERROR_MESSAGES[jwtSecretUpdateError as JwtSecretUpdateError]
|
|
|
|
useEffect(() => {
|
|
if (previousJwtSecretUpdateStatus.current === Updating) {
|
|
switch (jwtSecretUpdateStatus) {
|
|
case Updated:
|
|
client.invalidateQueries({ queryKey: configKeys.api(projectRef) })
|
|
client.invalidateQueries({ queryKey: configKeys.settings(projectRef) })
|
|
client.invalidateQueries({ queryKey: configKeys.postgrest(projectRef) })
|
|
toast.success('Successfully updated JWT secret')
|
|
break
|
|
case Failed:
|
|
toast.error(`JWT secret update failed: ${jwtSecretUpdateErrorMessage}`)
|
|
break
|
|
}
|
|
}
|
|
|
|
previousJwtSecretUpdateStatus.current = jwtSecretUpdateStatus
|
|
}, [jwtSecretUpdateStatus])
|
|
|
|
if (!projectSettingsLegacyJwtKeys) {
|
|
return <UnknownInterface urlBack={`/project/${projectRef}/settings/jwt/signing-keys`} />
|
|
}
|
|
|
|
return (
|
|
<JWTKeysLayout>
|
|
<JWTSettings />
|
|
</JWTKeysLayout>
|
|
)
|
|
}
|