mirror of
https://github.com/supabase/supabase.git
synced 2026-10-16 22:59:11 +03:00
* chore: cleanup packages - Avoid circular imports - Export API-types as types - pg-format without depending on Node internal Buffer (not browser-compatible) - Avoid importing from barrel files in ui dir * chore: avoid barrel file imports in studio (#27771) * chore: avoid barrel file imports - Removes some unused imports - Avoids barrel file import for faster builds + less memory * add eslint rule * type fixes * delete layouts barrel * delete components/grid barrel file * delete components/grid/utils barrel file * delete components/grid/components/common barrel file * delete components/grid/components/editor barrel file * delete components/grid/components/formatter barrel file * delete components/grid/components/grid barrel file * delete components/grid/components/header/filter barrel file * remote components/grid/store barrel file * remove components/interfaces/Auth/Policies barrel file * delete components/interfaces/Settings/Logs barrel file * delete components/ui/CodeEditor barrel file * delete components/ui/Forms barrel file * delete components/ui/Shimmers barrel file * delete data/analytics barrel file * delete hooks barrel file * cleanup lib/common/fetch barrel file * final * barral files cleanup * global react-data-grid styles * remove console.log --------- Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com> * fix build --------- Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com>
72 lines
2.3 KiB
TypeScript
72 lines
2.3 KiB
TypeScript
import { useRouter } from 'next/router'
|
|
import { ReactElement } from 'react'
|
|
|
|
import { useParams } from 'common'
|
|
import { useIsAPIDocsSidePanelEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
|
|
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 { useSelectedProject } from 'hooks/misc/useSelectedProject'
|
|
import { withAuth } from 'hooks/misc/withAuth'
|
|
import { PROJECT_STATUS } from 'lib/constants'
|
|
import ProjectLayout from '../ProjectLayout/ProjectLayout'
|
|
import { generateDocsMenu } from './DocsLayout.utils'
|
|
|
|
function DocsLayout({ title, children }: { title: string; children: ReactElement }) {
|
|
const router = useRouter()
|
|
const { ref } = useParams()
|
|
const selectedProject = useSelectedProject()
|
|
const isPaused = selectedProject?.status === PROJECT_STATUS.INACTIVE
|
|
|
|
const { data, isLoading, error } = useOpenAPISpecQuery(
|
|
{ projectRef: ref },
|
|
{ enabled: !isPaused }
|
|
)
|
|
|
|
const isNewAPIDocsEnabled = useIsAPIDocsSidePanelEnabled()
|
|
const hideMenu = isNewAPIDocsEnabled && router.pathname.endsWith('/graphiql')
|
|
|
|
const { projectAuthAll: authEnabled } = useIsFeatureEnabled(['project_auth:all'])
|
|
|
|
const getPage = () => {
|
|
if (router.pathname.endsWith('graphiql')) return 'graphiql'
|
|
|
|
const { page, resource } = router.query
|
|
if (!page && !resource) return 'introduction'
|
|
return (page || resource || '') as string
|
|
}
|
|
|
|
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
|
|
title={title || 'API Docs'}
|
|
isLoading={isLoading}
|
|
product="API Docs"
|
|
productMenu={
|
|
!hideMenu && (
|
|
<ProductMenu
|
|
page={getPage()}
|
|
menu={generateDocsMenu(projectRef, tableNames, functionNames, { authEnabled })}
|
|
/>
|
|
)
|
|
}
|
|
>
|
|
{children}
|
|
</ProjectLayout>
|
|
)
|
|
}
|
|
|
|
export default withAuth(DocsLayout)
|