mirror of
https://github.com/supabase/supabase.git
synced 2026-10-09 11:25:06 +03:00
Restores proper content in new marketplace detail overview pages compared to the legacy overview pages. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added Data API URL settings and a visible "Required extensions" section across integration overviews. * Unified install/manage UIs for webhooks, Stripe Sync, wrappers, queues, and others; marketplace mode now shows marketplace-specific overview content. * **Style** * Improved marketplace detail rail and filter-bar button styling; refined list/link row visuals. * **Refactor** * Overview pages reorganized to branch on marketplace mode and extract shared overview content for consistency. * **Tests** * Stabilized integration overview test data for deterministic runs. <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46179?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
100 lines
3.1 KiB
TypeScript
100 lines
3.1 KiB
TypeScript
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
|
import { useParams } from 'common'
|
|
import { toast } from 'sonner'
|
|
import { Admonition } from 'ui-patterns'
|
|
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
|
|
|
|
import { IntegrationOverviewTab } from '../Integration/IntegrationOverviewTab'
|
|
import { RequiredExtensionsSection } from '../Integration/RequiredExtensionsSection'
|
|
import { useIsMarketplaceEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
|
|
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
|
|
import NoPermission from '@/components/ui/NoPermission'
|
|
import { useHooksEnableMutation } from '@/data/database/hooks-enable-mutation'
|
|
import { useSchemasQuery } from '@/data/database/schemas-query'
|
|
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
|
|
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
|
|
|
const WebhooksContent = () => {
|
|
const { ref: projectRef } = useParams()
|
|
const { data: project } = useSelectedProjectQuery()
|
|
|
|
const {
|
|
data: schemas,
|
|
isSuccess: isSchemasLoaded,
|
|
refetch,
|
|
} = useSchemasQuery({
|
|
projectRef: project?.ref,
|
|
connectionString: project?.connectionString,
|
|
})
|
|
|
|
const isHooksEnabled = schemas?.some((schema) => schema.name === 'supabase_functions')
|
|
const { can: canReadWebhooks, isLoading: isLoadingPermissions } = useAsyncCheckPermissions(
|
|
PermissionAction.TENANT_SQL_ADMIN_READ,
|
|
'triggers'
|
|
)
|
|
|
|
const { mutate: enableHooks, isPending: isEnablingHooks } = useHooksEnableMutation({
|
|
onSuccess: async () => {
|
|
await refetch()
|
|
toast.success('Successfully enabled webhooks')
|
|
},
|
|
})
|
|
|
|
const enableHooksForProject = async () => {
|
|
if (!projectRef) return console.error('Project ref is required')
|
|
enableHooks({ ref: projectRef })
|
|
}
|
|
|
|
if (!isSchemasLoaded || isLoadingPermissions) {
|
|
return (
|
|
<div className="p-10">
|
|
<GenericSkeletonLoader />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (!canReadWebhooks) {
|
|
return (
|
|
<div className="p-10">
|
|
<NoPermission isFullPage resourceText="view database webhooks" />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (isSchemasLoaded && isHooksEnabled) return null
|
|
|
|
return (
|
|
<Admonition showIcon={false} type="default" title="Enable database webhooks on your project">
|
|
<p>
|
|
Database Webhooks can be used to trigger serverless functions or send requests to an HTTP
|
|
endpoint
|
|
</p>
|
|
<ButtonTooltip
|
|
className="mt-2 w-fit"
|
|
onClick={() => enableHooksForProject()}
|
|
disabled={isEnablingHooks}
|
|
tooltip={{
|
|
content: {
|
|
side: 'bottom',
|
|
text: !canReadWebhooks
|
|
? 'You need additional permissions to enable webhooks'
|
|
: undefined,
|
|
},
|
|
}}
|
|
>
|
|
Enable webhooks
|
|
</ButtonTooltip>
|
|
</Admonition>
|
|
)
|
|
}
|
|
|
|
export const WebhooksOverviewTab = () => {
|
|
const isMarketplaceEnabled = useIsMarketplaceEnabled()
|
|
|
|
if (isMarketplaceEnabled) {
|
|
return <RequiredExtensionsSection />
|
|
}
|
|
|
|
return <IntegrationOverviewTab hideRequiredExtensionsSection actions={<WebhooksContent />} />
|
|
}
|