Adding hidden, disabled and tooltip properties to UiNavLink class
This commit is contained in:
parent
2601fcfea7
commit
42cc301366
|
@ -15,6 +15,8 @@ describe('UiNavLink', () => {
|
|||
url: '/app/kibana#/discover',
|
||||
description: 'interactively explore your data',
|
||||
icon: 'plugins/kibana/assets/discover.svg',
|
||||
hidden: true,
|
||||
disabled: true
|
||||
};
|
||||
const link = new UiNavLink(uiExports, spec);
|
||||
|
||||
|
@ -24,6 +26,8 @@ describe('UiNavLink', () => {
|
|||
expect(link.url).to.be(`${uiExports.urlBasePath}${spec.url}`);
|
||||
expect(link.description).to.be(spec.description);
|
||||
expect(link.icon).to.be(spec.icon);
|
||||
expect(link.hidden).to.be(spec.hidden);
|
||||
expect(link.disabled).to.be(spec.disabled);
|
||||
});
|
||||
|
||||
it ('initializes the url property without a base path when one is not specified in the spec', () => {
|
||||
|
@ -85,6 +89,51 @@ describe('UiNavLink', () => {
|
|||
|
||||
expect(link.linkToLastSubUrl).to.be(true);
|
||||
});
|
||||
|
||||
it ('initializes the hidden property to false by default', () => {
|
||||
const uiExports = {};
|
||||
const spec = {
|
||||
id: 'kibana:discover',
|
||||
title: 'Discover',
|
||||
order: -1003,
|
||||
url: '/app/kibana#/discover',
|
||||
description: 'interactively explore your data',
|
||||
icon: 'plugins/kibana/assets/discover.svg',
|
||||
};
|
||||
const link = new UiNavLink(uiExports, spec);
|
||||
|
||||
expect(link.hidden).to.be(false);
|
||||
});
|
||||
|
||||
it ('initializes the disabled property to false by default', () => {
|
||||
const uiExports = {};
|
||||
const spec = {
|
||||
id: 'kibana:discover',
|
||||
title: 'Discover',
|
||||
order: -1003,
|
||||
url: '/app/kibana#/discover',
|
||||
description: 'interactively explore your data',
|
||||
icon: 'plugins/kibana/assets/discover.svg',
|
||||
};
|
||||
const link = new UiNavLink(uiExports, spec);
|
||||
|
||||
expect(link.disabled).to.be(false);
|
||||
});
|
||||
|
||||
it ('initializes the tooltip property to an empty string by default', () => {
|
||||
const uiExports = {};
|
||||
const spec = {
|
||||
id: 'kibana:discover',
|
||||
title: 'Discover',
|
||||
order: -1003,
|
||||
url: '/app/kibana#/discover',
|
||||
description: 'interactively explore your data',
|
||||
icon: 'plugins/kibana/assets/discover.svg',
|
||||
};
|
||||
const link = new UiNavLink(uiExports, spec);
|
||||
|
||||
expect(link.tooltip).to.be('');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#toJSON', () => {
|
||||
|
@ -103,9 +152,8 @@ describe('UiNavLink', () => {
|
|||
const link = new UiNavLink(uiExports, spec);
|
||||
const json = link.toJSON();
|
||||
|
||||
['id', 'title', 'url', 'order', 'description', 'icon', 'linkToLastSubUrl'].forEach(expectedProperty => {
|
||||
expect(json).to.have.property(expectedProperty);
|
||||
});
|
||||
['id', 'title', 'url', 'order', 'description', 'icon', 'linkToLastSubUrl', 'hidden', 'disabled', 'tooltip']
|
||||
.forEach(expectedProperty => expect(json).to.have.property(expectedProperty));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -6,11 +6,11 @@ import uiModules from 'ui/modules';
|
|||
import appSwitcherTemplate from './app_switcher.html';
|
||||
|
||||
function isNavLinkEnabled(link) {
|
||||
return link.enable === undefined || link.enable;
|
||||
return !link.disabled;
|
||||
}
|
||||
|
||||
function isNavLinkShown(link) {
|
||||
return link.show === undefined || link.show;
|
||||
return !link.hidden;
|
||||
}
|
||||
|
||||
uiModules
|
||||
|
|
|
@ -10,9 +10,12 @@ export default class UiNavLink {
|
|||
this.description = spec.description;
|
||||
this.icon = spec.icon;
|
||||
this.linkToLastSubUrl = spec.linkToLastSubUrl === false ? false : true;
|
||||
this.hidden = spec.hidden || false;
|
||||
this.disabled = spec.disabled || false;
|
||||
this.tooltip = spec.tooltip || '';
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return pick(this, ['id', 'title', 'url', 'order', 'description', 'icon', 'linkToLastSubUrl']);
|
||||
return pick(this, ['id', 'title', 'url', 'order', 'description', 'icon', 'linkToLastSubUrl', 'hidden', 'disabled', 'tooltip']);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue