mirror of
https://github.com/supabase/supabase.git
synced 2026-05-09 18:30:12 -04:00
26b3db8302
## Summary - Removes the "API Docs" navigation item from the sidebar and mobile menu - Removes the `UI_PREVIEW_API_SIDE_PANEL` feature preview flag since the feature is fully rolled out - Makes API docs buttons unconditionally visible across Auth Users, Storage, Edge Functions, and SecondLevelNav ## Test plan - [x] `NavigationBar.utils` tests pass (26 tests) - [x] `FileExplorerHeader` tests pass (6 tests) - [x] TypeScript compiles with no errors - [ ] Verify sidebar no longer shows "API Docs" nav item - [ ] Verify API docs buttons still appear in Auth Users, Storage, and Edge Functions pages - [ ] Verify feature preview modal no longer lists "Project API documentation" Resolves FE-2759 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * APIDocs button can optionally display a label and use a custom tooltip. * **Chores** * Removed the API docs side-panel feature flag and its localStorage key. * “API Docs” navigation entry removed; sidebar no longer special-cases that route. * Back links and API Docs buttons now render consistently across the app (no flag gating). * **Tests** * Tests updated to stop depending on the removed feature-flag behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
74 lines
2.2 KiB
TypeScript
74 lines
2.2 KiB
TypeScript
import { useParams } from 'common'
|
|
import { useRouter } from 'next/router'
|
|
import { ReactElement } from 'react'
|
|
|
|
import { ProjectLayout } from '../ProjectLayout'
|
|
import { generateDocsMenu, getActivePage } from './DocsLayout.utils'
|
|
import Error from '@/components/ui/Error'
|
|
import { ProductMenu } from '@/components/ui/ProductMenu'
|
|
import { useOpenAPISpecQuery } from '@/data/open-api/api-spec-query'
|
|
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
|
|
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
|
import { withAuth } from '@/hooks/misc/withAuth'
|
|
import { PROJECT_STATUS } from '@/lib/constants'
|
|
|
|
function DocsLayout({ title, children }: { title: string; children: ReactElement }) {
|
|
const router = useRouter()
|
|
const { ref } = useParams()
|
|
const { data: selectedProject } = useSelectedProjectQuery()
|
|
const isPaused = selectedProject?.status === PROJECT_STATUS.INACTIVE
|
|
|
|
const {
|
|
data,
|
|
isPending: isLoading,
|
|
error,
|
|
} = useOpenAPISpecQuery({ projectRef: ref }, { enabled: !isPaused })
|
|
|
|
const hideMenu = router.pathname.endsWith('/graphiql')
|
|
|
|
const { projectAuthAll: authEnabled } = useIsFeatureEnabled(['project_auth:all'])
|
|
|
|
const getPage = () => {
|
|
if (router.pathname.endsWith('graphiql')) return 'graphiql'
|
|
|
|
const { page, rpc, resource } = router.query
|
|
return getActivePage({
|
|
page: page as string | undefined,
|
|
resource: resource as string | undefined,
|
|
rpc: rpc as string | undefined,
|
|
})
|
|
}
|
|
|
|
if (error) {
|
|
return (
|
|
<ProjectLayout product="API Docs">
|
|
<Error error={error} />
|
|
</ProjectLayout>
|
|
)
|
|
}
|
|
|
|
const projectRef = selectedProject?.ref ?? 'default'
|
|
const tableNames = (data?.tables ?? []).map((table: any) => table.name)
|
|
const functionNames = (data?.functions ?? []).map((fn: any) => fn.name)
|
|
|
|
return (
|
|
<ProjectLayout
|
|
isLoading={isLoading}
|
|
product="API Docs"
|
|
browserTitle={{ section: title || 'API Docs' }}
|
|
productMenu={
|
|
!hideMenu && (
|
|
<ProductMenu
|
|
page={getPage()}
|
|
menu={generateDocsMenu(projectRef, tableNames, functionNames, { authEnabled })}
|
|
/>
|
|
)
|
|
}
|
|
>
|
|
{children}
|
|
</ProjectLayout>
|
|
)
|
|
}
|
|
|
|
export default withAuth(DocsLayout)
|