diff --git a/src/ui/__tests__/ui_nav_link.js b/src/ui/__tests__/ui_nav_link.js index e5a2ea8a2a70..f264ccf426ec 100644 --- a/src/ui/__tests__/ui_nav_link.js +++ b/src/ui/__tests__/ui_nav_link.js @@ -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)); }); }); }); diff --git a/src/ui/public/chrome/directives/app_switcher/app_switcher.js b/src/ui/public/chrome/directives/app_switcher/app_switcher.js index 01236785b5d0..8f54b4aa4a09 100644 --- a/src/ui/public/chrome/directives/app_switcher/app_switcher.js +++ b/src/ui/public/chrome/directives/app_switcher/app_switcher.js @@ -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 diff --git a/src/ui/ui_nav_link.js b/src/ui/ui_nav_link.js index fdcd81a9dd42..63847d97de76 100644 --- a/src/ui/ui_nav_link.js +++ b/src/ui/ui_nav_link.js @@ -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']); } }