mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[dev tools] Hide app link when there are no tools (#9489)
* [dev tools] Hide app link when there are no tools * [dev tools] Add tests for setting app as hidden
This commit is contained in:
parent
cb3219c798
commit
3144994c19
4 changed files with 57 additions and 0 deletions
|
@ -74,6 +74,7 @@ module.exports = function (kibana) {
|
||||||
description: 'compose visualizations for much win',
|
description: 'compose visualizations for much win',
|
||||||
icon: 'plugins/kibana/assets/dashboard.svg',
|
icon: 'plugins/kibana/assets/dashboard.svg',
|
||||||
}, {
|
}, {
|
||||||
|
id: 'kibana:dev_tools',
|
||||||
title: 'Dev Tools',
|
title: 'Dev Tools',
|
||||||
order: 9001,
|
order: 9001,
|
||||||
url: '/app/kibana#/dev_tools',
|
url: '/app/kibana#/dev_tools',
|
||||||
|
|
|
@ -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();
|
||||||
|
});
|
||||||
|
});
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,6 +20,7 @@ import 'ui/agg_types';
|
||||||
import 'ui/timepicker';
|
import 'ui/timepicker';
|
||||||
import Notifier from 'ui/notify/notifier';
|
import Notifier from 'ui/notify/notifier';
|
||||||
import 'leaflet';
|
import 'leaflet';
|
||||||
|
import { hideEmptyDevTools } from './dev_tools/lib/hide_empty_tools';
|
||||||
|
|
||||||
routes.enable();
|
routes.enable();
|
||||||
|
|
||||||
|
@ -49,3 +50,4 @@ chrome
|
||||||
});
|
});
|
||||||
|
|
||||||
modules.get('kibana').run(Notifier.pullMessageFromUrl);
|
modules.get('kibana').run(Notifier.pullMessageFromUrl);
|
||||||
|
modules.get('kibana').run(hideEmptyDevTools);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue