Skip to content

Commit

Permalink
Merge pull request elastic#8355 from spalger/fix/devtools-header-stac…
Browse files Browse the repository at this point in the history
…king

[kbnDevToolsApp] allow extending the top nav
  • Loading branch information
spalger authored Sep 21, 2016
2 parents bde2591 + 5bff9da commit 4552643
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 72 deletions.
1 change: 0 additions & 1 deletion src/core_plugins/console/public/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ require('./src/directives/sense_history');
require('./src/directives/sense_settings');
require('./src/directives/sense_help');
require('./src/directives/sense_welcome');
require('./src/directives/sense_navbar');

devTools.register(() => ({
order: 1,
Expand Down
4 changes: 1 addition & 3 deletions src/core_plugins/console/public/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<kbn-dev-tools-app data-test-subj="console">
<sense-navbar></sense-navbar>

<kbn-dev-tools-app data-test-subj="console" top-nav-config="topNavController">
<div id="editor_output_container">
<div id="editor_container">
<ul id="autocomplete"></ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { initializeInput } from '../input';
import { initializeOutput } from '../output';
import es from '../es';
import init from '../app';
import { SenseTopNavController } from './sense_top_nav_controller';

const module = require('ui/modules').get('app/sense');

Expand All @@ -16,14 +17,14 @@ module.run(function (Private, $rootScope) {
};
});

module.controller('SenseController', function SenseController($scope, $timeout, $location, docTitle) {

module.controller('SenseController', function SenseController(Private, $scope, $timeout, $location, docTitle) {
docTitle.change('Console');

let input, output;
$scope.topNavController = Private(SenseTopNavController)

// We need to wait for these elements to be rendered before we can select them with jQuery
// and then initialize this app
let input, output;
$timeout(() => {
output = initializeOutput($('#output'));
input = initializeInput($('#editor'), $('#editor_actions'), $('#copy_as_curl'), output);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import KbnTopNavControllerProvider from 'ui/kbn_top_nav/kbn_top_nav_controller';
import storage from '../storage';

export function SenseTopNavController(Private) {
const KbnTopNavController = Private(KbnTopNavControllerProvider);

const controller = new KbnTopNavController([
{
key: 'welcome',
hideButton: true,
template: `<sense-welcome></sense-welcome>`
},
{
key: 'history',
description: 'History',
template: `<sense-history></sense-history>`
},
{
key: 'settings',
description: 'Settings',
template: `<sense-settings></sense-settings>`
},
{
key: 'help',
description: 'Help',
template: `<sense-help></sense-help>`
},
]);

if (storage.get('version_welcome_shown') !== '@@SENSE_REVISION') {
controller.open('welcome')
}

return controller
}

This file was deleted.

53 changes: 0 additions & 53 deletions src/core_plugins/console/public/src/directives/sense_navbar.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
import uiModules from 'ui/modules';
import devTools from 'ui/registry/dev_tools';
import DevToolsRegistryProvider from 'ui/registry/dev_tools';
import template from 'plugins/kibana/dev_tools/partials/dev_tools_app.html';
import 'plugins/kibana/dev_tools/styles/dev_tools_app.less';
import 'ui/kbn_top_nav';

uiModules
.get('apps/dev_tools')
.directive('kbnDevToolsApp', function (Private, $location) {
const devToolsRegistry = Private(DevToolsRegistryProvider);

return {
restrict: 'E',
replace: true,
template,
transclude: true,
link: function ($scope) {
$scope.devTools = Private(devTools).inOrder;
$scope.currentPath = `#${$location.path()}`;
scope: {
topNavConfig: '='
},
bindToController: true,
controllerAs: 'kbnDevToolsApp',
controller() {
this.devTools = devToolsRegistry.inOrder;
this.currentPath = `#${$location.path()}`;
}
};
});
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<div class="dev-tools-app-container app-container">
<div class="dev-tools__app-container app-container">
<bread-crumbs class="bread-crumbs--navbar" omit-current-page="true"></bread-crumbs>
<kbn-top-nav name="devtools">
<kbn-top-nav name="devtools" config="kbnDevToolsApp.topNavConfig">
<div class="localTabs">
<a
ng-repeat="item in devTools"
ng-repeat="item in kbnDevToolsApp.devTools"
class="localTab"
ng-class="{'localTab-isSelected': currentPath === item.url}"
ng-class="{'localTab-isSelected': kbnDevToolsApp.currentPath === item.url}"
kbn-href="{{::item.url}}"
>
{{::item.display}}
</a>
</div>
</kbn-top-nav>
<div role="main" class="dev-tools-container" ng-transclude></div>
<div role="main" class="dev-tools__container" ng-transclude></div>
</div>
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
@import (reference) "~ui/styles/mixins.less";
@import (reference) "~ui/styles/variables.less";

.dev-tools-app-container {
.dev-tools__container {
.flex-parent;
}

.dev-tools-container {
.dev-tools__app-container {
.flex-parent;
}
13 changes: 13 additions & 0 deletions src/ui/public/kbn_top_nav/kbn_top_nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ module.directive('kbnTopNav', function (Private) {
restrict: 'E',
transclude: true,
template,

// TODO: The kbnTopNav currently requires that it share a scope with
// it's parent directive. This allows it to export the kbnTopNav controller
// and allows the config templates to use values from the parent scope.
//
// Moving this to an isolate scope will require modifying the config
// directive to support child directives, instead of templates, so that
// parent controllers can be imported/required rather than simply referenced
// directly in the template.
//
// scope: {}

controller($scope, $attrs, $element) {
const extensions = getNavbarExtensions($attrs.name);
let controls = _.get($scope, $attrs.config, []);
Expand All @@ -65,6 +77,7 @@ module.directive('kbnTopNav', function (Private) {

$scope.kbnTopNav = new KbnTopNavController(controls);
$scope.kbnTopNav._link($scope, $element);

return $scope.kbnTopNav;
}
};
Expand Down

0 comments on commit 4552643

Please sign in to comment.