mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 02:15:05 +03:00
* Demo api side panel * Add docs for storage and edge functions * Add content * fix * Add scroll to logic * Add storage docs * Add docs URLs * Add connecting to project section in getting started * Link back to docs site for product + resource specific docs * Add entry points into API side panel for table editor, auth users and storage * Add entry points into API side panel for edge functions * Beef up feature preview modal with content * Fix asset path * Address several feedback * Addressing more feedback * Shift GraphiQL page to database if new api docs flag enabled * Spelling * Wording changes * Spacing and wording * Fix small issues * Fix * Update key showing toggle button --------- Co-authored-by: Terry Sutton <saltcod@gmail.com>
60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
import { observer } from 'mobx-react-lite'
|
|
import { useRouter } from 'next/router'
|
|
import { PropsWithChildren, useEffect } from 'react'
|
|
|
|
import ProductMenu from 'components/ui/ProductMenu'
|
|
import { useSelectedProject, useStore, withAuth } from 'hooks'
|
|
import ProjectLayout from '../'
|
|
import { generateDatabaseMenu } from './DatabaseMenu.utils'
|
|
import { useIsAPIDocsSidePanelEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
|
|
|
|
export interface DatabaseLayoutProps {
|
|
title?: string
|
|
}
|
|
|
|
const DatabaseLayout = ({ children }: PropsWithChildren<DatabaseLayoutProps>) => {
|
|
const { ui, meta, vault } = useStore()
|
|
const project = useSelectedProject()
|
|
|
|
const router = useRouter()
|
|
const page = router.pathname.split('/')[4]
|
|
|
|
const vaultExtension = meta.extensions.byId('supabase_vault')
|
|
const isVaultEnabled = vaultExtension !== undefined && vaultExtension.installed_version !== null
|
|
const pgNetExtensionExists = meta.extensions.byId('pg_net') !== undefined
|
|
const isNewAPIDocsEnabled = useIsAPIDocsSidePanelEnabled()
|
|
|
|
useEffect(() => {
|
|
if (ui.selectedProjectRef) {
|
|
meta.roles.load()
|
|
meta.triggers.load()
|
|
meta.extensions.load()
|
|
meta.publications.load()
|
|
}
|
|
}, [ui.selectedProjectRef])
|
|
|
|
useEffect(() => {
|
|
if (isVaultEnabled) {
|
|
vault.load()
|
|
}
|
|
}, [ui.selectedProjectRef, isVaultEnabled])
|
|
|
|
return (
|
|
<ProjectLayout
|
|
product="Database"
|
|
productMenu={
|
|
<ProductMenu
|
|
page={page}
|
|
menu={generateDatabaseMenu(project, { pgNetExtensionExists, isNewAPIDocsEnabled })}
|
|
/>
|
|
}
|
|
>
|
|
<main style={{ maxHeight: '100vh' }} className="flex-1 overflow-y-auto">
|
|
{children}
|
|
</main>
|
|
</ProjectLayout>
|
|
)
|
|
}
|
|
|
|
export default withAuth(observer(DatabaseLayout))
|