Files
supabase/apps/studio/components/layouts/ProjectIntegrationsLayout/ProjectIntegrationsLayout.tsx
T
Joshen Lim d8a57c1c7e Add settings for queues: toggle expose through postgrest + permissions via table privileges (#30564)
* Add settings for queues: toggle expose through postgrest + permissions via table privileges

* Ensure appropriate grants are granted when toggling, and revoked when disabling

* Update to use queues_public schema

* Update queue schema to pgmq_public and add/remove from data api when enabling/disabling

* Fix query for retrieving toggle state

* Add schema invalidation

* Remove hard code

* Use QueuesSettings from Queues folder, remove from NewQueues

* Update SQL for toggling exposure + support RLS enabling

* Support toggling RLS for a queue

* Update admonition copy in queues for enabling/disable postgrest exposure

* Add custom RLS policy for queue

* Minor style fixes

* Fix

* Remove hard code

* Update RLS to add message regarding relevancy only if exposure to PostgREST is enabled

* Update message in exposing queues to postgREST

* Address feedback

* Address feedback

* Don't revoke postgres role stuff

* Remove hard code

* Update copy

* Update

* Address Oli's feedback, ensure that queues ALL have RLS enabled prior to allowing exposure to PostgREST

* Address remaining feedback

* Remove hardcode

* Update

* Address feedback
2024-11-27 12:10:33 +08:00

68 lines
2.0 KiB
TypeScript

import { useRouter } from 'next/router'
import { PropsWithChildren } from 'react'
import { IS_PLATFORM } from 'common'
import { ProductMenu } from 'components/ui/ProductMenu'
import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query'
import { useSelectedProject } from 'hooks/misc/useSelectedProject'
import { withAuth } from 'hooks/misc/withAuth'
import { useFlag } from 'hooks/ui/useFlag'
import ProjectLayout from '../ProjectLayout/ProjectLayout'
import { generateProjectIntegrationsMenu } from './ProjectIntegrationsMenu.utils'
export interface ProjectIntegrationsLayoutProps {
title: string
}
const ProjectIntegrationsMenu = () => {
// if running on self-hosted, cron UI should be always enabled
const cronUiEnabled = useFlag('cronUi') || !IS_PLATFORM
const queuesUiEnabled = useFlag('queues')
const project = useSelectedProject()
const router = useRouter()
const page = router.pathname.split('/')[4]
const { data } = useDatabaseExtensionsQuery({
projectRef: project?.ref,
connectionString: project?.connectionString,
})
const pgNetExtensionExists = (data ?? []).find((ext) => ext.name === 'pg_net') !== undefined
const graphqlExtensionExists = (data ?? []).find((ext) => ext.name === 'pg_graphql') !== undefined
const pgmqExtensionExists = (data ?? []).find((ext) => ext.name === 'pgmq') !== undefined
return (
<>
<ProductMenu
page={page}
menu={generateProjectIntegrationsMenu(project, {
pgNetExtensionExists,
cronUiEnabled,
queuesUiEnabled,
graphqlExtensionExists,
pgmqExtensionExists,
})}
/>
</>
)
}
const ProjectIntegrationsLayout = ({
children,
title,
}: PropsWithChildren<ProjectIntegrationsLayoutProps>) => {
return (
<ProjectLayout
title={title}
product="Integrations"
productMenu={<ProjectIntegrationsMenu />}
isBlocking={false}
>
{children}
</ProjectLayout>
)
}
export default withAuth(ProjectIntegrationsLayout)