@@ -39,24 +39,30 @@ export function useNavItems() {
3939 const setupState = useSetupState ( ) ;
4040
4141 useEffect ( ( ) => {
42+ const ability = currentUser ?. ability ;
4243 const globalItems : NavItem [ ] = [ ] ;
43- if ( currentUser ?. ability . can ( 'read' , 'Summary' ) ) {
44+ if (
45+ ability ?. can ( 'read' , 'Instrument' ) &&
46+ ability . can ( 'read' , 'InstrumentRecord' ) &&
47+ ability . can ( 'read' , 'Subject' ) &&
48+ ability . can ( 'read' , 'User' )
49+ ) {
4450 globalItems . push ( {
4551 icon : BarChartBigIcon ,
4652 label : t ( 'layout.navLinks.dashboard' ) ,
4753 url : '/dashboard'
4854 } ) ;
4955 }
50- if ( currentUser ?. ability . can ( 'read' , 'Subject' ) && currentUser . ability . can ( 'read' , 'InstrumentRecord' ) ) {
56+ if ( ability ?. can ( 'read' , 'Subject' ) && ability . can ( 'read' , 'InstrumentRecord' ) ) {
5157 globalItems . push ( {
5258 icon : DatabaseIcon ,
5359 label : t ( 'layout.navLinks.datahub' ) ,
5460 url : '/datahub'
5561 } ) ;
5662 }
5763 if (
58- currentUser ?. ability . can ( 'read' , 'Subject' ) &&
59- currentUser . ability . can ( 'create' , 'InstrumentRecord' ) &&
64+ ability ? .can ( 'read' , 'Subject' ) &&
65+ ability . can ( 'create' , 'InstrumentRecord' ) &&
6066 setupState . data ?. isExperimentalFeaturesEnabled
6167 ) {
6268 globalItems . push ( {
@@ -65,7 +71,7 @@ export function useNavItems() {
6571 url : '/upload'
6672 } ) ;
6773 }
68- if ( currentGroup && currentUser ?. ability . can ( 'manage' , 'Group' ) ) {
74+ if ( currentGroup && ability ? .can ( 'manage' , 'Group' ) ) {
6975 globalItems . push ( {
7076 icon : UsersIcon ,
7177 label : t ( 'layout.navLinks.manageGroup' ) ,
@@ -74,7 +80,7 @@ export function useNavItems() {
7480 }
7581
7682 const adminItems : NavItem [ ] = [ ] ;
77- if ( currentUser ?. ability . can ( 'manage' , 'all' ) ) {
83+ if ( ability ? .can ( 'manage' , 'all' ) ) {
7884 adminItems . push ( {
7985 icon : CogIcon ,
8086 label : t ( {
@@ -102,23 +108,23 @@ export function useNavItems() {
102108 }
103109
104110 const sessionItems : NavItem [ ] = [ ] ;
105- if ( currentUser ?. ability . can ( 'create' , 'Session' ) ) {
111+ if ( ability ? .can ( 'create' , 'Session' ) ) {
106112 sessionItems . push ( {
107113 disabled : currentSession !== null ,
108114 icon : CirclePlayIcon ,
109115 label : t ( 'layout.navLinks.startSession' ) ,
110116 url : '/session/start-session'
111117 } ) ;
112118 }
113- if ( currentUser ?. ability . can ( 'create' , 'InstrumentRecord' ) ) {
119+ if ( ability ? .can ( 'create' , 'InstrumentRecord' ) ) {
114120 sessionItems . push ( {
115121 disabled : currentSession === null ,
116122 icon : ComputerIcon ,
117123 label : t ( 'layout.navLinks.accessibleInstruments' ) ,
118124 url : '/instruments/accessible-instruments'
119125 } ) ;
120126 }
121- if ( currentUser ?. ability . can ( 'read' , 'Subject' ) && currentUser . ability . can ( 'read' , 'InstrumentRecord' ) ) {
127+ if ( ability ?. can ( 'read' , 'Subject' ) && ability . can ( 'read' , 'InstrumentRecord' ) ) {
122128 sessionItems . push ( {
123129 disabled : currentSession === null ,
124130 icon : EyeIcon ,
0 commit comments