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.

add webhooklayout

Steven Tey5b4ab82596c3
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/[webhookId]/edit/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/[webhookId]/edit/page-client.tsx
index 539f85ce05..d415e57a8b 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/[webhookId]/edit/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/[webhookId]/edit/page-client.tsx
@@ -4,7 +4,6 @@ import { clientAccessCheck } from "@/lib/api/tokens/permissions";
import useWorkspace from "@/lib/swr/use-workspace";
import { WebhookProps } from "@/lib/types";
import AddEditWebhookForm from "@/ui/webhooks/add-edit-webhook-form";
-import WebhookHeader from "@/ui/webhooks/webhook-header";
import { MaxWidthWrapper } from "@dub/ui";
import { fetcher } from "@dub/utils";
import { notFound, redirect } from "next/navigation";
@@ -36,11 +35,8 @@ export default function UpdateWebhookPageClient({
}
return (
- <>
- <WebhookHeader webhookId={webhookId} page="edit" />
- <MaxWidthWrapper className="max-w-screen-lg space-y-6">
- {webhook && <AddEditWebhookForm webhook={webhook} />}
- </MaxWidthWrapper>
- </>
+ <MaxWidthWrapper className="max-w-screen-lg space-y-6">
+ {webhook && <AddEditWebhookForm webhook={webhook} />}
+ </MaxWidthWrapper>
);
}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/[webhookId]/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/[webhookId]/layout.tsx
new file mode 100644
index 0000000000..67c771e1d2
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/[webhookId]/layout.tsx
@@ -0,0 +1,17 @@
+import WebhookHeader from "@/ui/webhooks/webhook-header";
+import { ReactNode } from "react";
+
+export default function WebhookLayout({
+ params,
+ children,
+}: {
+ params: { webhookId: string };
+ children: ReactNode;
+}) {
+ return (
+ <>
+ <WebhookHeader webhookId={params.webhookId} />
+ {children}
+ </>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/[webhookId]/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/[webhookId]/page-client.tsx
index b95783279e..d8317c7bd5 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/[webhookId]/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/[webhookId]/page-client.tsx
@@ -6,7 +6,6 @@ import { WebhookEventProps } from "@/lib/types";
import { WebhookEventListSkeleton } from "@/ui/webhooks/loading-events-skelton";
import { NoEventsPlaceholder } from "@/ui/webhooks/no-events-placeholder";
import { WebhookEventList } from "@/ui/webhooks/webhook-events";
-import WebhookHeader from "@/ui/webhooks/webhook-header";
import { MaxWidthWrapper } from "@dub/ui";
import { fetcher } from "@dub/utils";
import { redirect } from "next/navigation";
@@ -38,17 +37,14 @@ export default function WebhookLogsPageClient({
);
return (
- <>
- <WebhookHeader webhookId={webhookId} page="events" />
- <MaxWidthWrapper className="max-w-screen-lg space-y-6">
- {isLoading ? (
- <WebhookEventListSkeleton />
- ) : events && events.length === 0 ? (
- <NoEventsPlaceholder />
- ) : (
- <WebhookEventList events={events || []} />
- )}
- </MaxWidthWrapper>
- </>
+ <MaxWidthWrapper className="max-w-screen-lg space-y-6">
+ {isLoading ? (
+ <WebhookEventListSkeleton />
+ ) : events && events.length === 0 ? (
+ <NoEventsPlaceholder />
+ ) : (
+ <WebhookEventList events={events || []} />
+ )}
+ </MaxWidthWrapper>
);
}
diff --git a/apps/web/ui/webhooks/webhook-header.tsx b/apps/web/ui/webhooks/webhook-header.tsx
index 954081ef6c..1250f5af3a 100644
--- a/apps/web/ui/webhooks/webhook-header.tsx
+++ b/apps/web/ui/webhooks/webhook-header.tsx
@@ -4,25 +4,29 @@ import { clientAccessCheck } from "@/lib/api/tokens/permissions";
import useWorkspace from "@/lib/swr/use-workspace";
import { WebhookProps } from "@/lib/types";
import { ThreeDots } from "@/ui/shared/icons";
-import { Button, MaxWidthWrapper, Popover, TokenAvatar } from "@dub/ui";
+import {
+ Button,
+ MaxWidthWrapper,
+ Popover,
+ TabSelect,
+ TokenAvatar,
+} from "@dub/ui";
import { fetcher } from "@dub/utils";
-import { ChevronLeft, Edit3, FileStack, Send, Trash } from "lucide-react";
+import { ChevronLeft, Send, Trash } from "lucide-react";
import Link from "next/link";
-import { notFound, useRouter } from "next/navigation";
+import { notFound, useRouter, useSelectedLayoutSegment } from "next/navigation";
import { useState } from "react";
import useSWR from "swr";
import { useDeleteWebhookModal } from "../modals/delete-webhook-modal";
import { useSendTestWebhookModal } from "../modals/send-test-webhook-modal";
-export default function WebhookHeader({
- webhookId,
- page,
-}: {
- webhookId: string;
- page: "edit" | "events";
-}) {
+export default function WebhookHeader({ webhookId }: { webhookId: string }) {
const router = useRouter();
const { slug, id: workspaceId, role } = useWorkspace();
+
+ const selectedLayoutSegment = useSelectedLayoutSegment();
+ const page = selectedLayoutSegment === null ? "" : selectedLayoutSegment;
+
const [openPopover, setOpenPopover] = useState(false);
const { data: webhook, isLoading } = useSWR<WebhookProps>(
@@ -86,38 +90,10 @@ export default function WebhookHeader({
<Popover
content={
<div className="grid w-screen gap-px p-2 sm:w-48">
- {page === "events" && (
- <Button
- text="Update webhook"
- variant="outline"
- icon={<Edit3 className="h-4 w-4" />}
- className="h-9 justify-start px-2 font-medium"
- onClick={async () => {
- setOpenPopover(false);
- router.push(
- `/${slug}/settings/webhooks/${webhookId}/edit`,
- );
- }}
- />
- )}
-
- {page === "edit" && (
- <Button
- text="Webhook logs"
- variant="outline"
- icon={<FileStack className="h-4 w-4" />}
- className="h-9 justify-start px-2 font-medium"
- onClick={async () => {
- setOpenPopover(false);
- router.push(`/${slug}/settings/webhooks/${webhookId}`);
- }}
- />
- )}
-
<Button
text="Send test event"
variant="outline"
- icon={<Send className="h-4 w-4" />}
+ icon={<Send className="size-4" />}
className="h-9 justify-start px-2"
onClick={() => {
setOpenPopover(false);
@@ -128,7 +104,7 @@ export default function WebhookHeader({
<Button
text="Delete webhook"
variant="danger-outline"
- icon={<Trash className="h-4 w-4" />}
+ icon={<Trash className="size-4" />}
className="h-9 justify-start px-2"
onClick={() => {
setDeleteWebhookModal(true);
@@ -151,6 +127,16 @@ export default function WebhookHeader({
/>
</Popover>
</div>
+ <TabSelect
+ options={[
+ { id: "", label: "Webhook Logs" },
+ { id: "edit", label: "Update Details" },
+ ]}
+ selected={page}
+ onSelect={(id: "" | "edit") => {
+ router.push(`/${slug}/settings/webhooks/${webhookId}/${id}`);
+ }}
+ />
</MaxWidthWrapper>
</>
);