Files
supabase/apps/studio/components/layouts/ProjectSettingsLayout/SettingsLayout.tsx
T
ZiincandJordi Enric 5cfd10aae6 feat: self-hosted log drains (#28297)
* feat: initial log drain creation, sans rules creation.

* feat: add rules posting

* add project settings to self hosted and adapt log drains

* feat: log drains crud implementation, env var update

* feat: local log drains is working! rules provisioning refined

* fix: add filtering

* feat: finish implementing CRUD of local log drains.

* chore: formatting

* only allow navigation to log drains

* rm unnecessary checks

* rm log

* rm logs

* rm log

* fix type err

* turbofix for turboissue

---------

Co-authored-by: Jordi Enric <jordi.err@gmail.com>
2025-10-30 10:37:32 +00:00

74 lines
2.4 KiB
TypeScript

import { useRouter } from 'next/router'
import { PropsWithChildren, useEffect } from 'react'
import { useParams } from 'common'
import { ProductMenu } from 'components/ui/ProductMenu'
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import { withAuth } from 'hooks/misc/withAuth'
import { IS_PLATFORM } from 'lib/constants'
import { ProjectLayout } from '../ProjectLayout/ProjectLayout'
import { generateSettingsMenu } from './SettingsMenu.utils'
interface SettingsLayoutProps {
title?: string
}
const SettingsLayout = ({ title, children }: PropsWithChildren<SettingsLayoutProps>) => {
const router = useRouter()
const { ref } = useParams()
const { data: project } = useSelectedProjectQuery()
const { data: organization } = useSelectedOrganizationQuery()
// billing pages live under /billing/invoices and /billing/subscription, etc
// so we need to pass the [5]th part of the url to the menu
const page = router.pathname.includes('billing')
? router.pathname.split('/')[5]
: router.pathname.split('/')[4]
const {
projectAuthAll: authEnabled,
authenticationShowProviders: authProvidersEnabled,
projectEdgeFunctionAll: edgeFunctionsEnabled,
projectStorageAll: storageEnabled,
billingInvoices: invoicesEnabled,
projectSettingsLegacyJwtKeys: legacyJWTKeysEnabled,
projectSettingsLogDrains,
billingAll,
} = useIsFeatureEnabled([
'project_auth:all',
'authentication:show_providers',
'project_edge_function:all',
'project_storage:all',
'billing:invoices',
'project_settings:legacy_jwt_keys',
'project_settings:log_drains',
'billing:all',
])
const menuRoutes = generateSettingsMenu(ref, project, organization, {
auth: authEnabled,
authProviders: authProvidersEnabled,
edgeFunctions: edgeFunctionsEnabled,
storage: storageEnabled,
invoices: invoicesEnabled,
legacyJwtKeys: legacyJWTKeysEnabled,
logDrains: projectSettingsLogDrains,
billing: billingAll,
})
return (
<ProjectLayout
isBlocking={false}
title={title || 'Settings'}
product="Settings"
productMenu={<ProductMenu page={page} menu={menuRoutes} />}
>
{children}
</ProjectLayout>
)
}
export default withAuth(SettingsLayout)