Files
supabase/apps/studio/routes/project/$ref/functions/$functionSlug/invocations.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

62 lines
1.9 KiB
TypeScript

import { createFileRoute, useLocation, useNavigate } from '@tanstack/react-router'
import { useParams } from 'common'
import { useCallback } from 'react'
import { useUnifiedLogsPreview } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
import { useFunctionLogsMigration } from '@/components/interfaces/Functions/useFunctionLogsMigration'
import { LogsPreviewer } from '@/components/interfaces/Settings/Logs/LogsPreviewer'
import { useEdgeFunctionQuery } from '@/data/edge-functions/edge-function-query'
export const Route = createFileRoute('/project/$ref/functions/$functionSlug/invocations')({
component: LogPage,
staticData: {
edgeFunctionDetailsTitle: 'Invocations',
},
})
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 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,
isInvocationsPage: true,
})
const shouldWaitForLogs =
selectedFunction === undefined ||
isLoading ||
isLoadingPreview ||
isMigrating ||
(isUnifiedLogsEnabled && !shouldUseLegacyLogs)
if (shouldWaitForLogs) return null
return (
<div className="flex-1">
<LogsPreviewer
condensedLayout
projectRef={ref as string}
queryType="fn_edge"
filterOverride={{ 'request.pathname': `/functions/v1/${selectedFunction.slug}` }}
/>
</div>
)
}