mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
## What kind of change does this PR introduce? Impending feature addition. Resolves DEPR-340. ## What is the current behavior? We don’t have any platform webhook support. ## What is the new behavior? This puts the scaffolding for platform webhooks **behind a feature flag**. The content is currently UI-only (with mock data and a [temporary tracking file](https://github.com/supabase/supabase/blob/8adadc61f57c70b686a0f5f05e9f7f05837e0466/apps/studio/components/interfaces/Platform/Webhooks/DEPR-340-backend-integration-tracker.md)). Merging this in lets us work incrementally from here on.
32 lines
976 B
TypeScript
32 lines
976 B
TypeScript
import type { WebhookDeliveryStatus } from './PlatformWebhooks.types'
|
|
|
|
export const statusBadgeVariant: Record<
|
|
WebhookDeliveryStatus,
|
|
'default' | 'success' | 'destructive'
|
|
> = {
|
|
pending: 'default',
|
|
success: 'success',
|
|
failure: 'destructive',
|
|
skipped: 'default',
|
|
}
|
|
|
|
export const formatDate = (value: string) =>
|
|
new Intl.DateTimeFormat(undefined, { dateStyle: 'medium', timeStyle: 'short' }).format(
|
|
new Date(value)
|
|
)
|
|
|
|
export const formatEvents = (eventTypes: string[]) =>
|
|
eventTypes.includes('*') ? 'All events (*)' : eventTypes.join(', ')
|
|
|
|
export const formatDeliveryStatus = (status: WebhookDeliveryStatus) =>
|
|
`${status.charAt(0).toUpperCase()}${status.slice(1)}`
|
|
|
|
export const responseCodeBadgeVariant = (
|
|
responseCode?: number
|
|
): 'default' | 'success' | 'destructive' => {
|
|
if (!responseCode) return 'default'
|
|
if (responseCode >= 200 && responseCode < 300) return 'success'
|
|
if (responseCode >= 400) return 'destructive'
|
|
return 'default'
|
|
}
|