Skip to content

Commit e00333b

Browse files
authored
chore(dashboard): put create new docs site behind feature flag (#4842)
1 parent ddac6e2 commit e00333b

File tree

6 files changed

+55
-20
lines changed

6 files changed

+55
-20
lines changed

packages/fern-dashboard/src/app/[orgName]/(wizard)/layout.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import { redirect } from "next/navigation";
12
import { ThemeProvider } from "next-themes";
2-
3+
import { getCurrentSession } from "@/app/services/auth0/getCurrentSession";
4+
import { PosthogFeatureFlag } from "@/components/posthog/feature-flags/flags";
5+
import { isFeatureFlagEnabledForUser } from "@/components/posthog/feature-flags/server-side";
36
import { ServerSidePylonSetup } from "@/components/pylon/ServerSidePylonSetup";
4-
57
import type { Auth0OrgName } from "../../services/auth0/types";
68
import { OrgNameProvider } from "../context/OrgNameContext";
79

@@ -14,6 +16,21 @@ export default async function WizardLayout({
1416
}>) {
1517
const { orgName } = await params;
1618

19+
const session = await getCurrentSession();
20+
if (session == null) {
21+
redirect("/");
22+
}
23+
24+
const isCreateDocsNewSiteEnabled = await isFeatureFlagEnabledForUser(
25+
PosthogFeatureFlag.ENABLE_CREATE_DOCS_NEW_SITE,
26+
session.user.sub,
27+
orgName
28+
);
29+
30+
if (!isCreateDocsNewSiteEnabled) {
31+
redirect(`/${orgName}/docs`);
32+
}
33+
1734
return (
1835
<>
1936
<ServerSidePylonSetup />

packages/fern-dashboard/src/components/docs-page/DocsZeroState.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import type { User } from "@auth0/nextjs-auth0/types";
2-
import { PlusIcon } from "lucide-react";
3-
import Link from "next/link";
4-
import { Button } from "../ui/button";
52
import { DocsZeroStateButton } from "./DocsZeroStateButton";
63
import { DocsZeroStateImage } from "./DocsZeroStateImage";
74

packages/fern-dashboard/src/components/docs-page/DocsZeroStateButton.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
"use client";
2-
31
import { PlusIcon } from "lucide-react";
42
import Link from "next/link";
5-
import { useOrgNameFromPathname } from "@/utils/useOrgNameFromPathname";
63
import { Button } from "../ui/button";
74

85
export function DocsZeroStateButton() {
9-
const orgName = useOrgNameFromPathname();
106
return (
117
<Button variant="default" asChild>
12-
<Link href={`/${orgName}/docs/new`} className="flex items-center gap-2" rel="noopener">
8+
<Link
9+
href="https://buildwithfern.com/learn/docs/getting-started/quickstart"
10+
target="_blank"
11+
className="flex items-center gap-2"
12+
rel="noopener"
13+
>
1314
<PlusIcon className="h-4 w-4" />
1415
Create your first docs site
1516
</Link>

packages/fern-dashboard/src/components/navbar/DocsNavbarItems.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export async function DocsNavbarItems({ orgName }: { orgName: Auth0OrgName }) {
3939
firstDocsSite != null ? `/docs/${constructDocsUrlParam(getDocsSiteUrl(firstDocsSite))}` : undefined
4040
}
4141
/>
42-
<DocsNavbarSubItems docsSites={docsSites} />
42+
<DocsNavbarSubItems docsSites={docsSites} orgName={orgName} />
4343
</>
4444
);
4545
}

packages/fern-dashboard/src/components/navbar/DocsNavbarSubItems.tsx

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
1-
"use client";
1+
import "server-only";
22

33
import type { FdrAPI } from "@fern-api/fdr-sdk/client/types";
44

55
import { PlusIcon } from "lucide-react";
66
import Link from "next/link";
7-
7+
import { getCurrentSession } from "@/app/services/auth0/getCurrentSession";
8+
import type { Auth0OrgName } from "@/app/services/auth0/types";
89
import { constructDocsUrlParam } from "@/utils/constructDocsUrlParam";
910
import { getDocsSiteUrl } from "@/utils/getDocsSiteUrl";
10-
import { useOrgNameFromPathname } from "@/utils/useOrgNameFromPathname";
1111
import { cn } from "@/utils/utils";
12-
12+
import { PosthogFeatureFlag } from "../posthog/feature-flags/flags";
13+
import { FeatureFlaggedServerSide, isFeatureFlagEnabledForUser } from "../posthog/feature-flags/server-side";
1314
import { NavbarSubItem } from "./NavbarSubItem";
1415

15-
export function DocsNavbarSubItems({ docsSites }: { docsSites: FdrAPI.dashboard.DocsSite[] }) {
16-
const orgName = useOrgNameFromPathname();
17-
16+
export async function DocsNavbarSubItems({
17+
docsSites,
18+
orgName
19+
}: {
20+
docsSites: FdrAPI.dashboard.DocsSite[];
21+
orgName: Auth0OrgName;
22+
}) {
23+
const session = await getCurrentSession();
24+
if (session == null) {
25+
return null;
26+
}
27+
const isCreateDocsNewSiteEnabled = await isFeatureFlagEnabledForUser(
28+
PosthogFeatureFlag.ENABLE_CREATE_DOCS_NEW_SITE,
29+
session?.user.sub,
30+
orgName
31+
);
1832
return (
1933
<>
2034
{docsSites.map((docsSite) => {
@@ -25,12 +39,17 @@ export function DocsNavbarSubItems({ docsSites }: { docsSites: FdrAPI.dashboard.
2539
);
2640
})}
2741
<Link
28-
href={`/${orgName}/docs/new`}
42+
href={
43+
isCreateDocsNewSiteEnabled
44+
? `/${orgName}/docs/new`
45+
: "https://buildwithfern.com/learn/docs/getting-started/quickstart"
46+
}
2947
className={cn(
3048
"hidden md:flex",
3149
"flex-1 flex-row gap-2 text-sm transition",
3250
"hover:text-primary text-gray-900"
3351
)}
52+
target={isCreateDocsNewSiteEnabled ? "_self" : "_blank"}
3453
>
3554
<div className="flex w-5 shrink-0 justify-center">
3655
<div className="w-px bg-gray-700" />

packages/fern-dashboard/src/components/posthog/feature-flags/flags.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export const PosthogFeatureFlag = {
88
ENABLE_DOCS_ASK_FERN_BILLING: "dashboard-enable-docs-ask-fern-billing",
99
ENABLE_VE_BRANCH_PRS: "dashboard-enable-ve-branch-prs",
1010
ENABLE_WEB_ANALYTICS_TAB: "dashboard-enable-web-analytics-tab",
11-
ENABLE_INCIDENTS_PAGE: "dashboard-enable-incidents-page"
11+
ENABLE_INCIDENTS_PAGE: "dashboard-enable-incidents-page",
12+
ENABLE_CREATE_DOCS_NEW_SITE: "dashboard-create-new-docs-site"
1213
} as const;
1314

1415
export type PosthogFeatureFlag = (typeof PosthogFeatureFlag)[keyof typeof PosthogFeatureFlag];

0 commit comments

Comments
 (0)