| 1 | /** biome-ignore-all lint/suspicious/noArrayIndexKey: skeleton rows have no id */ |
| 2 | import { Webhook } |
| 3 | import Link from "next/link |
| 4 | import { Fragment } |
| 5 | |
| 6 | import { Badge } |
| 7 | import { Button } |
| 8 | import { Card } |
| 9 | import { |
| 10 | Empty, |
| 11 | EmptyDescription, |
| 12 | EmptyHeader, |
| 13 | EmptyMedia, |
| 14 | EmptyTitle, |
| 15 | } from "@/components/ui/empty"; |
| 16 | import { |
| 17 | Item, |
| 18 | ItemActions, |
| 19 | ItemContent, |
| 20 | ItemDescription, |
| 21 | ItemGroup, |
| 22 | ItemMedia, |
| 23 | ItemSeparator, |
| 24 | ItemTitle, |
| 25 | } from "@/components/ui/item"; |
| 26 | import { Skeleton } |
| 27 | import type { components |
| 28 | import { type WebhookOwner, |
| 29 | |
| 30 | export function WebhookList({ |
| 31 | owner, |
| 32 | webhooks, |
| 33 | }: { |
| 34 | owner: WebhookOwner |
| 35 | webhooks: components |
| 36 | }) { |
| 37 | return ( |
| 38 | <section> |
| 39 | <h2 className="mb-3 text-sm font-semibold |
| 40 | Webhooks |
| 41 | <span className="ml-2 font-normal text-muted-foreground tabular-nums |
| 42 | {webhooks.length} |
| 43 | </span> |
| 44 | </h2> |
| 45 | <Card className=" |
| 46 | {webhooks.length === |
| 47 | <Empty className=" |
| 48 | <EmptyHeader> |
| 49 | <EmptyMedia variant=" |
| 50 | <Webhook /> |
| 51 | </EmptyMedia> |
| 52 | <EmptyTitle>No webhooks yet</EmptyTitle |
| 53 | <EmptyDescription> |
| 54 | Ghost POSTs a signed JSON payload to each URL you add here |
| 55 | whenever one of its events happens. |
| 56 | </EmptyDescription> |
| 57 | </EmptyHeader> |
| 58 | </Empty> |
| 59 | ) : ( |
| 60 | <ItemGroup className=" |
| 61 | {webhooks.map(( |
| 62 | <Fragment key={ |
| 63 | {index > 0 |
| 64 | <Item className=" |
| 65 | <ItemMedia variant=" |
| 66 | <Webhook /> |
| 67 | </ItemMedia> |
| 68 | <ItemContent className=" |
| 69 | <ItemTitle className=" |
| 70 | <span className="truncate font-mono text-xs |
| 71 | {webhook.url} |
| 72 | </span> |
| 73 | {!webhook.active |
| 74 | <Badge variant=" |
| 75 | )} |
| 76 | </ItemTitle> |
| 77 | <ItemDescription className=" |
| 78 | {webhook.disabledReason ?? |
| 79 | `${webhook.events. |
| 80 | </ItemDescription> |
| 81 | </ItemContent> |
| 82 | <ItemActions> |
| 83 | <Button size=" |
| 84 | <Link href={ |
| 85 | Edit |
| 86 | </Link> |
| 87 | </Button> |
| 88 | </ItemActions> |
| 89 | </Item> |
| 90 | </Fragment> |
| 91 | ))} |
| 92 | </ItemGroup> |
| 93 | )} |
| 94 | </Card> |
| 95 | </section> |
| 96 | ); |
| 97 | } |
| 98 | |
| 99 | export function WebhookListSkeleton() |
| 100 | return ( |
| 101 | <section> |
| 102 | <Skeleton className=" |
| 103 | <ul className="divide-y rounded-lg border |
| 104 | {Array.from({ |
| 105 | <li key={index |
| 106 | <Skeleton className=" |
| 107 | <div className="flex flex-1 flex-col gap-1.5 |
| 108 | <Skeleton className=" |
| 109 | <Skeleton className=" |
| 110 | </div> |
| 111 | <Skeleton className=" |
| 112 | </li> |
| 113 | ))} |
| 114 | </ul> |
| 115 | </section> |
| 116 | ); |
| 117 | } |