mirror of
https://github.com/supabase/supabase.git
synced 2026-09-08 19:08:44 +08:00
Follow-up to #48344: collapses the two resolution paths for the Admonition module into one. `src/admonition.tsx` was a back-compat shim re-exporting `src/Admonition/`. Two ways to resolve one module is exactly what produced the macOS self-import bug fixed in #48344, and the local typecheck errors that #48374 worked around. This removes the shim and standardizes on the PascalCase subpath, matching every other export in the package. **Changed:** - Codemodded all 246 `ui-patterns/admonition` imports to `ui-patterns/Admonition` (240 `.tsx`, 5 `.mdx`, 1 `.ts` across studio, docs, www, design-system, and lite-studio) - Pointed the 5 internal `'../admonition'` imports back at the `'../Admonition'` directory **Removed:** - `packages/ui-patterns/src/admonition.tsx`, and its `./admonition` entry in the exports map (regenerated with `pnpm gen:exports`) ## To test - `grep -r "ui-patterns/admonition" --include='*.ts*'` → no hits - `pnpm test:case-hazards` → passes - `pnpm typecheck` → all 15 tasks green - `pnpm --filter studio run lint:ratchet` → passes - `pnpm --filter ui-patterns vitest run src/Admonition` → 11 tests pass <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Standardized Admonition component imports across the application and documentation. * Improved compatibility with case-sensitive environments by using the canonical component path. * Removed the legacy Admonition import entry point. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.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/Admonition'
|
|
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 />} />
|
|
}
|