forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request elastic#7601 from ycombinator/app-switcher/nav-lin…
…k-enhancements [app switcher] nav link enhancements Former-commit-id: 0169492
- Loading branch information
Showing
9 changed files
with
241 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
import expect from 'expect.js'; | ||
|
||
import UiNavLink from '../ui_nav_link'; | ||
|
||
describe('UiNavLink', () => { | ||
describe('constructor', () => { | ||
it ('initializes the object properties as expected', () => { | ||
const uiExports = { | ||
urlBasePath: 'http://localhost:5601/rnd' | ||
}; | ||
const spec = { | ||
id: 'kibana:discover', | ||
title: 'Discover', | ||
order: -1003, | ||
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); | ||
|
||
expect(link.id).to.be(spec.id); | ||
expect(link.title).to.be(spec.title); | ||
expect(link.order).to.be(spec.order); | ||
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', () => { | ||
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.url).to.be(spec.url); | ||
}); | ||
|
||
it ('initializes the order property to 0 when order is not specified in the spec', () => { | ||
const uiExports = {}; | ||
const spec = { | ||
id: 'kibana:discover', | ||
title: 'Discover', | ||
url: '/app/kibana#/discover', | ||
description: 'interactively explore your data', | ||
icon: 'plugins/kibana/assets/discover.svg', | ||
}; | ||
const link = new UiNavLink(uiExports, spec); | ||
|
||
expect(link.order).to.be(0); | ||
}); | ||
|
||
it ('initializes the linkToLastSubUrl property to false when false is specified in the spec', () => { | ||
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', | ||
linkToLastSubUrl: false | ||
}; | ||
const link = new UiNavLink(uiExports, spec); | ||
|
||
expect(link.linkToLastSubUrl).to.be(false); | ||
}); | ||
|
||
it ('initializes the linkToLastSubUrl property to true 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.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', () => { | ||
it ('returns the expected properties', () => { | ||
const uiExports = { | ||
urlBasePath: 'http://localhost:5601/rnd' | ||
}; | ||
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); | ||
const json = link.toJSON(); | ||
|
||
['id', 'title', 'url', 'order', 'description', 'icon', 'linkToLastSubUrl', 'hidden', 'disabled', 'tooltip'] | ||
.forEach(expectedProperty => expect(json).to.have.property(expectedProperty)); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 10 additions & 3 deletions
13
src/ui/public/chrome/directives/app_switcher/app_switcher.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters