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.

dynamically show integrations & oauth settings pages

Steven Teycfa469f9e4bf
diff --git a/apps/web/app/api/workspaces/[idOrSlug]/route.ts b/apps/web/app/api/workspaces/[idOrSlug]/route.ts
index f24e89d45d..a67e67e65b 100644
--- a/apps/web/app/api/workspaces/[idOrSlug]/route.ts
+++ b/apps/web/app/api/workspaces/[idOrSlug]/route.ts
@@ -27,7 +27,9 @@ export const GET = withWorkspace(
...workspace,
id: `ws_${workspace.id}`,
domains,
- flags: await getFeatureFlags(workspace.id),
+ flags: await getFeatureFlags({
+ workspaceId: workspace.id,
+ }),
}),
{ headers },
);
@@ -74,7 +76,9 @@ export const PATCH = withWorkspace(
WorkspaceSchema.parse({
...response,
id: `ws_${response.id}`,
- flags: await getFeatureFlags(workspace.id),
+ flags: await getFeatureFlags({
+ workspaceId: response.id,
+ }),
}),
);
} catch (error) {
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/page-client.tsx
index 3f82aba13c..870d638459 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/page-client.tsx
@@ -13,7 +13,7 @@ export default function IntegrationsPageClient({
const { slug, flags } = useWorkspace();
if (!flags?.integrations) {
- redirect(`/${slug}`);
+ redirect(`/${slug}/settings`);
}
return (
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/page-header.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/page-header.tsx
index e60afb5ff1..76c93bed5d 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/page-header.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/page-header.tsx
@@ -10,7 +10,7 @@ export default function IntegrationsPageHeader() {
const { slug, flags } = useWorkspace();
if (!flags?.integrations) {
- redirect(`/${slug}`);
+ redirect(`/${slug}/settings`);
}
return (
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/layout.tsx
index ccfd27e080..13101b080d 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/layout.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/layout.tsx
@@ -2,8 +2,8 @@ import { getFeatureFlags } from "@/lib/edge-config";
import SettingsLayout from "@/ui/layout/settings-layout";
import {
CircleInfo,
- Cube,
- Dots,
+ ConnectedDots,
+ CubeSettings,
Gear2,
Globe,
Key,
@@ -21,8 +21,7 @@ export default async function WorkspaceSettingsLayout({
children: ReactNode;
params: { slug: string };
}) {
- const { slug } = params;
- const flags = await getFeatureFlags(slug);
+ const flags = await getFeatureFlags({ workspaceSlug: params.slug });
const tabs = [
// Workspace Settings
@@ -54,8 +53,14 @@ export default async function WorkspaceSettingsLayout({
icon: Users6,
segment: "people",
},
- ...(flags?.integrations
- ? [{ name: "Integrations", icon: Dots, segment: "integrations" }]
+ ...(flags.integrations
+ ? [
+ {
+ name: "Integrations",
+ icon: ConnectedDots,
+ segment: "integrations",
+ },
+ ]
: []),
{
name: "Security",
@@ -74,8 +79,8 @@ export default async function WorkspaceSettingsLayout({
icon: Key,
segment: "tokens",
},
- ...(flags?.integrations
- ? [{ name: "OAuth Apps", icon: Cube, segment: "oauth-apps" }]
+ ...(flags.integrations
+ ? [{ name: "OAuth Apps", icon: CubeSettings, segment: "oauth-apps" }]
: []),
],
},
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 74c13f6975..8c6ab90a1e 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
@@ -11,7 +11,7 @@ export default function NewOAuthAppPageClient() {
const { slug, flags } = useWorkspace();
if (!flags?.integrations) {
- redirect(`/${slug}`);
+ redirect(`/${slug}/settings`);
}
return (
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/page-client.tsx
index 9f76beb2cd..78ada97427 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/page-client.tsx
@@ -16,7 +16,7 @@ export default function OAuthAppsPageClient() {
const { slug, id: workspaceId, flags } = useWorkspace();
if (!flags?.integrations) {
- redirect(`/${slug}`);
+ redirect(`/${slug}/settings`);
}
const { data: oAuthApps, isLoading } = useSWR<OAuthAppProps[]>(
diff --git a/apps/web/lib/api/links/process-link.ts b/apps/web/lib/api/links/process-link.ts
index a32a701012..15d0d97142 100644
--- a/apps/web/lib/api/links/process-link.ts
+++ b/apps/web/lib/api/links/process-link.ts
@@ -185,7 +185,9 @@ export async function processLink<T extends Record<string, any>>({
code: "forbidden",
};
}
- const flags = await getFeatureFlags(workspace.id);
+ const flags = await getFeatureFlags({
+ workspaceId: workspace.id,
+ });
if (!flags.dublink) {
return {
link: payload,
@@ -247,7 +249,7 @@ export async function processLink<T extends Record<string, any>>({
}
if (trackConversion && workspace) {
- const flags = await getFeatureFlags(workspace?.id);
+ const flags = await getFeatureFlags({ workspaceId: workspace.id });
if (!flags.conversions) {
return {
diff --git a/apps/web/lib/auth/workspace-edge.ts b/apps/web/lib/auth/workspace-edge.ts
index 402be4db7a..42e640a3ca 100644
--- a/apps/web/lib/auth/workspace-edge.ts
+++ b/apps/web/lib/auth/workspace-edge.ts
@@ -292,7 +292,7 @@ export const withWorkspaceEdge = (
// beta feature checks
if (featureFlag) {
- const flags = await getFeatureFlags(workspace.id);
+ const flags = await getFeatureFlags({ workspaceId: workspace.id });
if (!flags[featureFlag]) {
throw new DubApiError({
diff --git a/apps/web/lib/auth/workspace.ts b/apps/web/lib/auth/workspace.ts
index 0ba6171031..f5e928cf7f 100644
--- a/apps/web/lib/auth/workspace.ts
+++ b/apps/web/lib/auth/workspace.ts
@@ -318,7 +318,7 @@ export const withWorkspace = (
// beta feature checks
if (featureFlag) {
- const flags = await getFeatureFlags(workspace.id);
+ const flags = await getFeatureFlags({ workspaceId: workspace.id });
if (!flags[featureFlag]) {
throw new DubApiError({
diff --git a/apps/web/lib/edge-config/get-feature-flags.ts b/apps/web/lib/edge-config/get-feature-flags.ts
index 81dcbfe6cd..f4ec738738 100644
--- a/apps/web/lib/edge-config/get-feature-flags.ts
+++ b/apps/web/lib/edge-config/get-feature-flags.ts
@@ -3,17 +3,25 @@ import { BetaFeatures } from "../types";
type BetaFeaturesRecord = Record<BetaFeatures, string[]>;
-export const getFeatureFlags = async (workspaceId: string) => {
+export const getFeatureFlags = async ({
+ workspaceId,
+ workspaceSlug,
+}: {
+ workspaceId?: string;
+ workspaceSlug?: string;
+}) => {
+ if (workspaceId) {
+ workspaceId = workspaceId.startsWith("ws_")
+ ? workspaceId
+ : `ws_${workspaceId}`;
+ }
+
const workspaceFeatures: Record<BetaFeatures, boolean> = {
conversions: false,
integrations: false,
dublink: false,
};
- workspaceId = workspaceId.startsWith("ws_")
- ? workspaceId
- : `ws_${workspaceId}`;
-
if (!process.env.NEXT_PUBLIC_IS_DUB || !process.env.EDGE_CONFIG) {
return workspaceFeatures;
}
@@ -27,8 +35,13 @@ export const getFeatureFlags = async (workspaceId: string) => {
}
if (betaFeatures) {
- for (const [featureFlag, workspaceIds] of Object.entries(betaFeatures)) {
- if (workspaceIds.includes(workspaceId)) {
+ for (const [featureFlag, workspaceIdsOrSlugs] of Object.entries(
+ betaFeatures,
+ )) {
+ if (
+ (workspaceId && workspaceIdsOrSlugs.includes(workspaceId)) ||
+ (workspaceSlug && workspaceIdsOrSlugs.includes(workspaceSlug))
+ ) {
workspaceFeatures[featureFlag] = true;
}
}
diff --git a/packages/ui/src/icons/nucleo/connected-dots.tsx b/packages/ui/src/icons/nucleo/connected-dots.tsx
new file mode 100644
index 0000000000..1574ac2deb
--- /dev/null
+++ b/packages/ui/src/icons/nucleo/connected-dots.tsx
@@ -0,0 +1,73 @@
+import { SVGProps } from "react";
+
+export function ConnectedDots(props: SVGProps<SVGSVGElement>) {
+ return (
+ <svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg" {...props}>
+ <g fill="currentColor">
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="7.954"
+ x2="5.047"
+ y1="5.988"
+ y2="11.511"
+ />
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="10.046"
+ x2="12.953"
+ y1="5.988"
+ y2="11.511"
+ />
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="6.25"
+ x2="11.75"
+ y1="13.25"
+ y2="13.25"
+ />
+ <circle
+ cx="9"
+ cy="4"
+ fill="none"
+ r="2.25"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <circle
+ cx="14"
+ cy="13.5"
+ fill="none"
+ r="2.25"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <circle
+ cx="4"
+ cy="13.5"
+ fill="none"
+ r="2.25"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ </g>
+ </svg>
+ );
+}
diff --git a/packages/ui/src/icons/nucleo/cube-settings.tsx b/packages/ui/src/icons/nucleo/cube-settings.tsx
new file mode 100644
index 0000000000..479e7eeecb
--- /dev/null
+++ b/packages/ui/src/icons/nucleo/cube-settings.tsx
@@ -0,0 +1,135 @@
+import { SVGProps } from "react";
+
+export function CubeSettings(props: SVGProps<SVGSVGElement>) {
+ return (
+ <svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg" {...props}>
+ <g fill="currentColor">
+ <polyline
+ fill="none"
+ points="13.983 5.53 8 9 2.017 5.53"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="8"
+ x2="8"
+ y1="15.938"
+ y2="9"
+ />
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="13.75"
+ x2="13.75"
+ y1="10.5"
+ y2="11.75"
+ />
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="16.048"
+ x2="15.164"
+ y1="11.452"
+ y2="12.336"
+ />
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="17"
+ x2="15.75"
+ y1="13.75"
+ y2="13.75"
+ />
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="16.048"
+ x2="15.164"
+ y1="16.048"
+ y2="15.164"
+ />
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="13.75"
+ x2="13.75"
+ y1="17"
+ y2="15.75"
+ />
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="11.452"
+ x2="12.336"
+ y1="16.048"
+ y2="15.164"
+ />
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="10.5"
+ x2="11.75"
+ y1="13.75"
+ y2="13.75"
+ />
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="11.452"
+ x2="12.336"
+ y1="11.452"
+ y2="12.336"
+ />
+ <circle
+ cx="13.75"
+ cy="13.75"
+ fill="none"
+ r="1.75"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M14.25,8.06v-1.533c0-.713-.38-1.372-.997-1.73l-4.25-2.465c-.621-.36-1.386-.36-2.007,0L2.747,4.797c-.617,.358-.997,1.017-.997,1.73v4.946c0,.713,.38,1.372,.997,1.73l4.25,2.465c.603,.35,1.341,.353,1.951,.023"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ </g>
+ </svg>
+ );
+}
diff --git a/packages/ui/src/icons/nucleo/index.ts b/packages/ui/src/icons/nucleo/index.ts
index 0d0a6201e5..84a0359028 100644
--- a/packages/ui/src/icons/nucleo/index.ts
+++ b/packages/ui/src/icons/nucleo/index.ts
@@ -17,8 +17,10 @@ export * from "./circle-warning";
export * from "./circle-xmark";
export * from "./cloud-upload";
export * from "./code";
+export * from "./connected-dots";
export * from "./crosshairs";
export * from "./cube";
+export * from "./cube-settings";
export * from "./cursor-rays";
export * from "./desktop";
export * from "./dots";