mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
Moves the SQL editor, table editor, explorer and project integrations page bodies into their route files and deletes the pages (FE-3106). Part 11 of the stack. **Depends on:** #53219 **Changed:** - `routes/project/$ref/{sql,editor,explorer,integrations}/**` – 15 page bodies inlined. Every `router.push/replace` became the equivalent `navigate` with the same path, `search` and `replace`; the last-opened-table redirect splits `buildTableEditorUrl`'s absolute URL with `splitInternalUrl` so it stays a client-side navigation - `components/interfaces/SQLEditor/SnippetNotFound.tsx` – the invalid-snippet state moves out of the route because `tabs.handleTabClose` still takes a Next-shaped router - `tests/routes/project/$ref/explorer/index.test.tsx` – moved and rendered with `renderRoute` **Removed:** - 15 page files Addresses [FE-3106](https://linear.app/supabase/issue/FE-3106/move-page-bodies-into-route-files-and-delete-pages). ## To test - SQL editor: open `/sql` (redirects to the last snippet or `new`), open/close snippets and tabs, an invalid snippet id shows "Unable to find snippet" - Table editor: open `/editor` (redirects to the last table), create a table – lands on it with `?schema=` - Explorer and Integrations pages – same layout; integration sub-pages redirect as before --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
59 lines
1.9 KiB
TypeScript
59 lines
1.9 KiB
TypeScript
import { createFileRoute, useNavigate } from '@tanstack/react-router'
|
|
import { useFlag } from 'common'
|
|
import { useEffect } from 'react'
|
|
import { PageContainer } from 'ui-patterns/PageContainer'
|
|
import { PageSection, PageSectionContent } from 'ui-patterns/PageSection'
|
|
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
|
|
|
|
export const Route = createFileRoute('/project/$ref/integrations/$id/')({
|
|
component: IntegrationPage,
|
|
})
|
|
|
|
const INTEGRATION_FLAGS: Record<string, string> = {
|
|
grafana: 'grafanaDashboardIntegrationEnabled',
|
|
resend: 'resendDashboardIntegrationEnabled',
|
|
aikido: 'aikidoDashboardIntegrationEnabled',
|
|
doppler: 'dopplerDashboardIntegrationEnabled',
|
|
}
|
|
|
|
function IntegrationPage() {
|
|
const navigate = useNavigate()
|
|
const { ref, id } = Route.useParams()
|
|
|
|
const grafanaEnabled = useFlag('grafanaDashboardIntegrationEnabled')
|
|
const resendEnabled = useFlag('resendDashboardIntegrationEnabled')
|
|
const aikidoEnabled = useFlag('aikidoDashboardIntegrationEnabled')
|
|
const dopplerEnabled = useFlag('dopplerDashboardIntegrationEnabled')
|
|
|
|
const integrationFlagValues: Record<string, boolean> = {
|
|
grafana: grafanaEnabled,
|
|
resend: resendEnabled,
|
|
aikido: aikidoEnabled,
|
|
doppler: dopplerEnabled,
|
|
}
|
|
|
|
useEffect(() => {
|
|
const flagName = id ? INTEGRATION_FLAGS[id] : undefined
|
|
if (flagName !== undefined && integrationFlagValues[id] === false) {
|
|
void navigate({ to: '/project/$ref/integrations', params: { ref }, replace: true })
|
|
return
|
|
}
|
|
|
|
void navigate({
|
|
to: '/project/$ref/integrations/$id/$pageId',
|
|
params: { ref, id, pageId: 'overview' },
|
|
replace: true,
|
|
})
|
|
}, [navigate, ref, id, grafanaEnabled, resendEnabled, aikidoEnabled, dopplerEnabled])
|
|
|
|
return (
|
|
<PageContainer size="full">
|
|
<PageSection>
|
|
<PageSectionContent>
|
|
<GenericSkeletonLoader />
|
|
</PageSectionContent>
|
|
</PageSection>
|
|
</PageContainer>
|
|
)
|
|
}
|