mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 10:55:06 +03:00
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
|
import { useRouter } from 'next/router'
|
|
import { PropsWithChildren } from 'react'
|
|
|
|
import NoPermission from 'components/ui/NoPermission'
|
|
import ProductMenu from 'components/ui/ProductMenu'
|
|
import { useCheckPermissions, useSelectedProject, withAuth } from 'hooks'
|
|
import ProjectLayout from '../'
|
|
import { generateLogsMenu } from './LogsMenu.utils'
|
|
|
|
interface LogsLayoutProps {
|
|
title?: string
|
|
}
|
|
|
|
const LogsLayout = ({ title, children }: PropsWithChildren<LogsLayoutProps>) => {
|
|
const router = useRouter()
|
|
const pathArr = router.pathname.split('/')
|
|
const page = pathArr[pathArr.length - 1]
|
|
|
|
const project = useSelectedProject()
|
|
|
|
const canUseLogsExplorer = useCheckPermissions(PermissionAction.ANALYTICS_READ, 'logflare')
|
|
|
|
if (!canUseLogsExplorer) {
|
|
return (
|
|
<ProjectLayout>
|
|
<main style={{ maxHeight: '100vh' }} className="flex-1 overflow-y-auto">
|
|
<NoPermission isFullPage resourceText="access your project's logs explorer" />
|
|
</main>
|
|
</ProjectLayout>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<ProjectLayout
|
|
title={title}
|
|
product="Logs"
|
|
productMenu={<ProductMenu page={page} menu={generateLogsMenu(project)} />}
|
|
>
|
|
<main style={{ maxHeight: '100vh' }} className="flex-1 overflow-y-auto">
|
|
{children}
|
|
</main>
|
|
</ProjectLayout>
|
|
)
|
|
}
|
|
|
|
export default withAuth(LogsLayout)
|