@@ -46,6 +46,8 @@ const WebUISider: React.FC<WebUISiderProps> = (props) => {
4646 config . theme ?. algorithm === theme . darkAlgorithm ? 'dark' : 'light' ;
4747
4848 const currentUserRole = useCurrentUserRole ( ) ;
49+ const hasAdminCategoryRole =
50+ currentUserRole === 'superadmin' || currentUserRole === 'admin' ;
4951 const webuiNavigate = useWebUINavigate ( ) ;
5052 const location = useLocation ( ) ;
5153 const baiClient = useSuspendedBackendaiClient ( ) ;
@@ -111,6 +113,7 @@ const WebUISider: React.FC<WebUISiderProps> = (props) => {
111113 height : 40 ,
112114 width : 42 ,
113115 marginLeft : token . margin ,
116+ marginBottom : 4 ,
114117 } }
115118 />
116119 </ Tooltip >
@@ -203,67 +206,44 @@ const WebUISider: React.FC<WebUISiderProps> = (props) => {
203206 ] }
204207 // @ts -ignore
205208 items = { filterOutEmpty ( [
206- ...groupedGeneralMenu ,
207- ( currentUserRole === 'superadmin' ||
208- currentUserRole === 'admin' ) && {
209+ hasAdminCategoryRole && {
209210 // Go to first page of admin setting pages.
210- type : 'group' ,
211211 label : (
212- < BAIFlex
213- style = { {
214- borderBottom : `1px solid ${ token . colorBorder } ` ,
215- } }
216- >
217- { ! props . collapsed && (
218- < Typography . Text type = "secondary" ellipsis >
219- { t ( 'webui.menu.Administration' ) }
220- </ Typography . Text >
221- ) }
222- </ BAIFlex >
212+ < WebUILink to = "/credential" >
213+ { t ( 'webui.menu.AdminSettings' ) }
214+ </ WebUILink >
223215 ) ,
224- children : [
225- {
226- label : (
227- < WebUILink
228- to = "/credential"
229- state = { { goBack : location . pathname } }
230- >
231- { t ( 'webui.menu.AdminSettings' ) }
232- </ WebUILink >
233- ) ,
234- icon : < SettingsIcon style = { { color : token . colorInfo } } /> ,
235- key : 'admin-settings' ,
236- } ,
237- ] ,
216+ icon : < SettingsIcon style = { { color : token . colorInfo } } /> ,
217+ key : 'admin-settings' ,
238218 } ,
219+ ...groupedGeneralMenu ,
239220 ] ) }
240221 />
241222 ) }
242- { ( currentUserRole === 'superadmin' || currentUserRole === 'admin' ) &&
243- isSelectedAdminCategoryMenu && (
244- < ConfigProvider
245- theme = { {
246- token : {
247- colorPrimary : primaryColors . admin ,
248- } ,
249- } }
250- >
251- { adminHeader }
252- < BAIMenu
253- collapsed = { props . collapsed }
254- selectedKeys = { [
255- // TODO: After matching first path of 'storage-settings' and 'agent', remove this code
256- location . pathname . split ( '/' ) [ 1 ] === 'storage-settings'
257- ? 'agent'
258- : location . pathname . split ( '/' ) [ 1 ] ,
259- ] }
260- items = { [
261- ...adminMenu ,
262- ...( currentUserRole === 'superadmin' ? superAdminMenu : [ ] ) ,
263- ] }
264- />
265- </ ConfigProvider >
266- ) }
223+ { hasAdminCategoryRole && isSelectedAdminCategoryMenu && (
224+ < ConfigProvider
225+ theme = { {
226+ token : {
227+ colorPrimary : primaryColors . admin ,
228+ } ,
229+ } }
230+ >
231+ { adminHeader }
232+ < BAIMenu
233+ collapsed = { props . collapsed }
234+ selectedKeys = { [
235+ // TODO: After matching first path of 'storage-settings' and 'agent', remove this code
236+ location . pathname . split ( '/' ) [ 1 ] === 'storage-settings'
237+ ? 'agent'
238+ : location . pathname . split ( '/' ) [ 1 ] ,
239+ ] }
240+ items = { [
241+ ...adminMenu ,
242+ ...( currentUserRole === 'superadmin' ? superAdminMenu : [ ] ) ,
243+ ] }
244+ />
245+ </ ConfigProvider >
246+ ) }
267247 </ BAIFlex >
268248 { props . collapsed ? null : (
269249 < BAIFlex
0 commit comments