Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Merge branch 'main' into webhooks-ga

Kiran K0020cf94dddc
diff --cc apps/web/lib/zod/schemas/webhooks.ts
index 1f6c58281a,c2e52419da..e39451f161
--- a/apps/web/lib/zod/schemas/webhooks.ts
+++ b/apps/web/lib/zod/schemas/webhooks.ts
@@@ -12,9 -14,9 +12,9 @@@ export const webhookSchema = z.object(
});
export const createWebhookSchema = z.object({
- name: z.string().min(1).max(30),
+ name: z.string().min(1).max(40),
url: z.string().url().max(190),
- secret: z.string().startsWith(WEBHOOK_SECRET_PREFIX),
+ secret: z.string().optional(),
triggers: z.array(z.enum(WEBHOOK_TRIGGERS)),
linkIds: z.array(z.string()).optional(),
});
diff --cc apps/web/ui/webhooks/webhook-header.tsx
index 6e8a455e78,6e89521489..bbd45435ce
--- a/apps/web/ui/webhooks/webhook-header.tsx
+++ b/apps/web/ui/webhooks/webhook-header.tsx
@@@ -13,8 -14,7 +15,8 @@@ import
TokenAvatar,
} from "@dub/ui";
import { fetcher } from "@dub/utils";
- import { ChevronLeft, CircleCheck, CircleX, Send, Trash } from "lucide-react";
-import { ChevronLeft, Send, Trash } from "lucide-react";
++import { ChevronLeft, CircleX, Send, Trash } from "lucide-react";
+import { useAction } from "next-safe-action/hooks";
import Link from "next/link";
import { notFound, useRouter, useSelectedLayoutSegment } from "next/navigation";
import { useState } from "react";
@@@ -134,32 -119,20 +144,46 @@@ export default function WebhookHeader(
}}
/>
+ <Button
+ text={
+ webhook?.disabledAt ? "Enable webhook" : "Disable webhook"
+ }
+ variant="outline"
+ icon={
+ webhook?.disabledAt ? (
+ <CircleX className="size-4" />
+ ) : (
+ <CircleCheck className="size-4" />
+ )
+ }
+ className="h-9 justify-start px-2"
+ onClick={async () => {
+ execute({
+ webhookId,
+ workspaceId: workspaceId!,
+ });
+
+ setOpenPopover(false);
+ }}
+ disabled={!!permissionsError}
+ disabledTooltip={permissionsError}
+ loading={isExecuting}
+ />
+
+ <Button
+ text="Copy Webhook ID"
+ variant="outline"
+ icon={
+ copiedWebhookId ? (
+ <CircleCheck className="h-4 w-4" />
+ ) : (
+ <Copy className="h-4 w-4" />
+ )
+ }
+ className="h-9 justify-start px-2"
+ onClick={() => copyWebhookId()}
+ />
+
<Button
text="Delete webhook"
variant="danger-outline"