Skip to content

Commit 0802ebb

Browse files
authored
refactor: check insights feature flag in higher stack (#21341)
1 parent 29b8d68 commit 0802ebb

4 files changed

Lines changed: 10 additions & 30 deletions

File tree

apps/web/app/(use-page-wrapper)/insights/layout.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
import { getTranslate } from "app/_utils";
2+
import { notFound } from "next/navigation";
23

34
import { CTA_CONTAINER_CLASS_NAME } from "@calcom/features/data-table/lib/utils";
5+
import { FeaturesRepository } from "@calcom/features/flags/features.repository";
46
import Shell from "@calcom/features/shell/Shell";
57

68
import UpgradeTipWrapper from "./UpgradeTipWrapper";
79

810
export default async function InsightsLayout({ children }: { children: React.ReactNode }) {
11+
const featuresRepository = new FeaturesRepository();
12+
const insightsEnabled = await featuresRepository.checkIfFeatureIsEnabledGlobally("insights");
13+
14+
if (!insightsEnabled) {
15+
return notFound();
16+
}
17+
918
const t = await getTranslate();
19+
1020
return (
1121
<>
1222
<div>
Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import { _generateMetadata } from "app/_utils";
2-
import { notFound } from "next/navigation";
3-
4-
import { FeaturesRepository } from "@calcom/features/flags/features.repository";
52

63
import InsightsPage from "~/insights/insights-view";
74

@@ -15,12 +12,5 @@ export const generateMetadata = async () =>
1512
);
1613

1714
export default async function Page() {
18-
const featuresRepository = new FeaturesRepository();
19-
const insightsEnabled = await featuresRepository.checkIfFeatureIsEnabledGlobally("insights");
20-
21-
if (!insightsEnabled) {
22-
return notFound();
23-
}
24-
2515
return <InsightsPage />;
2616
}
Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import { _generateMetadata } from "app/_utils";
2-
import { notFound } from "next/navigation";
3-
4-
import { FeaturesRepository } from "@calcom/features/flags/features.repository";
52

63
import InsightsVirtualQueuesPage from "~/insights/insights-virtual-queues-view";
74

@@ -15,12 +12,5 @@ export const generateMetadata = async () =>
1512
);
1613

1714
export default async function Page() {
18-
const featuresRepository = new FeaturesRepository();
19-
const insightsEnabled = await featuresRepository.checkIfFeatureIsEnabledGlobally("insights");
20-
21-
if (!insightsEnabled) {
22-
return notFound();
23-
}
24-
2515
return <InsightsVirtualQueuesPage />;
2616
}
Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import { _generateMetadata } from "app/_utils";
2-
import { notFound } from "next/navigation";
3-
4-
import { FeaturesRepository } from "@calcom/features/flags/features.repository";
52

63
import InsightsRoutingPage from "~/insights/insights-routing-view";
74

@@ -15,12 +12,5 @@ export const generateMetadata = async () =>
1512
);
1613

1714
export default async function Page() {
18-
const featuresRepository = new FeaturesRepository();
19-
const insightsEnabled = await featuresRepository.checkIfFeatureIsEnabledGlobally("insights");
20-
21-
if (!insightsEnabled) {
22-
return notFound();
23-
}
24-
2515
return <InsightsRoutingPage />;
2616
}

0 commit comments

Comments
 (0)