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 integrations page (#4041)

Steven Tey99a525164d03
diff --git a/apps/web/app/api/integrations/route.ts b/apps/web/app/api/integrations/route.ts
index 2c7fca008f..3c3a677264 100644
--- a/apps/web/app/api/integrations/route.ts
+++ b/apps/web/app/api/integrations/route.ts
@@ -1,4 +1,5 @@
import { withWorkspace } from "@/lib/auth";
+import { installedIntegrationSchema } from "@/lib/zod/schemas/integration";
import { prisma } from "@dub/prisma";
import { NextResponse } from "next/server";
@@ -10,9 +11,11 @@ export const GET = withWorkspace(
id: true,
name: true,
slug: true,
+ verified: true,
+ projectId: true,
+ logo: true,
},
where: {
- verified: true,
installations: {
some: {
project: {
@@ -21,9 +24,16 @@ export const GET = withWorkspace(
},
},
},
+ orderBy: {
+ createdAt: "desc",
+ },
});
- return NextResponse.json(integrations);
+ return NextResponse.json(
+ integrations.map((integration) =>
+ installedIntegrationSchema.parse(integration),
+ ),
+ );
},
{
requiredPermissions: ["workspaces.read"],
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/customers/[customerId]/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/customers/[customerId]/page.tsx
index 6a11985812..4c9eacca0d 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/customers/[customerId]/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/customers/[customerId]/page.tsx
@@ -12,6 +12,4 @@ export default async function ProgramCustomerPage({
}
redirect(`/${slug}/program/customers/${customerId}/sales`);
-
- return null;
}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page.tsx
index 2c697ba25a..0cd8e18938 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page.tsx
@@ -59,7 +59,7 @@ export default function WorkspaceInvoices() {
>
Billing
</Link>
- <ChevronRight className="text-content-muted size-4" />
+ <ChevronRight className="text-content-muted size-2.5 shrink-0 [&_*]:stroke-2" />
<h1>Invoices</h1>
</div>
}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page.tsx
index bbdce70cdf..46c6fffdc3 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page.tsx
@@ -131,7 +131,7 @@ export default function WorkspaceBillingUpgradePage() {
>
Billing
</Link>
- <ChevronRight className="text-content-muted size-4" />
+ <ChevronRight className="text-content-muted size-2.5 shrink-0 [&_*]:stroke-2" />
<h1>Plans</h1>
</div>
}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/[integrationSlug]/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/[integrationSlug]/layout.tsx
new file mode 100644
index 0000000000..ff5dccdfd6
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/[integrationSlug]/layout.tsx
@@ -0,0 +1,31 @@
+import { prisma } from "@dub/prisma";
+import { ReactNode } from "react";
+import { SetIntegrationsSubpageTitle } from "../integrations-subpage-context";
+
+export default async function IntegrationSlugLayout({
+ params,
+ children,
+}: {
+ params: Promise<{ integrationSlug: string }>;
+ children: ReactNode;
+}) {
+ const { integrationSlug } = await params;
+
+ const integration = await prisma.integration.findUnique({
+ where: {
+ slug: integrationSlug,
+ },
+ select: {
+ name: true,
+ },
+ });
+
+ return (
+ <>
+ {integration ? (
+ <SetIntegrationsSubpageTitle title={integration.name} />
+ ) : null}
+ {children}
+ </>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/[integrationSlug]/manage/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/[integrationSlug]/manage/page.tsx
index a4f3597991..858fe64723 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/[integrationSlug]/manage/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/[integrationSlug]/manage/page.tsx
@@ -1,5 +1,4 @@
import AddEditIntegrationForm from "@/ui/oauth-apps/add-edit-integration-form";
-import { BackLink } from "@/ui/shared/back-link";
import { prisma } from "@dub/prisma";
import { MaxWidthWrapper } from "@dub/ui";
import { redirect } from "next/navigation";
@@ -25,10 +24,6 @@ export default async function IntegrationManagePage(props: {
}
return (
<MaxWidthWrapper className="grid max-w-screen-lg gap-8">
- <BackLink href={`/${params.slug}/settings/integrations`}>
- Back to integrations
- </BackLink>
-
<AddEditIntegrationForm
integration={{
...integration,
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/[integrationSlug]/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/[integrationSlug]/page-client.tsx
index d9173a8767..adc446637d 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/[integrationSlug]/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/[integrationSlug]/page-client.tsx
@@ -13,9 +13,9 @@ import { ZapierSettings } from "@/lib/integrations/zapier/ui/settings";
import { getPlanCapabilities } from "@/lib/plan-capabilities";
import useWorkspace from "@/lib/swr/use-workspace";
import { InstalledIntegrationInfoProps } from "@/lib/types";
+import { IntegrationStatusBadge } from "@/ui/integrations/integration-status-badge";
import { IntegrationLogo } from "@/ui/integrations/integration-logo";
import { useUninstallIntegrationModal } from "@/ui/modals/uninstall-integration-modal";
-import { BackLink } from "@/ui/shared/back-link";
import { CheckCircleFill, ThreeDots } from "@/ui/shared/icons";
import { Markdown } from "@/ui/shared/markdown";
import { UserAvatar } from "@/ui/users/user-avatar";
@@ -37,9 +37,7 @@ import {
useMediaQuery,
} from "@dub/ui";
import {
- CircleWarning,
ConnectedDots,
- DubCraftedShield,
Flask,
Globe,
OfficeBuilding,
@@ -159,7 +157,6 @@ export default function IntegrationPageClient({
return (
<MaxWidthWrapper className="grid max-w-screen-lg grid-cols-1 gap-6">
{integration.installed && <UninstallIntegrationModal />}
- <BackLink href={`/${slug}/settings/integrations`}>Integrations</BackLink>
<div className="flex justify-between gap-8">
<div className="flex flex-col gap-3 sm:flex-row sm:items-center">
<IntegrationLogo
@@ -169,22 +166,13 @@ export default function IntegrationPageClient({
/>
<div>
<div className="flex items-center gap-1.5">
- <h1 className="text-base font-semibold leading-none text-neutral-800">
+ <div className="text-base font-semibold leading-none text-neutral-800">
{integration.name}
- </h1>
- {integration.projectId === DUB_WORKSPACE_ID ? (
- <Tooltip content="This is an official integration built and maintained by Dub">
- <div>
- <DubCraftedShield className="size-4 -translate-y-px" />
- </div>
- </Tooltip>
- ) : !integration.verified ? (
- <Tooltip content="Dub hasn't verified this integration. Install it at your own risk.">
- <div>
- <CircleWarning className="size-5 text-neutral-500" invert />
- </div>
- </Tooltip>
- ) : null}
+ </div>
+ <IntegrationStatusBadge
+ projectId={integration.projectId}
+ verified={integration.verified}
+ />
</div>
<p className="mt-1 text-[0.8125rem] leading-snug text-neutral-600">
{integration.description}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/enabled-integrations.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/enabled-integrations.tsx
index dddc6a63e4..2f6225d748 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/enabled-integrations.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/enabled-integrations.tsx
@@ -2,31 +2,23 @@
import useIntegrations from "@/lib/swr/use-integrations";
import useWorkspace from "@/lib/swr/use-workspace";
+import { InstalledIntegrationProps } from "@/lib/types";
import { IntegrationLogo } from "@/ui/integrations/integration-logo";
-import { Integration } from "@dub/prisma/client";
+import { IntegrationStatusBadge } from "@/ui/integrations/integration-status-badge";
import { cn } from "@dub/utils";
import { ChevronRight } from "lucide-react";
import { AnimatePresence, motion } from "motion/react";
import Link from "next/link";
import { useSearchParams } from "next/navigation";
-import { IntegrationsWithInstallations } from "./integrations-list";
-export function EnabledIntegrations({
- integrations,
-}: {
- integrations: IntegrationsWithInstallations;
-}) {
+export function EnabledIntegrations() {
const searchParams = useSearchParams();
const search = searchParams.get("search");
const { slug } = useWorkspace();
const { integrations: activeIntegrations } = useIntegrations();
- const enabledIntegrations = integrations.filter((i) =>
- activeIntegrations?.some((ai) => ai.id === i.id),
- );
-
- return enabledIntegrations?.length ? (
+ return activeIntegrations?.length ? (
<AnimatePresence initial={false}>
{!search && (
<motion.div
@@ -44,11 +36,11 @@ export function EnabledIntegrations({
href={`/${slug}/settings/integrations/enabled`}
className="font-medium leading-4 text-neutral-500 transition-colors duration-100 hover:text-neutral-700"
>
- View all ({enabledIntegrations.length})
+ View all ({activeIntegrations.length})
</Link>
</div>
<ul className="mt-4 divide-y divide-neutral-200 overflow-hidden rounded-lg border border-neutral-200">
- {enabledIntegrations.slice(0, 3).map((integration) => (
+ {activeIntegrations.slice(0, 3).map((integration) => (
<li key={integration.id}>
<IntegrationRow integration={integration} />
</li>
@@ -60,7 +52,11 @@ export function EnabledIntegrations({
) : null;
}
-function IntegrationRow({ integration }: { integration: Integration }) {
+function IntegrationRow({
+ integration,
+}: {
+ integration: InstalledIntegrationProps;
+}) {
const { slug } = useWorkspace();
return (
@@ -73,12 +69,16 @@ function IntegrationRow({ integration }: { integration: Integration }) {
>
<div className="flex items-center justify-between gap-3">
<IntegrationLogo
- src={integration.logo}
+ src={integration.logo ?? null}
alt={`Logo for ${integration.name}`}
/>
- <span className="text-sm font-medium text-neutral-800">
+ <span className="flex items-center gap-1.5 text-sm font-medium text-neutral-800">
{integration.name}
+ <IntegrationStatusBadge
+ projectId={integration.projectId}
+ verified={integration.verified}
+ />
</span>
</div>
<ChevronRight className="size-4 text-neutral-400 transition-all duration-150 group-hover:translate-x-0.5 group-hover:text-neutral-600" />
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/enabled/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/enabled/page.tsx
index 87762d15c0..6d46a2d5b1 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/enabled/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/enabled/page.tsx
@@ -1,10 +1,10 @@
import { IntegrationLogo } from "@/ui/integrations/integration-logo";
+import { IntegrationStatusBadge } from "@/ui/integrations/integration-status-badge";
import LayoutLoader from "@/ui/layout/layout-loader";
import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";
-import { BackLink } from "@/ui/shared/back-link";
import { UserAvatar } from "@/ui/users/user-avatar";
import { prisma } from "@dub/prisma";
-import { ConnectedDots } from "@dub/ui";
+import { ConnectedDots, TimestampTooltip } from "@dub/ui";
import { cn, formatDate, truncate } from "@dub/utils";
import { ChevronRight } from "lucide-react";
import Link from "next/link";
@@ -17,25 +17,17 @@ export default async function EnabledIntegrationsPage(props: {
params: Promise<{ slug: string }>;
}) {
const params = await props.params;
+
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={<LayoutLoader />}>
- <EnabledIntegrationsPageRSC slug={params.slug} />
- </Suspense>
- </div>
+ <Suspense fallback={<LayoutLoader />}>
+ <EnabledIntegrationsPageRSC slug={params.slug} />
+ </Suspense>
);
}
async function EnabledIntegrationsPageRSC({ slug }: { slug: string }) {
const integrations = await prisma.integration.findMany({
where: {
- verified: true,
installations: {
some: {
project: {
@@ -44,14 +36,21 @@ async function EnabledIntegrationsPageRSC({ slug }: { slug: string }) {
},
},
},
- include: {
+ select: {
+ id: true,
+ name: true,
+ slug: true,
+ projectId: true,
+ verified: true,
+ logo: true,
installations: {
where: {
project: {
slug,
},
},
- include: {
+ select: {
+ createdAt: true,
user: {
select: {
id: true,
@@ -61,6 +60,9 @@ async function EnabledIntegrationsPageRSC({ slug }: { slug: string }) {
},
},
},
+ orderBy: {
+ createdAt: "desc",
+ },
},
},
});
@@ -104,9 +106,13 @@ async function EnabledIntegrationsPageRSC({ slug }: { slug: string }) {
className="size-10"
/>
- <div className="flex min-w-0 flex-col">
- <span className="text-sm font-medium text-neutral-800">
+ <div className="flex min-w-0 flex-col gap-0.5">
+ <span className="flex items-center gap-1.5 text-sm font-medium text-neutral-800">
{integration.name}
+ <IntegrationStatusBadge
+ projectId={integration.projectId}
+ verified={integration.verified}
+ />
</span>
{installation && (
<span className="truncate text-[0.8125rem] text-neutral-500">
@@ -123,10 +129,18 @@ async function EnabledIntegrationsPageRSC({ slug }: { slug: string }) {
</span>{" "}
</>
) : null}
- {formatDate(installation.createdAt, {
- month: "short",
- year: "numeric",
- })}
+ •{" "}
+ <TimestampTooltip
+ timestamp={installation.createdAt}
+ rows={["local", "utc", "unix"]}
+ >
+ <span className="text-xs text-neutral-500 underline decoration-neutral-300 decoration-dotted underline-offset-2">
+ {formatDate(installation.createdAt, {
+ month: "short",
+ year: "numeric",
+ })}
+ </span>
+ </TimestampTooltip>
</span>
)}
</div>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/integrations-cards.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/integrations-cards.tsx
index dddacf3d5b..b7577043f6 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/integrations-cards.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/integrations-cards.tsx
@@ -81,11 +81,7 @@ export function IntegrationsCards({
</h2>
<div className="mt-4 grid gap-3 sm:grid-cols-2 xl:grid-cols-3">
{groupedIntegrations[category]!.map((integration) => (
- <IntegrationCard
- key={integration.id}
- {...integration}
- installations={integration._count.installations}
- />
+ <IntegrationCard key={integration.id} {...integration} />
))}
</div>
</div>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/integrations-layout-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/integrations-layout-client.tsx
new file mode 100644
index 0000000000..8ea4f907df
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/integrations-layout-client.tsx
@@ -0,0 +1,123 @@
+"use client";
+
+import { PageContent } from "@/ui/layout/page-content";
+import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
+import { ChevronRight } from "@dub/ui";
+import { capitalize } from "@dub/utils";
+import Link from "next/link";
+import { useParams, usePathname } from "next/navigation";
+import { Fragment, ReactNode } from "react";
+import {
+ IntegrationsSubpageProvider,
+ useIntegrationsSubpage,
+} from "./integrations-subpage-context";
+
+function IntegrationsBreadcrumb({
+ segments,
+}: {
+ segments: { label: string; href?: string }[];
+}) {
+ const { slug } = useParams<{ slug: string }>();
+
+ return (
+ <div className="flex items-center gap-1.5">
+ <Link
+ href={`/${slug}/settings/integrations`}
+ className="transition-all duration-150 hover:text-neutral-600 active:scale-95"
+ >
+ Integrations
+ </Link>
+ {segments.map((segment, index) => (
+ <Fragment key={`${segment.label}-${index}`}>
+ <ChevronRight className="text-content-muted size-2.5 shrink-0 [&_*]:stroke-2" />
+ {segment.href ? (
+ <Link
+ href={segment.href}
+ className="transition-all duration-150 hover:text-neutral-600 active:scale-95"
+ >
+ {segment.label}
+ </Link>
+ ) : (
+ <h1>{segment.label}</h1>
+ )}
+ </Fragment>
+ ))}
+ </div>
+ );
+}
+
+function IntegrationsLayoutContent({ children }: { children: ReactNode }) {
+ const { slug, integrationSlug } = useParams<{
+ slug: string;
+ integrationSlug?: string;
+ }>();
+ const pathname = usePathname();
+ const { title: subpageTitle } = useIntegrationsSubpage();
+
+ const isEnabledPage = pathname?.endsWith("/integrations/enabled");
+ const isManagePage = pathname?.endsWith("/manage");
+ const isIntegrationPage =
+ Boolean(integrationSlug) &&
+ integrationSlug !== "enabled" &&
+ integrationSlug !== "new";
+
+ const integrationName =
+ subpageTitle ||
+ (integrationSlug ? capitalize(integrationSlug.replace(/-/g, " ")) : null);
+
+ let title: ReactNode = "Integrations";
+ let hideTitleInfo = false;
+
+ if (isEnabledPage) {
+ title = <IntegrationsBreadcrumb segments={[{ label: "Enabled" }]} />;
+ hideTitleInfo = true;
+ } else if (isIntegrationPage && integrationName) {
+ title = (
+ <IntegrationsBreadcrumb
+ segments={
+ isManagePage
+ ? [
+ {
+ label: integrationName,
+ href: `/${slug}/settings/integrations/${integrationSlug}`,
+ },
+ { label: "Manage" },
+ ]
+ : [{ label: integrationName }]
+ }
+ />
+ );
+ hideTitleInfo = true;
+ }
+
+ return (
+ <PageContent
+ title={title}
+ titleInfo={
+ hideTitleInfo
+ ? undefined
+ : {
+ title:
+ "Use Dub with your existing favorite tools with our seamless integrations.",
+ href: "https://dub.co/integrations",
+ }
+ }
+ >
+ <PageWidthWrapper className="max-w-[800px] pb-20">
+ {children}
+ </PageWidthWrapper>
+ </PageContent>
+ );
+}
+
+export function IntegrationsLayoutClient({
+ children,
+}: {
+ children: ReactNode;
+}) {
+ return (
+ <IntegrationsSubpageProvider>
+ <IntegrationsLayoutContent>{children}</IntegrationsLayoutContent>
+ </IntegrationsSubpageProvider>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/integrations-list.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/integrations-list.tsx
index 22b473d635..5b4b4e6891 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/integrations-list.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/integrations-list.tsx
@@ -51,7 +51,7 @@ async function IntegrationsListRSC() {
return (
<>
<SearchBoxPersisted debounceTimeoutMs={250} />
- <EnabledIntegrations integrations={integrations} />
+ <EnabledIntegrations />
<FeaturedIntegrations integrations={integrations} />
<IntegrationsCards integrations={integrations} />
</>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/integrations-subpage-context.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/integrations-subpage-context.tsx
new file mode 100644
index 0000000000..23b268f72a
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/integrations-subpage-context.tsx
@@ -0,0 +1,46 @@
+"use client";
+
+import { createContext, ReactNode, useContext, useEffect, useState } from "react";
+
+const IntegrationsSubpageContext = createContext<{
+ title: string | null;
+ setTitle: (title: string | null) => void;
+} | null>(null);
+
+export function IntegrationsSubpageProvider({
+ children,
+}: {
+ children: ReactNode;
+}) {
+ const [title, setTitle] = useState<string | null>(null);
+
+ return (
+ <IntegrationsSubpageContext.Provider value={{ title, setTitle }}>
+ {children}
+ </IntegrationsSubpageContext.Provider>
+ );
+}
+
+export function useIntegrationsSubpage() {
+ const context = useContext(IntegrationsSubpageContext);
+
+ if (!context) {
+ throw new Error(
+ "useIntegrationsSubpage must be used within IntegrationsSubpageProvider",
+ );
+ }
+
+ return context;
+}
+
+export function SetIntegrationsSubpageTitle({ title }: { title: string }) {
+ const { setTitle } = useIntegrationsSubpage();
+
+ useEffect(() => {
+ setTitle(title);
+
+ return () => setTitle(null);
+ }, [title, setTitle]);
+
+ return null;
+}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/layout.tsx
index d1b3e9e778..23c782f24e 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/layout.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/layout.tsx
@@ -1,24 +1,10 @@
-import { PageContent } from "@/ui/layout/page-content";
-import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
import { ReactNode } from "react";
+import { IntegrationsLayoutClient } from "./integrations-layout-client";
export default function IntegrationsLayout({
children,
}: {
children: ReactNode;
}) {
- return (
- <PageContent
- title="Integrations"
- titleInfo={{
- title:
- "Use Dub with your existing favorite tools with our seamless integrations.",
- href: "https://d.to/integrations",
- }}
- >
- <PageWidthWrapper className="max-w-[800px] pb-20">
- {children}
- </PageWidthWrapper>
- </PageContent>
- );
+ return <IntegrationsLayoutClient>{children}</IntegrationsLayoutClient>;
}
diff --git a/apps/web/lib/swr/use-integrations.ts b/apps/web/lib/swr/use-integrations.ts
index 90cf0b7576..7cfea34039 100644
--- a/apps/web/lib/swr/use-integrations.ts
+++ b/apps/web/lib/swr/use-integrations.ts
@@ -8,14 +8,16 @@ export default function useIntegrations({
}: { swrOpts?: SWRConfiguration } = {}) {
const { id } = useWorkspace();
- const { data: integrations, error } = useSWR<
- Pick<InstalledIntegrationProps, "id" | "name" | "slug">[]
- >(`/api/integrations?workspaceId=${id}`, fetcher, {
- dedupingInterval: 20000,
- revalidateOnFocus: false,
- keepPreviousData: true,
- ...swrOpts,
- });
+ const { data: integrations, error } = useSWR<InstalledIntegrationProps[]>(
+ `/api/integrations?workspaceId=${id}`,
+ fetcher,
+ {
+ dedupingInterval: 20000,
+ revalidateOnFocus: false,
+ keepPreviousData: true,
+ ...swrOpts,
+ },
+ );
return {
integrations,
diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.ts
index 977536375b..e98c675b9f 100644
--- a/apps/web/lib/types.ts
+++ b/apps/web/lib/types.ts
@@ -122,7 +122,10 @@ import {
GroupWithFormDataSchema,
PartnerGroupDefaultLinkSchema,
} from "./zod/schemas/groups";
-import { integrationSchema } from "./zod/schemas/integration";
+import {
+ installedIntegrationSchema,
+ integrationSchema,
+} from "./zod/schemas/integration";
import { InvoiceSchema } from "./zod/schemas/invoices";
import {
leadEventResponseSchema,
@@ -431,22 +434,9 @@ export type NewOrExistingIntegration = Omit<
id?: string;
};
-export type InstalledIntegrationProps = Pick<
- IntegrationProps,
- | "id"
- | "projectId"
- | "slug"
- | "logo"
- | "name"
- | "developer"
- | "description"
- | "verified"
- | "comingSoon"
- | "guideUrl"
-> & {
- installations: number;
- installed?: boolean;
-};
+export type InstalledIntegrationProps = z.infer<
+ typeof installedIntegrationSchema
+>;
export type InstalledIntegrationInfoProps = Pick<
IntegrationProps,
diff --git a/apps/web/lib/zod/schemas/integration.ts b/apps/web/lib/zod/schemas/integration.ts
index 177de53c90..0d60875046 100644
--- a/apps/web/lib/zod/schemas/integration.ts
+++ b/apps/web/lib/zod/schemas/integration.ts
@@ -22,6 +22,18 @@ export const integrationSchema = z.object({
installations: z.number().default(0),
});
+export const installedIntegrationSchema = integrationSchema.pick({
+ id: true,
+ projectId: true,
+ name: true,
+ slug: true,
+ description: true,
+ logo: true,
+ verified: true,
+ guideUrl: true,
+ comingSoon: true,
+});
+
export const createIntegrationSchema = z.object({
name: z.string().min(1).max(100),
slug: z.string().min(1).max(100),
diff --git a/apps/web/ui/integrations/integration-card.tsx b/apps/web/ui/integrations/integration-card.tsx
index b2bc7f533c..0510d706c0 100644
--- a/apps/web/ui/integrations/integration-card.tsx
+++ b/apps/web/ui/integrations/integration-card.tsx
@@ -3,13 +3,12 @@
import useIntegrations from "@/lib/swr/use-integrations";
import useWorkspace from "@/lib/swr/use-workspace";
import { InstalledIntegrationProps } from "@/lib/types";
-import { DubCraftedShield, Tooltip } from "@dub/ui";
-import { DUB_WORKSPACE_ID } from "@dub/utils";
import { cn } from "@dub/utils/src";
import { ArrowUpRight } from "lucide-react";
import Link from "next/link";
import { HTMLProps, PropsWithChildren } from "react";
import { IntegrationLogo } from "./integration-logo";
+import { IntegrationStatusBadge } from "./integration-status-badge";
export default function IntegrationCard(
integration: InstalledIntegrationProps,
@@ -18,8 +17,6 @@ export default function IntegrationCard(
const installed = activeIntegrations?.some((i) => i.id === integration.id);
- const dubCrafted = integration.projectId === DUB_WORKSPACE_ID;
-
return (
<Wrapper integration={integration}>
{installed ? (
@@ -37,13 +34,10 @@ export default function IntegrationCard(
<IntegrationLogo src={integration.logo ?? null} alt={integration.name} />
<h3 className="mt-4 flex items-center gap-1.5 text-sm font-semibold text-neutral-800">
{integration.name}
- {dubCrafted && (
- <Tooltip content="This is an official integration built and maintained by Dub">
- <div>
- <DubCraftedShield className="size-4 -translate-y-px" />
- </div>
- </Tooltip>
- )}
+ <IntegrationStatusBadge
+ projectId={integration.projectId}
+ verified={integration.verified}
+ />
</h3>
<p className="mt-2 line-clamp-3 text-sm text-neutral-600">
{integration.description}
diff --git a/apps/web/ui/integrations/integration-status-badge.tsx b/apps/web/ui/integrations/integration-status-badge.tsx
new file mode 100644
index 0000000000..496ec55c92
--- /dev/null
+++ b/apps/web/ui/integrations/integration-status-badge.tsx
@@ -0,0 +1,51 @@
+import { BadgeCheck2Fill, DubCraftedShield, Tooltip } from "@dub/ui";
+import { CircleWarning } from "@dub/ui/icons";
+import { DUB_WORKSPACE_ID } from "@dub/utils";
+
+export function IntegrationStatusBadge({
+ projectId,
+ verified,
+}: {
+ projectId: string;
+ verified: boolean;
+}) {
+ if (projectId === DUB_WORKSPACE_ID) {
+ return (
+ <Tooltip content="This is an official integration built and maintained by Dub">
+ <span>
+ <DubCraftedShield className="size-4 shrink-0 -translate-y-px" />
+ </span>
+ </Tooltip>
+ );
+ }
+
+ if (verified) {
+ return (
+ <Tooltip
+ content={
+ <div className="flex max-w-xs items-start gap-1.5 p-3">
+ <BadgeCheck2Fill className="mt-0.5 size-5 shrink-0 text-blue-500" />
+ <div className="flex flex-col gap-1">
+ <span className="text-sm font-semibold text-neutral-900">
+ Verified Integration
+ </span>
+ <span className="text-sm font-normal text-neutral-600">
+ This integration has been verified by Dub.
+ </span>
+ </div>
+ </div>
+ }
+ >
+ <BadgeCheck2Fill className="size-4 shrink-0 text-blue-500" />
+ </Tooltip>
+ );
+ }
+
+ return (
+ <Tooltip content="Dub hasn't verified this integration. Install it at your own risk.">
+ <span>
+ <CircleWarning className="size-4 shrink-0 text-neutral-500" invert />
+ </span>
+ </Tooltip>
+ );
+}