@@ -15,6 +15,7 @@ import {
15
15
import { useQuery } from "@tanstack/react-query"
16
16
import { AuthorizationRequest } from "api/typesGenerated"
17
17
import { ErrorAlert } from "components/Alert/ErrorAlert"
18
+ import { useDashboard } from "components/Dashboard/DashboardProvider"
18
19
19
20
const templatePermissions = (
20
21
templateId : string ,
@@ -71,6 +72,12 @@ export const TemplateLayout: FC<{ children?: JSX.Element }> = ({
71
72
queryKey : [ "template" , templateName ] ,
72
73
queryFn : ( ) => fetchTemplate ( orgId , templateName ) ,
73
74
} )
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
74
81
75
82
if ( error ) {
76
83
return (
@@ -157,17 +164,19 @@ export const TemplateLayout: FC<{ children?: JSX.Element }> = ({
157
164
>
158
165
Embed
159
166
</ 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
+ ) }
171
180
</ Stack >
172
181
</ Margins >
173
182
</ div >
0 commit comments