OverviewTab.tsx55 lines · main
| 1 | import { useParams } from 'common' |
| 2 | import Link from 'next/link' |
| 3 | import { Button } from 'ui' |
| 4 | import { Admonition } from 'ui-patterns' |
| 5 | |
| 6 | import { IntegrationOverviewTab } from '../Integration/IntegrationOverviewTab' |
| 7 | import { IntegrationOverviewTabV2 } from '../Integration/IntegrationOverviewTabV2' |
| 8 | import { useIsMarketplaceEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext' |
| 9 | import { useDatabaseExtensionsQuery } from '@/data/database-extensions/database-extensions-query' |
| 10 | import { useQueuesExposePostgrestStatusQuery } from '@/data/database-queues/database-queues-expose-postgrest-status-query' |
| 11 | import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject' |
| 12 | |
| 13 | const QueuesAdmonition = () => { |
| 14 | const { ref } = useParams() |
| 15 | const { data: project } = useSelectedProjectQuery() |
| 16 | |
| 17 | const { data: extensions = [] } = useDatabaseExtensionsQuery({ |
| 18 | projectRef: project?.ref, |
| 19 | connectionString: project?.connectionString, |
| 20 | }) |
| 21 | const isQueuesInstalled = !!extensions.find((x) => x.name === 'pgmq')?.installed_version |
| 22 | |
| 23 | return ( |
| 24 | <Admonition |
| 25 | type="default" |
| 26 | title="Queues can be managed via any Briven client library or PostgREST endpoints" |
| 27 | > |
| 28 | <p> |
| 29 | You may choose to toggle the exposure of Queues through Data APIs via the queues settings |
| 30 | </p> |
| 31 | |
| 32 | {isQueuesInstalled && ( |
| 33 | <Button asChild type="default" className="mt-2"> |
| 34 | <Link href={`/project/${ref}/integrations/queues/settings`}>Manage queues settings</Link> |
| 35 | </Button> |
| 36 | )} |
| 37 | </Admonition> |
| 38 | ) |
| 39 | } |
| 40 | |
| 41 | export const QueuesOverviewTab = () => { |
| 42 | const { data: project } = useSelectedProjectQuery() |
| 43 | const isMarketplaceEnabled = useIsMarketplaceEnabled() |
| 44 | |
| 45 | const { data: isExposed } = useQueuesExposePostgrestStatusQuery({ |
| 46 | projectRef: project?.ref, |
| 47 | connectionString: project?.connectionString, |
| 48 | }) |
| 49 | |
| 50 | if (isMarketplaceEnabled) { |
| 51 | return <IntegrationOverviewTabV2>{!isExposed && <QueuesAdmonition />}</IntegrationOverviewTabV2> |
| 52 | } else { |
| 53 | return <IntegrationOverviewTab actions={!isExposed ? <QueuesAdmonition /> : null} /> |
| 54 | } |
| 55 | } |