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.

Fix the OAuth Applications pages layout

Kiran K99a0bcdf9c6a
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/create-oauth-app-button.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/create-oauth-app-button.tsx
new file mode 100644
index 0000000000..e7b2f3be60
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/create-oauth-app-button.tsx
@@ -0,0 +1,31 @@
+"use client";
+
+import { clientAccessCheck } from "@/lib/api/tokens/permissions";
+import useWorkspace from "@/lib/swr/use-workspace";
+import { Button } from "@dub/ui";
+import Link from "next/link";
+import { usePathname } from "next/navigation";
+
+export default function CreateOAuthAppButton() {
+ const pathname = usePathname();
+ const { slug, role } = useWorkspace();
+
+ const { error: permissionsError } = clientAccessCheck({
+ action: "webhooks.write",
+ role: role,
+ });
+
+ if (!pathname.endsWith("/settings/oauth-apps")) {
+ return null;
+ }
+
+ return (
+ <Link href={`/${slug}/settings/oauth-apps/new`}>
+ <Button
+ className="flex h-10 items-center justify-center whitespace-nowrap rounded-lg border px-4 text-sm"
+ text="Create OAuth App"
+ disabledTooltip={permissionsError}
+ />
+ </Link>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/layout.tsx
new file mode 100644
index 0000000000..d3d7765f75
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/layout.tsx
@@ -0,0 +1,20 @@
+import { PageContent } from "@/ui/layout/page-content";
+import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
+import { ReactNode } from "react";
+import CreateOAuthAppButton from "./create-oauth-app-button";
+
+export default function OAuthAppsLayout({ children }: { children: ReactNode }) {
+ return (
+ <PageContent
+ title="OAuth Applications"
+ titleInfo={{
+ title:
+ "Learn how to use OAuth applications to build integrations with Dub.",
+ href: "https://dub.co/docs/integrations/quickstart",
+ }}
+ controls={<CreateOAuthAppButton />}
+ >
+ <PageWidthWrapper>{children}</PageWidthWrapper>
+ </PageContent>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/new/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/new/page-client.tsx
index 5dd8151bc6..86707ac025 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/new/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/new/page-client.tsx
@@ -3,7 +3,6 @@
import { clientAccessCheck } from "@/lib/api/tokens/permissions";
import useWorkspace from "@/lib/swr/use-workspace";
import AddOAuthAppForm from "@/ui/oauth-apps/add-edit-app-form";
-import { BackLink } from "@/ui/shared/back-link";
import { MaxWidthWrapper } from "@dub/ui";
import { redirect } from "next/navigation";
@@ -20,16 +19,8 @@ export default function NewOAuthAppPageClient() {
}
return (
- <>
- <MaxWidthWrapper className="grid max-w-screen-lg gap-8">
- <BackLink href={`/${slug}/settings/oauth-apps`}>
- Back to OAuth Apps
- </BackLink>
- </MaxWidthWrapper>
-
- <MaxWidthWrapper className="max-w-screen-lg space-y-6">
- <AddOAuthAppForm oAuthApp={null} />
- </MaxWidthWrapper>
- </>
+ <MaxWidthWrapper className="max-w-screen-lg space-y-6">
+ <AddOAuthAppForm oAuthApp={null} />
+ </MaxWidthWrapper>
);
}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/page.tsx
index 6935d38698..7353b17202 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/page.tsx
@@ -1,20 +1,5 @@
-import { PageContent } from "@/ui/layout/page-content";
-import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
import OAuthAppsPageClient from "./page-client";
export default async function OAuthAppsPage() {
- return (
- <PageContent
- title="OAuth Applications"
- titleInfo={{
- title:
- "Learn how to use OAuth applications to build integrations with Dub.",
- href: "https://dub.co/docs/integrations/quickstart",
- }}
- >
- <PageWidthWrapper>
- <OAuthAppsPageClient />
- </PageWidthWrapper>
- </PageContent>
- );
+ return <OAuthAppsPageClient />;
}