Register navLink actions for declared applications (#72109)
This commit is contained in:
parent
6164037f18
commit
99e14aad76
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'),
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -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'),
|
||||
]);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue