Skip to content

Commit

Permalink
[7.9] Register navLink actions for declared applications (#72109) (#7…
Browse files Browse the repository at this point in the history
  • Loading branch information
legrego authored Jul 17, 2020
1 parent c8930b7 commit 2d4042c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import { BaseFeaturePrivilegeBuilder } from './feature_privilege_builder';

export class FeaturePrivilegeNavlinkBuilder extends BaseFeaturePrivilegeBuilder {
public getActions(privilegeDefinition: FeatureKibanaPrivileges, feature: Feature): string[] {
return feature.navLinkId ? [this.actions.ui.get('navLinks', feature.navLinkId)] : [];
const appNavLinks = feature.app.map((app) => this.actions.ui.get('navLinks', app));
return feature.navLinkId
? [this.actions.ui.get('navLinks', feature.navLinkId), ...appNavLinks]
: appNavLinks;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,20 @@ describe('features', () => {

const actual = privileges.get();
expect(actual).toHaveProperty('features.foo-feature', {
all: [actions.login, actions.version, actions.ui.get('navLinks', 'kibana:foo')],
read: [actions.login, actions.version, actions.ui.get('navLinks', 'kibana:foo')],
all: [
actions.login,
actions.version,
actions.ui.get('navLinks', 'kibana:foo'),
actions.ui.get('navLinks', 'app-1'),
actions.ui.get('navLinks', 'app-2'),
],
read: [
actions.login,
actions.version,
actions.ui.get('navLinks', 'kibana:foo'),
actions.ui.get('navLinks', 'app-1'),
actions.ui.get('navLinks', 'app-2'),
],
});
});

Expand Down Expand Up @@ -635,6 +647,8 @@ describe('reserved', () => {
expect(actual).toHaveProperty('reserved.foo', [
actions.version,
actions.ui.get('navLinks', 'kibana:foo'),
actions.ui.get('navLinks', 'app-1'),
actions.ui.get('navLinks', 'app-2'),
]);
});

Expand Down

0 comments on commit 2d4042c

Please sign in to comment.