open-vault/ui/app/helpers/has-permission.js
Noelle Daley 3bf3130268
Only link to nav items that user has access to (#7590)
* only show entities sidenav item if user has list capability on entities

* wip - link to correct paths in top navigation

* remove comment

* only link to groups page if user has list capability

* add test for checking multiple capabilities

* test when capabilities are not specified

* format jsdoc comments

* move capabilities check out of helper and into permissions service
2019-10-30 11:39:51 -07:00

24 lines
599 B
JavaScript

import Helper from '@ember/component/helper';
import { inject as service } from '@ember/service';
import { observer } from '@ember/object';
export default Helper.extend({
permissions: service(),
/* eslint-disable-next-line ember/no-observers */
onPermissionsChange: observer(
'permissions.exactPaths',
'permissions.globPaths',
'permissions.canViewAll',
function() {
this.recompute();
}
),
compute([route], params) {
let { routeParams } = params;
let permissions = this.permissions;
return permissions.hasNavPermission(route, routeParams);
},
});