33
44import * as React from 'react' ;
55import { usePathname , useRouter } from 'next/navigation' ;
6- import HelpDropdown from './HelpDropdown/HelpDropdown' ;
76import Link from 'next/link' ;
8- import UserMenu from './UserMenu/UserMenu' ;
97import { useSession } from 'next-auth/react' ;
10- import { useState } from 'react' ;
118import {
129 Bullseye ,
1310 Spinner ,
@@ -31,7 +28,11 @@ import {
3128} from '@patternfly/react-core' ;
3229import { BarsIcon } from '@patternfly/react-icons' ;
3330import ThemePreference from '@/components/ThemePreference/ThemePreference' ;
31+ import HelpDropdown from './HelpDropdown/HelpDropdown' ;
32+ import UserMenu from './UserMenu/UserMenu' ;
33+
3434import '../styles/globals.scss' ;
35+ import { useFeatureFlags } from '@/context/FeatureFlagsContext' ;
3536
3637interface IAppLayout {
3738 children : React . ReactNode ;
@@ -46,21 +47,13 @@ type Route = {
4647
4748const AppLayout : React . FunctionComponent < IAppLayout > = ( { children, className } ) => {
4849 const { data : session , status } = useSession ( ) ;
49- const [ isExperimentalEnabled , setExperimental ] = useState ( false ) ;
50+ const {
51+ featureFlags : { experimentalFeaturesEnabled }
52+ } = useFeatureFlags ( ) ;
5053
5154 const router = useRouter ( ) ;
5255 const pathname = usePathname ( ) ;
5356
54- React . useEffect ( ( ) => {
55- // Fetch the experimental feature flag
56- const fetchExperimentalFeature = async ( ) => {
57- const res = await fetch ( '/api/envConfig' ) ;
58- const envConfig = await res . json ( ) ;
59- setExperimental ( envConfig . EXPERIMENTAL_FEATURES === 'true' ) ;
60- } ;
61- fetchExperimentalFeature ( ) ;
62- } , [ ] ) ;
63-
6457 React . useEffect ( ( ) => {
6558 if ( status === 'loading' ) return ; // Do nothing while loading
6659 if ( ! session && pathname !== '/login' ) {
@@ -82,12 +75,6 @@ const AppLayout: React.FunctionComponent<IAppLayout> = ({ children, className })
8275
8376 //const isExperimentalEnabled = process.env.NEXT_PUBLIC_EXPERIMENTAL_FEATURES === 'true';
8477
85- // Only log if experimental features are enabled
86- if ( isExperimentalEnabled ) {
87- console . log ( 'Is Experimental Enabled:' , isExperimentalEnabled ) ;
88- console . log ( 'Environment Variable:' , process . env . NEXT_PUBLIC_EXPERIMENTAL_FEATURES ) ;
89- }
90-
9178 const routes = [
9279 { path : '/dashboard' , label : 'Dashboard' } ,
9380 {
@@ -106,7 +93,7 @@ const AppLayout: React.FunctionComponent<IAppLayout> = ({ children, className })
10693 { path : '/playground/endpoints' , label : 'Custom model endpoints' }
10794 ]
10895 } ,
109- isExperimentalEnabled && {
96+ experimentalFeaturesEnabled && {
11097 path : '/experimental' ,
11198 label : 'Experimental features' ,
11299 children : [
0 commit comments