import { useValues } from 'kea' ; import { EuiSideNavItemType } from '@elastic/eui' ; import { generateNavLink } from '../../../shared/layout' ; import { ROLE_MAPPINGS_TITLE } from '../../../shared/role_mapping/constants' ; import { AppLogic } from '../../app_logic' ; import { ENGINES_PATH , SETTINGS_PATH , CREDENTIALS_PATH , USERS_AND_ROLES_PATH } from '../../routes' ; import { CREDENTIALS_TITLE } from '../credentials' ; import { useEngineNav } from '../engine/engine_nav' ; import { ENGINES_TITLE } from '../engines' ; import { SETTINGS_TITLE } from '../settings' ; export const useAppSearchNav = ( ) => { const { myRole : { canViewSettings , canViewAccountCredentials , canViewRoleMappings } , } = useValues ( AppLogic ) ; const navItems = [ { id : 'engines' , name : ENGINES_TITLE , ... generateNavLink ( { to : ENGINES_PATH , isRoot : true , shouldShowActiveForSubroutes : true , items : useEngineNav ( ) , } ) , } , ] ; if ( canViewSettings ) { navItems . push ( { id : 'settings' , name : SETTINGS_TITLE , ... generateNavLink ( { to : SETTINGS_PATH } ) , } ) ; } if ( canViewAccountCredentials ) { navItems . push ( { id : 'credentials' , name : CREDENTIALS_TITLE , ... generateNavLink ( { to : CREDENTIALS_PATH } ) , } ) ; } if ( canViewRoleMappings ) { navItems . push ( { id : 'usersRoles' , name : ROLE_MAPPINGS_TITLE , ... generateNavLink ( { to : USERS_AND_ROLES_PATH } ) , } ) ; } return [ { id : '' , name : '' , items : navItems } ] ; } ;