Skip to content

Commit fdcf23f

Browse files
committed
Show or not insights page
1 parent a1a9952 commit fdcf23f

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

site/src/components/TemplateLayout/TemplateLayout.tsx

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
import { useQuery } from "@tanstack/react-query"
1616
import { AuthorizationRequest } from "api/typesGenerated"
1717
import { ErrorAlert } from "components/Alert/ErrorAlert"
18+
import { useDashboard } from "components/Dashboard/DashboardProvider"
1819

1920
const templatePermissions = (
2021
templateId: string,
@@ -71,6 +72,12 @@ export const TemplateLayout: FC<{ children?: JSX.Element }> = ({
7172
queryKey: ["template", templateName],
7273
queryFn: () => fetchTemplate(orgId, templateName),
7374
})
75+
const dashboard = useDashboard()
76+
const hasInsightsEnabled =
77+
dashboard.experiments.includes("template_insights_page") ||
78+
process.env.NODE_ENV === "development"
79+
const shouldShowInsights =
80+
hasInsightsEnabled && data?.permissions?.canUpdateTemplate
7481

7582
if (error) {
7683
return (
@@ -157,17 +164,19 @@ export const TemplateLayout: FC<{ children?: JSX.Element }> = ({
157164
>
158165
Embed
159166
</NavLink>
160-
<NavLink
161-
to={`/templates/${templateName}/insights`}
162-
className={({ isActive }) =>
163-
combineClasses([
164-
styles.tabItem,
165-
isActive ? styles.tabItemActive : undefined,
166-
])
167-
}
168-
>
169-
Insights
170-
</NavLink>
167+
{shouldShowInsights && (
168+
<NavLink
169+
to={`/templates/${templateName}/insights`}
170+
className={({ isActive }) =>
171+
combineClasses([
172+
styles.tabItem,
173+
isActive ? styles.tabItemActive : undefined,
174+
])
175+
}
176+
>
177+
Insights
178+
</NavLink>
179+
)}
171180
</Stack>
172181
</Margins>
173182
</div>

0 commit comments

Comments
 (0)