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 "Enabled Integrations" page

Tim Wilsonc8e3bf034f9a
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/enabled/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/enabled/page.tsx
new file mode 100644
index 0000000000..3323d93003
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/enabled/page.tsx
@@ -0,0 +1,111 @@
+import { IntegrationLogo } from "@/ui/integrations/integration-logo";
+import { BackLink } from "@/ui/shared/back-link";
+import { prisma } from "@dub/prisma";
+import { Avatar } from "@dub/ui";
+import { cn, formatDate, truncate } from "@dub/utils";
+import { ChevronRight } from "lucide-react";
+import Link from "next/link";
+import { Suspense } from "react";
+
+export default function EnabledIntegrationsPage({
+ params,
+}: {
+ params: { slug: string };
+}) {
+ return (
+ <div className="mx-auto flex w-full max-w-screen-md flex-col gap-8">
+ <BackLink href={`/${params.slug}/settings/integrations`}>
+ Integrations
+ </BackLink>
+ <h1 className="text-2xl font-semibold tracking-tight text-black">
+ Enabled Integrations
+ </h1>
+ <Suspense fallback={<div>Loading...</div>}>
+ <EnabledIntegrationsPageRSC slug={params.slug} />
+ </Suspense>
+ </div>
+ );
+}
+
+async function EnabledIntegrationsPageRSC({ slug }: { slug: string }) {
+ const integrations = await prisma.integration.findMany({
+ where: {
+ verified: true,
+ installations: {
+ some: {
+ project: {
+ slug,
+ },
+ },
+ },
+ },
+ include: {
+ installations: {
+ include: {
+ user: true,
+ },
+ },
+ },
+ });
+
+ return (
+ <ul className="flex flex-col gap-2">
+ {integrations.map((integration) => {
+ const installation = integration.installations?.[0];
+ const installerName =
+ installation?.user?.name || installation?.user?.email;
+
+ return (
+ <li key={integration.id}>
+ <Link
+ href={`/${slug}/settings/integrations/${integration?.slug}`}
+ className={cn(
+ "group flex items-center justify-between rounded-lg border border-neutral-200 p-3 pr-5 text-sm",
+ "transition-colors duration-75 hover:bg-neutral-50",
+ )}
+ >
+ <div className="flex min-w-0 items-center justify-between gap-3">
+ <IntegrationLogo
+ src={integration.logo}
+ alt={`Logo for ${integration.name}`}
+ />
+
+ <div className="flex min-w-0 flex-col gap-1">
+ <span className="text-sm font-medium text-neutral-800">
+ {integration.name}
+ </span>
+ {installation && (
+ <span className="truncate text-[0.8125rem] text-neutral-500">
+ Enabled{" "}
+ {installerName ? (
+ <>
+ by{" "}
+ <Avatar
+ user={installation.user}
+ className="inline-block size-3 -translate-y-0.5 border-0"
+ />{" "}
+ <span className="text-neutral-600">
+ {truncate(installerName, 24)}
+ </span>{" "}
+ </>
+ ) : null}
+ {formatDate(installation.createdAt, {
+ month: "short",
+ year:
+ installation.createdAt.getFullYear() ===
+ new Date().getFullYear()
+ ? undefined
+ : "numeric",
+ })}
+ </span>
+ )}
+ </div>
+ </div>
+ <ChevronRight className="size-4 shrink-0 text-neutral-400 transition-all duration-150 group-hover:translate-x-0.5 group-hover:text-neutral-600" />
+ </Link>
+ </li>
+ );
+ })}
+ </ul>
+ );
+}
diff --git a/apps/web/ui/integrations/integration-logo.tsx b/apps/web/ui/integrations/integration-logo.tsx
index 9bf5e051f9..84b80625f1 100644
--- a/apps/web/ui/integrations/integration-logo.tsx
+++ b/apps/web/ui/integrations/integration-logo.tsx
@@ -12,7 +12,7 @@ export const IntegrationLogo = memo(
alt: string;
className?: string;
}) => (
- <div className="relative w-fit">
+ <div className="relative w-fit shrink-0">
{src ? (
<>
<BlurImage
diff --git a/apps/web/ui/layout/settings-layout.tsx b/apps/web/ui/layout/settings-layout.tsx
index 2df1ab018a..5175838e48 100644
--- a/apps/web/ui/layout/settings-layout.tsx
+++ b/apps/web/ui/layout/settings-layout.tsx
@@ -6,7 +6,7 @@ export default function SettingsLayout({ children }: PropsWithChildren) {
return (
<PageContent>
<div className="relative min-h-[calc(100vh-16px)]">
- <MaxWidthWrapper className="grid gap-5 pb-10 pt-3">
+ <MaxWidthWrapper className="grid grid-cols-1 gap-5 pb-10 pt-3">
{children}
</MaxWidthWrapper>
</div>