The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Add tooltip for queue settings (#30761)
Joshen Limbcd71a64ed59
diff --git a/apps/studio/components/interfaces/Integrations/Queues/SingleQueue/Queue.utils.tsx b/apps/studio/components/interfaces/Integrations/Queues/SingleQueue/Queue.utils.tsxindex 3f72dc4ede4..2d236a9e7f0 100644--- a/apps/studio/components/interfaces/Integrations/Queues/SingleQueue/Queue.utils.tsx+++ b/apps/studio/components/interfaces/Integrations/Queues/SingleQueue/Queue.utils.tsx@@ -7,3 +7,18 @@ export const QUEUE_MESSAGE_OPTIONS = QUEUE_MESSAGE_TYPES.map((type) => ({id: type,name: capitalize(type),}))++export const getQueueFunctionsMapping = (command: string) => {+ switch (command) {+ case 'select':+ return ['send', 'send_batch', 'read', 'pop', 'archive', 'delete']+ case 'insert':+ return ['send', 'send_batch']+ case 'update':+ return ['read', 'pop']+ case 'delete':+ return ['archive', 'delete']+ default:+ return []+ }+}diff --git a/apps/studio/components/interfaces/Integrations/Queues/SingleQueue/QueueSettings.tsx b/apps/studio/components/interfaces/Integrations/Queues/SingleQueue/QueueSettings.tsxindex fd475eb5acb..4406a7c403f 100644--- a/apps/studio/components/interfaces/Integrations/Queues/SingleQueue/QueueSettings.tsx+++ b/apps/studio/components/interfaces/Integrations/Queues/SingleQueue/QueueSettings.tsx@@ -1,5 +1,5 @@import { isEqual } from 'lodash'-import { Settings } from 'lucide-react'+import { HelpCircle, Settings } from 'lucide-react'import { useEffect, useState } from 'react'import { toast } from 'sonner'@@ -35,8 +35,13 @@ import {TableHead,TableHeader,TableRow,+ Tooltip_Shadcn_,+ TooltipContent_Shadcn_,+ TooltipTrigger_Shadcn_,} from 'ui'import ShimmeringLoader from 'ui-patterns/ShimmeringLoader'+import { useQueuesExposePostgrestStatusQuery } from 'data/database-queues/database-queues-expose-postgrest-status-query'+import { getQueueFunctionsMapping } from './Queue.utils'const ACTIONS = ['select', 'insert', 'update', 'delete']type Privileges = { select?: boolean; insert?: boolean; update?: boolean; delete?: boolean }@@ -51,6 +56,11 @@ export const QueueSettings = ({}: QueueSettingsProps) => {const [isSaving, setIsSaving] = useState(false)const [privileges, setPrivileges] = useState<{ [key: string]: Privileges }>({})+ const { data: isExposed } = useQueuesExposePostgrestStatusQuery({+ projectRef: project?.ref,+ connectionString: project?.connectionString,+ })+const { data, error, isLoading, isSuccess, isError } = useDatabaseRolesQuery({projectRef: project?.ref,connectionString: project?.connectionString,@@ -223,7 +233,14 @@ export const QueueSettings = ({}: QueueSettingsProps) => {<SheetHeader><SheetTitle>Manage queue permissions on {name}</SheetTitle><SheetDescription>- Configure permissions for each role to grant access to the relevant actions on the queue+ Configure permissions for each role to grant access to the relevant actions on the+ queue.{' '}+ {isExposed && (+ <>+ These will also determine access to each function available from the{' '}+ <code className="text-xs">pgmq_public</code> schema.+ </>+ )}</SheetDescription></SheetHeader>@@ -232,11 +249,38 @@ export const QueueSettings = ({}: QueueSettingsProps) => {<TableHeader className="[&_th]:h-8"><TableRow className="py-2"><TableHead>Role</TableHead>- {ACTIONS.map((x) => (- <TableHead key={x} className="capitalize">- {x}- </TableHead>- ))}+ {ACTIONS.map((x) => {+ const relatedFunctions = getQueueFunctionsMapping(x)+ return (+ <TableHead key={x}>+ <Tooltip_Shadcn_>+ <TooltipTrigger_Shadcn_ className="mx-auto flex items-center gap-x-1 capitalize text-foreground-light font-normal">+ {x}+ {isExposed && <HelpCircle size={14} strokeWidth={1.5} />}+ </TooltipTrigger_Shadcn_>+ {isExposed && (+ <TooltipContent_Shadcn_+ side="bottom"+ className="w-64 flex flex-col gap-y-1"+ >+ <p>+ Required for{' '}+ {relatedFunctions.length === 6+ ? 'all'+ : `the following ${relatedFunctions.length}`}{' '}+ functions:+ </p>+ <div className="max-w-full flex flex-wrap gap-x-0.5 gap-y-1">+ {relatedFunctions.map((y) => (+ <code key={`${x}_${y}`}>{y}</code>+ ))}+ </div>+ </TooltipContent_Shadcn_>+ )}+ </Tooltip_Shadcn_>+ </TableHead>+ )+ })}</TableRow></TableHeader><TableBody className="[&_td]:py-2">@@ -272,7 +316,7 @@ export const QueueSettings = ({}: QueueSettingsProps) => {<TableRow key={role.id}><TableCell>{role.name}</TableCell>{ACTIONS.map((x) => (- <TableCell key={x}>+ <TableCell key={x} className="text-center"><Switchchecked={(privileges[role.name] as Privileges)?.[x as keyof Privileges] ??