Files
supabase/apps/studio/routes/project/$ref/logs/index.tsx
Alaister YoungandAlaister Young 96e4543ea9 [FE-3106] (part 9) – refactor(studio): move logs and observability page bodies (#53218)
Moves the `/logs/*` and `/observability/*` page bodies into their route
files and deletes the pages (FE-3106). Part 9 of the stack.

**Depends on:** #53217

**Changed:**
- `routes/project/$ref/logs/**` – 20 page bodies inlined. `logs/index`
keeps its `withAuth` wrapper; `replication-logs` redirects with
`<Navigate search hash>`; the Logs Explorer save navigates with `search:
{ queryId }` (never a query inside `to`)
- `routes/project/$ref/observability/**` – 12 page bodies inlined; chart
highlight actions navigate with `search` params
- `components/interfaces/Observability/DatabaseReport.hooks.ts` – the
database report's URL hooks move out of the page (with their test)
- `components/ui/Charts/ComposedChartHandler.tsx` – imports
`UpdateDateRange` from `ChartHighlightActions` instead of a page

**Removed:**
- 32 page files

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

## To test

- Logs Explorer: run a multi-line query, save it – the URL keeps
newlines and the saved query reopens
- Each log source (Postgres, Auth, Edge, Storage, Realtime, …) – same
layout and title
- Observability reports – charts render; highlighting a range links to
the right logs page

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

59 lines
1.8 KiB
TypeScript

import { createFileRoute, useNavigate } from '@tanstack/react-router'
import { useParams } from 'common'
import { useEffect } from 'react'
import { useUnifiedLogsPreview } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
import { UnifiedLogs } from '@/components/interfaces/UnifiedLogs/UnifiedLogs'
import { ProjectLayout } from '@/components/layouts/ProjectLayout'
import { UnknownInterface } from '@/components/ui/UnknownInterface'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
import { withAuth } from '@/hooks/misc/withAuth'
export const Route = createFileRoute('/project/$ref/logs/')({
component: LogsIndexRoute,
staticData: {
// Page body wraps in its own <ProjectLayout> conditionally; LogsLayout
// is not appropriate here.
skipLogsLayout: true,
},
})
const LogPageWithAuth = withAuth(LogPage)
function LogsIndexRoute() {
return <LogPageWithAuth />
}
function LogPage() {
const navigate = useNavigate()
const { ref } = useParams()
const logsEnabled = useIsFeatureEnabled('logs:all')
const { isEnabled: isUnifiedLogsEnabled, isLoading } = useUnifiedLogsPreview()
useEffect(() => {
if (logsEnabled && !isLoading && !isUnifiedLogsEnabled && ref) {
void navigate({ to: '/project/$ref/logs/explorer', params: { ref }, replace: true })
}
}, [logsEnabled, isLoading, isUnifiedLogsEnabled, ref, navigate])
if (!logsEnabled) {
return (
<ProjectLayout browserTitle={{ section: 'Logs' }}>
<UnknownInterface urlBack={`/project/${ref}`} />
</ProjectLayout>
)
}
if (isUnifiedLogsEnabled) {
return (
// Omit the generic product segment here; project/org context already makes the route clear.
<ProjectLayout browserTitle={{ section: 'Unified Logs' }}>
<UnifiedLogs />
</ProjectLayout>
)
}
return null
}