mirror of
https://github.com/supabase/supabase.git
synced 2026-06-18 21:54:18 +08: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](8adadc61f5/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'
|
|
}
|