AddHookDropdown() — supabase Function Reference
Architecture documentation for the AddHookDropdown() function in AddHookDropdown.tsx from the supabase codebase.
Entity Profile
Dependency Diagram
graph TD 88ef1a80_8aa7_dc47_4a1b_b4c5227b90a4["AddHookDropdown()"] 44a1d22a_5d71_8dd5_1cd2_b6af6a48cf0f["extractMethod()"] 88ef1a80_8aa7_dc47_4a1b_b4c5227b90a4 -->|calls| 44a1d22a_5d71_8dd5_1cd2_b6af6a48cf0f 2b26d2a1_635d_8e95_7c0f_a3382ff8636f["isValidHook()"] 88ef1a80_8aa7_dc47_4a1b_b4c5227b90a4 -->|calls| 2b26d2a1_635d_8e95_7c0f_a3382ff8636f style 88ef1a80_8aa7_dc47_4a1b_b4c5227b90a4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
apps/studio/components/interfaces/Auth/Hooks/AddHookDropdown.tsx lines 30–124
export const AddHookDropdown = ({
buttonText = 'Add hook',
align = 'end',
type = 'primary',
onSelectHook,
}: AddHookDropdownProps) => {
const { ref: projectRef } = useParams()
const { data: organization } = useSelectedOrganizationQuery()
const { data: authConfig } = useAuthConfigQuery({ projectRef })
const { can: canUpdateAuthHook } = useAsyncCheckPermissions(PermissionAction.AUTH_EXECUTE, '*')
const { getEntitlementSetValues: getEntitledHookSet } = useCheckEntitlements('auth.hooks')
const entitledHookSet = getEntitledHookSet()
const { availableHooks, nonAvailableHooks } = useMemo(() => {
const allHooks: Hook[] = HOOKS_DEFINITIONS.map((definition) => ({
...definition,
enabled: authConfig?.[definition.enabledKey] || false,
method: extractMethod(
authConfig?.[definition.uriKey] || '',
authConfig?.[definition.secretsKey] || ''
),
}))
const availableHooks: Hook[] = allHooks.filter(
(h) => !isValidHook(h) && entitledHookSet.includes(h.entitlementKey)
)
const nonAvailableHooks: Hook[] = allHooks.filter(
(h) => !isValidHook(h) && !entitledHookSet.includes(h.entitlementKey)
)
return { availableHooks, nonAvailableHooks }
}, [entitledHookSet, authConfig])
if (!canUpdateAuthHook) {
return (
<ButtonTooltip
disabled
type={type}
tooltip={{
content: { side: 'bottom', text: 'You need additional permissions to add auth hooks' },
}}
>
{buttonText}
</ButtonTooltip>
)
}
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button type={type} iconRight={<ChevronDown />}>
{buttonText}
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-76" align={align}>
<div>
{availableHooks.length === 0 && (
<DropdownMenuLabel className="text-foreground-light">
All available hooks have been added
</DropdownMenuLabel>
)}
{availableHooks.map((h) => (
<DropdownMenuItem key={h.title} onClick={() => onSelectHook(h.title)}>
{h.title}
</DropdownMenuItem>
))}
</div>
{nonAvailableHooks.length > 0 && (
<>
{availableHooks.length > 0 && <DropdownMenuSeparator />}
<DropdownMenuLabel className="grid gap-1 bg-surface-200">
<p className="text-foreground-light">Team or Enterprise Plan required</p>
<p className="text-foreground-lighter text-xs">
The following hooks are not available on{' '}
<InlineLink href={`/org/${organization?.slug ?? '_'}/billing`}>
your plan
</InlineLink>
.
</p>
</DropdownMenuLabel>
{nonAvailableHooks.map((h) => (
<DropdownMenuItem key={h.title} disabled={true}>
{h.title}
</DropdownMenuItem>
))}
</>
)}
</DropdownMenuContent>
</DropdownMenu>
)
}
Domain
Subdomains
Source
Frequently Asked Questions
What does AddHookDropdown() do?
AddHookDropdown() is a function in the supabase codebase.
What does AddHookDropdown() call?
AddHookDropdown() calls 2 function(s): extractMethod, isValidHook.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free