Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
[kbnTopNav] break out controller, allow implementors to pass it in
Browse files Browse the repository at this point in the history
The first iteration of `kbnTopNav` prevented the need to define a `configTemplate` and the `menuItems` in separate locations, but moved the external API to a `kbnTopNav` object that was exposed on the scope where `kbnTopNav` was rendered. This meant that in order to programmatically control the `kbnTopNav` other directives needed to share a scope with it, or inherit from its scope. Additionally, since the `kbnTopNav` object is potentially not available when other directives boot, all access to this object needed to be wrapped in a call to `$timeout`.

In order to prevent this, but keep the nice API of `kbnTopNav`, this change breaks the controller and it's API out of `kbnTopNav` and exposes it via a Private module. Now, implementors can instantiate the `KbnTopNavController` themselves and pass it into the `<kbn-top-nav>` directive via the config attribute. This allows implementors to store the topNav API wherever makes sense in their implementation.

When the config attribute is not already an instance of the `KbnTopNavController` the directive will create an instance out of the passed value, which means that no existing implementations need to change at all.
  • Loading branch information
spalger committed Apr 2, 2016
1 parent fc62113 commit 9924a58
Show file tree
Hide file tree
Showing 8 changed files with 439 additions and 133 deletions.
1 change: 0 additions & 1 deletion src/plugins/kibana/public/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import _ from 'lodash';
import $ from 'jquery';
import angular from 'angular';
import chrome from 'ui/chrome';
import 'ui/directives/kbn_top_nav';
import 'ui/courier';
import 'ui/config';
import 'ui/notify';
Expand Down
1 change: 1 addition & 0 deletions src/ui/public/autoload/modules.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'angular';
import 'ui/chrome';
import 'ui/bind';
import 'ui/kbn_top_nav';
import 'ui/bound_to_config_obj';
import 'ui/config';
import 'ui/courier';
Expand Down
2 changes: 0 additions & 2 deletions src/ui/public/chrome/directives/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'ui/directives/kbn_top_nav';

import './app_switcher';
import kbnChromeProv from './kbn_chrome';
import kbnChromeNavControlsProv from './append_nav_controls';
Expand Down
128 changes: 0 additions & 128 deletions src/ui/public/directives/kbn_top_nav.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import expect from 'expect.js';
import { assign } from 'lodash';
import $ from 'jquery';

import '../';
import navbarExtensionsRegistry from 'ui/registry/navbar_extensions';
import Registry from 'ui/registry/_registry';
import 'ui/navbar_extensions';

describe('kbnTopNav Directive', function () {

describe('kbnTopNav directive', function () {
var build = function () {};
let $testScope = null;
let stubRegistry;
Expand Down
Loading

0 comments on commit 9924a58

Please sign in to comment.