1- import React from 'react'
1+ import React , { useContext } from 'react'
22import { useAtomValue , useSetAtom } from 'jotai'
33import {
44 MainViewState ,
@@ -20,6 +20,9 @@ import { twMerge } from 'tailwind-merge'
2020import { showingBotListModalAtom } from '@helpers/atoms/Modal.atom'
2121import useGetBots from '@hooks/useGetBots'
2222import { useUserConfigs } from '@hooks/useUserConfigs'
23+ import {
24+ FeatureToggleContext ,
25+ } from '@helpers/FeatureToggleWrapper'
2326
2427export const SidebarLeft = ( ) => {
2528 const [ config ] = useUserConfigs ( )
@@ -28,6 +31,7 @@ export const SidebarLeft = () => {
2831 const setBotListModal = useSetAtom ( showingBotListModalAtom )
2932 const { downloadedModels } = useGetDownloadedModels ( )
3033 const { getAllBots } = useGetBots ( )
34+ const { experimentalFeatureEnabed } = useContext ( FeatureToggleContext )
3135
3236 const onMenuClick = ( mainViewState : MainViewState ) => {
3337 if ( currentState === mainViewState ) return
@@ -88,18 +92,21 @@ export const SidebarLeft = () => {
8892 icon : < LayoutGrid size = { 20 } className = "flex-shrink-0" /> ,
8993 state : MainViewState . MyModel ,
9094 } ,
91- {
92- name : 'Bot' ,
93- icon : < Bot size = { 20 } className = "flex-shrink-0" /> ,
94- state : MainViewState . CreateBot ,
95- } ,
95+ ...( experimentalFeatureEnabed
96+ ? [
97+ {
98+ name : 'Bot' ,
99+ icon : < Bot size = { 20 } className = "flex-shrink-0" /> ,
100+ state : MainViewState . CreateBot ,
101+ } ,
102+ ]
103+ : [ ] ) ,
96104 {
97105 name : 'Settings' ,
98106 icon : < Settings size = { 20 } className = "flex-shrink-0" /> ,
99107 state : MainViewState . Setting ,
100108 } ,
101109 ]
102-
103110 return (
104111 < m . div
105112 initial = { false }
@@ -124,42 +131,44 @@ export const SidebarLeft = () => {
124131 config . sidebarLeftExpand ? 'items-start' : 'items-center'
125132 ) }
126133 >
127- { menus . map ( ( menu , i ) => {
128- const isActive = currentState === menu . state
129- const isBotMenu = menu . name === 'Bot'
130- return (
131- < div className = "relative w-full px-4 py-2" key = { i } >
132- < button
133- data-testid = { menu . name }
134- className = { twMerge (
135- 'flex w-full flex-shrink-0 items-center gap-x-2' ,
136- config . sidebarLeftExpand
137- ? 'justify-start'
138- : 'justify-center'
139- ) }
140- onClick = { ( ) =>
141- isBotMenu ? onBotListClick ( ) : onMenuClick ( menu . state )
142- }
143- >
144- { menu . icon }
145- < m . span
146- initial = { false }
147- variants = { variant }
148- animate = { config . sidebarLeftExpand ? 'show' : 'hide' }
149- className = "text-xs font-semibold text-muted-foreground"
134+ { menus
135+ . filter ( ( menu ) => ! ! menu )
136+ . map ( ( menu , i ) => {
137+ const isActive = currentState === menu . state
138+ const isBotMenu = menu . name === 'Bot'
139+ return (
140+ < div className = "relative w-full px-4 py-2" key = { i } >
141+ < button
142+ data-testid = { menu . name }
143+ className = { twMerge (
144+ 'flex w-full flex-shrink-0 items-center gap-x-2' ,
145+ config . sidebarLeftExpand
146+ ? 'justify-start'
147+ : 'justify-center'
148+ ) }
149+ onClick = { ( ) =>
150+ isBotMenu ? onBotListClick ( ) : onMenuClick ( menu . state )
151+ }
150152 >
151- { menu . name }
152- </ m . span >
153- </ button >
154- { isActive ? (
155- < m . div
156- className = "absolute inset-0 left-2 -z-10 h-full w-[calc(100%-16px)] rounded-md bg-accent/20 p-2 backdrop-blur-lg"
157- layoutId = "active-state"
158- />
159- ) : null }
160- </ div >
161- )
162- } ) }
153+ { menu . icon }
154+ < m . span
155+ initial = { false }
156+ variants = { variant }
157+ animate = { config . sidebarLeftExpand ? 'show' : 'hide' }
158+ className = "text-xs font-semibold text-muted-foreground"
159+ >
160+ { menu . name }
161+ </ m . span >
162+ </ button >
163+ { isActive ? (
164+ < m . div
165+ className = "absolute inset-0 left-2 -z-10 h-full w-[calc(100%-16px)] rounded-md bg-accent/20 p-2 backdrop-blur-lg"
166+ layoutId = "active-state"
167+ />
168+ ) : null }
169+ </ div >
170+ )
171+ } ) }
163172 </ div >
164173 < m . div
165174 initial = { false }
@@ -170,19 +179,15 @@ export const SidebarLeft = () => {
170179 < div className = "space-y-2 rounded-lg border border-border bg-background/50 p-3" >
171180 < button
172181 onClick = { ( ) =>
173- window . coreAPI ?. openExternalUrl (
174- 'https://discord.gg/AsJ8krTT3N'
175- )
182+ window . coreAPI ?. openExternalUrl ( 'https://discord.gg/AsJ8krTT3N' )
176183 }
177184 className = "block text-xs font-semibold text-muted-foreground"
178185 >
179186 Discord
180187 </ button >
181188 < button
182189 onClick = { ( ) =>
183- window . coreAPI ?. openExternalUrl (
184- 'https://twitter.com/janhq_'
185- )
190+ window . coreAPI ?. openExternalUrl ( 'https://twitter.com/janhq_' )
186191 }
187192 className = "block text-xs font-semibold text-muted-foreground"
188193 >
0 commit comments