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.

improve webhook selectors

Steven Teyea791d6dd866
diff --git a/apps/web/ui/modals/link-builder/webhook-select.tsx b/apps/web/ui/modals/link-builder/webhook-select.tsx
index f339889af4..fa520bdab9 100644
--- a/apps/web/ui/modals/link-builder/webhook-select.tsx
+++ b/apps/web/ui/modals/link-builder/webhook-select.tsx
@@ -90,7 +90,7 @@ const NoWebhooksFound = () => {
<div>
<Button
className="mt-1 h-8"
- onClick={() => router.push(`/${slug}/settings/webhooks`)}
+ onClick={() => window.open(`/${slug}/settings/webhooks`, "_blank")}
text="Add webhook"
/>
</div>
diff --git a/apps/web/ui/webhooks/webhook-header.tsx b/apps/web/ui/webhooks/webhook-header.tsx
index addf1a1032..08a3ad13f8 100644
--- a/apps/web/ui/webhooks/webhook-header.tsx
+++ b/apps/web/ui/webhooks/webhook-header.tsx
@@ -51,11 +51,10 @@ export default function WebhookHeader({ webhookId }: { webhookId: string }) {
const { execute, isExecuting } = useAction(enableOrDisableWebhook, {
onSuccess: async ({ data }) => {
+ await mutate();
toast.success(
data?.disabledAt ? "Webhook disabled." : "Webhook enabled.",
);
-
- await mutate();
},
onError: ({ error }) => {
toast.error(error.serverError);
@@ -129,69 +128,83 @@ export default function WebhookHeader({ webhookId }: { webhookId: string }) {
<Popover
content={
- <div className="grid w-screen gap-px p-2 sm:w-48">
- <Button
- text="Send test event"
- variant="outline"
- icon={<Send className="size-4" />}
- className="h-9 justify-start px-2"
- onClick={() => {
- setOpenPopover(false);
- setShowSendTestWebhookModal(true);
- }}
- />
-
- <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={disabled}
- disabledTooltip={disabledTooltip}
- 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"
- icon={<Trash className="size-4" />}
- className="h-9 justify-start px-2"
- onClick={() => {
- setDeleteWebhookModal(true);
- }}
- disabled={disabled}
- disabledTooltip={disabledTooltip}
- />
+ <div className="w-screen sm:w-48">
+ <div className="grid gap-px p-2">
+ <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="Send test event"
+ variant="outline"
+ icon={<Send className="size-4" />}
+ className="h-9 justify-start px-2"
+ onClick={() => {
+ setOpenPopover(false);
+ setShowSendTestWebhookModal(true);
+ }}
+ />
+ </div>
+
+ <div className="h-px w-full bg-gray-200" />
+
+ <div className="grid gap-px p-2">
+ <Button
+ text={
+ webhook?.disabledAt ? "Enable webhook" : "Disable webhook"
+ }
+ variant="outline"
+ icon={
+ webhook?.disabledAt ? (
+ <CircleCheck className="size-4" />
+ ) : (
+ <CircleX className="size-4" />
+ )
+ }
+ className="h-9 justify-start px-2"
+ onClick={async () => {
+ if (
+ !confirm(
+ `Are you sure you want to ${
+ webhook?.disabledAt ? "enable" : "disable"
+ } this webhook?`,
+ )
+ ) {
+ return;
+ }
+
+ execute({
+ webhookId,
+ workspaceId: workspaceId!,
+ });
+ }}
+ disabled={disabled}
+ disabledTooltip={disabledTooltip}
+ loading={isExecuting}
+ />
+
+ <Button
+ text="Delete webhook"
+ variant="danger-outline"
+ icon={<Trash className="size-4" />}
+ className="h-9 justify-start px-2"
+ onClick={() => {
+ setDeleteWebhookModal(true);
+ }}
+ disabled={disabled}
+ disabledTooltip={disabledTooltip}
+ />
+ </div>
</div>
}
align="end"