-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dev tools] Hide app link when there are no tools (#9517)
Backports PR #9489 **Commit 1:** [dev tools] Hide app link when there are no tools * Original sha: ace40c4 * Authored by Jonathan Budzenski <[email protected]> on 2016-12-01T18:10:07Z **Commit 2:** [dev tools] Add tests for setting app as hidden * Original sha: 7828524 * Authored by Jonathan Budzenski <[email protected]> on 2016-12-15T21:08:20Z
- Loading branch information
1 parent
da4c0b4
commit 38975e2
Showing
4 changed files
with
57 additions
and
0 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
44 changes: 44 additions & 0 deletions
44
src/core_plugins/kibana/public/dev_tools/lib/__tests__/hide_empty_tools.js
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,44 @@ | ||
import ngMock from 'ng_mock'; | ||
import expect from 'expect.js'; | ||
import sinon from 'sinon'; | ||
|
||
import chrome from 'ui/chrome'; | ||
import { hideEmptyDevTools } from '../hide_empty_tools'; | ||
|
||
describe('hide dev tools', function () { | ||
let Private; | ||
let navlinks; | ||
|
||
function PrivateWithoutTools() { | ||
return []; | ||
} | ||
|
||
function PrivateWithTools() { | ||
return ['tool1', 'tool2']; | ||
} | ||
|
||
function isHidden() { | ||
return !!chrome.getNavLinkById('kibana:dev_tools').hidden; | ||
} | ||
|
||
beforeEach(function () { | ||
navlinks = {}; | ||
sinon.stub(chrome, 'getNavLinkById',function () { | ||
return navlinks; | ||
}); | ||
}); | ||
|
||
it('should hide the app if there are no dev tools', function () { | ||
hideEmptyDevTools(PrivateWithTools); | ||
expect(isHidden()).to.be(false); | ||
}); | ||
|
||
it('should not hide the app if there are tools', function () { | ||
hideEmptyDevTools(PrivateWithoutTools); | ||
expect(isHidden()).to.be(true); | ||
}); | ||
|
||
afterEach(function () { | ||
chrome.getNavLinkById.restore(); | ||
}); | ||
}); |
10 changes: 10 additions & 0 deletions
10
src/core_plugins/kibana/public/dev_tools/lib/hide_empty_tools.js
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,10 @@ | ||
import chrome from 'ui/chrome'; | ||
import DevToolsRegistryProvider from 'ui/registry/dev_tools'; | ||
|
||
export function hideEmptyDevTools(Private) { | ||
const hasTools = !!Private(DevToolsRegistryProvider).length; | ||
if (!hasTools) { | ||
const navLink = chrome.getNavLinkById('kibana:dev_tools'); | ||
navLink.hidden = true; | ||
} | ||
} |
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