Skip to content

Commit

Permalink
removed argument
Browse files Browse the repository at this point in the history
  • Loading branch information
scampi committed Jan 27, 2017
1 parent f27a535 commit c9d5c0c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 26 deletions.
25 changes: 1 addition & 24 deletions src/ui/public/kbn_top_nav/__tests__/kbn_top_nav_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ import KbnTopNavControllerProvider from '../kbn_top_nav_controller';

describe('KbnTopNavController', function () {
let KbnTopNavController;
let $location;
let $rootScope;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (_$location_, _$rootScope_, Private) {
$location = _$location_;
$rootScope = _$rootScope_;
beforeEach(ngMock.inject(function (Private) {
KbnTopNavController = Private(KbnTopNavControllerProvider);
}));

Expand Down Expand Up @@ -97,25 +93,6 @@ describe('KbnTopNavController', function () {

expect(controller.menuItems).to.have.length(1);
});

it('exclude/include opts depending on the location', function () {
const opts = [
{ key: 'foo', hideButton: path => path === '/one' },
{ key: '1234', hideButton: path => path === '/two' },
];

$location.path('one');
$rootScope.$apply();
let controller = new KbnTopNavController(opts);
expect(controller.menuItems).to.have.length(1);
expect(controller.menuItems[0].key).to.be('1234');

$location.path('two');
$rootScope.$apply();
controller = new KbnTopNavController(opts);
expect(controller.menuItems).to.have.length(1);
expect(controller.menuItems[0].key).to.be('foo');
});
});

describe('disableButton:', function () {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/kbn_top_nav/kbn_top_nav_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import chrome from 'ui/chrome';
import filterTemplate from 'ui/chrome/config/filter.html';
import intervalTemplate from 'ui/chrome/config/interval.html';

export default function ($compile, $location) {
export default function ($compile) {
return class KbnTopNavController {
constructor(opts = []) {
if (opts instanceof KbnTopNavController) {
Expand Down Expand Up @@ -34,7 +34,7 @@ export default function ($compile, $location) {
const opt = this._applyOptDefault(rawOpt);
if (!opt.key) throw new TypeError('KbnTopNav: menu items must have a key');
this.opts.push(opt);
if (!opt.hideButton($location.path())) this.menuItems.push(opt);
if (!opt.hideButton()) this.menuItems.push(opt);
if (opt.template) this.templates[opt.key] = opt.template;
if (opt.controller) {
this.controllers[opt.key] = opt.controller;
Expand Down

0 comments on commit c9d5c0c

Please sign in to comment.