HooksList() — supabase Function Reference
Architecture documentation for the HooksList() function in HooksList.tsx from the supabase codebase.
Entity Profile
Relationship Graph
Source Code
apps/studio/components/interfaces/Database/Hooks/HooksList/HooksList.tsx lines 27–118
export const HooksList = ({
createHook = noop,
editHook = noop,
deleteHook = noop,
}: HooksListProps) => {
const { data: project } = useSelectedProjectQuery()
const {
data: hooks,
isPending: isLoading,
isSuccess,
isError,
error,
} = useDatabaseHooksQuery({
projectRef: project?.ref,
connectionString: project?.connectionString,
})
const [filterString, setFilterString] = useState<string>('')
const filteredHooks = (hooks || []).filter((x: any) =>
includes(x.name.toLowerCase(), filterString.toLowerCase())
)
const filteredHookSchemas = lodashMap(uniqBy(filteredHooks, 'schema'), 'schema')
const { can: canCreateWebhooks, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions(
PermissionAction.TENANT_SQL_ADMIN_WRITE,
'triggers'
)
return (
<div className="w-full space-y-4">
<div className="flex items-center justify-between">
<Input
placeholder="Search for a webhook"
size="tiny"
icon={<Search />}
value={filterString}
className="w-52"
onChange={(e) => setFilterString(e.target.value)}
/>
<div className="flex items-center gap-x-2">
<DocsButton href={`${DOCS_URL}/guides/database/webhooks`} />
<ButtonTooltip
onClick={() => createHook()}
disabled={!isPermissionsLoaded || !canCreateWebhooks}
tooltip={{
content: {
side: 'bottom',
text:
isPermissionsLoaded && !canCreateWebhooks
? 'You need additional permissions to create webhooks'
: undefined,
},
}}
>
Create a new hook
</ButtonTooltip>
</div>
</div>
{isLoading && (
<div className="py-4">
<GenericSkeletonLoader />
</div>
)}
{isError && <AlertError error={error} subject="Failed to retrieve database webhooks" />}
{isSuccess &&
(hooks.length <= 0 ? (
<HooksListEmpty />
) : (
<>
{filteredHooks.length <= 0 && (
<NoSearchResults
searchString={filterString}
onResetFilter={() => setFilterString('')}
/>
)}
{filteredHookSchemas.map((schema: any) => (
<SchemaTable
key={schema}
filterString={filterString}
schema={schema}
editHook={editHook}
deleteHook={deleteHook}
/>
))}
</>
))}
</div>
)
}
Domain
Subdomains
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free