Files
supabase/studio/components/layouts/DatabaseLayout/DatabaseLayout.tsx
T
Joshen LimandTerry Sutton 94f5fc5a61 Feat/api side panel (#17880)
* 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>
2023-10-05 13:30:12 +08:00

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))