Skip to content

Commit

Permalink
dreamfactorysoftware#300 - hide Reports tap for non-root users
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and root committed Aug 13, 2024
1 parent 90cc436 commit f3c9f95
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 20 deletions.
17 changes: 16 additions & 1 deletion src/app/shared/components/df-side-nav/df-side-nav.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,22 @@ export class DfSideNavComponent implements OnInit {
return of(null);
}
if (userData?.isSysAdmin && !userData.roleId) {
return of(null);
return of([
'home',
'apps',
'role',
'users',
'services',
'apidocs',
'schema/data',
'files',
'scripts',
'systemInfo',
'limits',
'scheduler',
'system-config',
'admin-setting',
]);
}
if (userData?.isSysAdmin && userData.roleId) {
return this.userDataService.restrictedAccess$;
Expand Down
51 changes: 32 additions & 19 deletions src/app/shared/utilities/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,8 @@ export function accessibleRoutes(
const allowed: Array<ROUTES> = [ROUTES.SYSTEM_INFO];
allowedTabs?.forEach(tab => {
switch (tab) {
case 'apps':
allowed.push(ROUTES.API_KEYS);
break;
case 'users':
allowed.push(ROUTES.USERS);
case 'home':
allowed.push(ROUTES.HOME);
break;
case 'services':
allowed.push(
Expand All @@ -82,32 +79,48 @@ export function accessibleRoutes(
ROUTES.DF_PLATFORM_APIS
);
break;
case 'apidocs':
allowed.push(ROUTES.API_DOCS);
break;
case 'schema/data':
allowed.push(ROUTES.SCHEMA);
case 'role':
allowed.push(ROUTES.ROLE_BASED_ACCESS);
break;
case 'files':
allowed.push(ROUTES.FILES);
case 'apps':
allowed.push(ROUTES.API_KEYS);
break;
case 'scripts':
allowed.push(ROUTES.EVENT_SCRIPTS);
break;
case 'config':
allowed.push(
ROUTES.CORS,
ROUTES.CACHE,
ROUTES.EMAIL_TEMPLATES,
ROUTES.GLOBAL_LOOKUP_KEYS
);
case 'apidocs':
allowed.push(ROUTES.API_DOCS);
break;
case 'limits':
allowed.push(ROUTES.RATE_LIMITING);
break;
case 'system-config':
allowed.push(ROUTES.CORS);
allowed.push(ROUTES.CACHE);
allowed.push(ROUTES.EMAIL_TEMPLATES);
allowed.push(ROUTES.GLOBAL_LOOKUP_KEYS);
break;
case 'scheduler':
allowed.push(ROUTES.SCHEDULER);
break;
case 'reports':
allowed.push(ROUTES.REPORTING);
break;
case 'users':
allowed.push(ROUTES.USERS);
break;

case 'schema/data':
allowed.push(ROUTES.SCHEMA);
break;
case 'files':
allowed.push(ROUTES.FILES);
break;

case 'admin-setting':
allowed.push(ROUTES.ADMINS);
allowed.push(ROUTES.LOGS);
break;
}
});
return navs.filter(nav => {
Expand Down

0 comments on commit f3c9f95

Please sign in to comment.