Files
supabase/apps/studio/routes/project/$ref/functions/$functionSlug/logs.tsx
Alaister YoungandAlaister Young 2695cf117a [FE-3106] (part 8) – refactor(studio): move storage, functions and branches pages (#53217)
Moves the `/storage`, `/realtime`, `/compute`, `/functions` and
`/branches` page bodies into their route files and deletes the pages
(FE-3106). Part 8 of the stack.

**Depends on:** #53216

**Changed:**
- `routes/project/$ref/{storage,realtime,compute,functions,branches}/**`
– 26 page bodies inlined. Wrappers the routes imported from pages
(`BranchesPageWrapper`, `MergeRequestsPageWrapper`, …) are now private
to their route files. Bucket redirects, function create/deploy
navigation and merge-request links use typed `navigate`/`Link`; function
logs/invocations use `useLocation().href`
- Edge function overview, logs-navigation, vectors, compute and branches
tests render the routes with `renderRoute`

- `routes/project/$ref/storage/files/buckets/$bucketId.tsx` – also
carries master's #52777 (Purge CDN cache action and single `action`
query param for the bucket modals), ported from the deleted page so it
isn't reverted

**Removed:**
- 26 page files

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

## To test

- Storage: open a bucket, its policies link and S3 settings – same
layout; deleting a bucket returns to the list
- Edge Functions: create a function, open
Overview/Code/Logs/Invocations/Details – same layout
- Branches and merge requests – lists and "Review" links work

---------

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

75 lines
2.4 KiB
TypeScript

import { createFileRoute, useLocation, useNavigate } from '@tanstack/react-router'
import { useParams } from 'common'
import { useCallback, useMemo } from 'react'
import { useUnifiedLogsPreview } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
import {
EDGE_FUNCTION_LOGS_VIEW,
getEdgeFunctionLogsScope,
} from '@/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionOverview.utils'
import { useFunctionLogsMigration } from '@/components/interfaces/Functions/useFunctionLogsMigration'
import { LogsPreviewer } from '@/components/interfaces/Settings/Logs/LogsPreviewer'
import { UnifiedLogs } from '@/components/interfaces/UnifiedLogs/UnifiedLogs'
import { useEdgeFunctionQuery } from '@/data/edge-functions/edge-function-query'
export const Route = createFileRoute('/project/$ref/functions/$functionSlug/logs')({
component: LogPage,
staticData: {
edgeFunctionDetailsTitle: 'Logs',
},
})
function LogPage() {
const { href: asPath } = useLocation()
const navigate = useNavigate()
const { ref, functionSlug } = useParams()
const { isEnabled: isUnifiedLogsEnabled, isLoading: isLoadingPreview } = useUnifiedLogsPreview()
const { data: selectedFunction, isPending: isLoading } = useEdgeFunctionQuery({
projectRef: ref,
slug: functionSlug,
})
const functionId = selectedFunction?.id
const scope = useMemo(
() => (functionId ? getEdgeFunctionLogsScope(functionId) : undefined),
[functionId]
)
const handleReplace = useCallback(
(url: string) => void navigate({ href: url, replace: true }),
[navigate]
)
const { isMigrating, shouldUseLegacyLogs } = useFunctionLogsMigration({
asPath,
onReplace: handleReplace,
projectRef: ref,
functionSlug,
isEnabled: isUnifiedLogsEnabled,
isLoading: isLoadingPreview,
})
if (selectedFunction === undefined || isLoading || isLoadingPreview || isMigrating) return null
if (isUnifiedLogsEnabled && !shouldUseLegacyLogs) {
return (
<div className="relative min-h-0 flex-1">
<div className="absolute inset-0">
<UnifiedLogs scope={scope} hasFilterSideBar={false} {...EDGE_FUNCTION_LOGS_VIEW} />
</div>
</div>
)
}
return (
<div className="flex-1">
<LogsPreviewer
condensedLayout
projectRef={ref as string}
queryType="functions"
filterOverride={{ 'metadata.function_id': selectedFunction.id }}
/>
</div>
)
}