-
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.
[chrome] use chromNavControls rather than a hard coded list
- Loading branch information
Showing
15 changed files
with
231 additions
and
96 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
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
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
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
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,73 @@ | ||
import ngMock from 'ngMock'; | ||
import $ from 'jquery'; | ||
import expect from 'expect.js'; | ||
|
||
import uiModules from 'ui/modules'; | ||
import chromeNavControlsRegistry from 'ui/registry/chrome_nav_controls'; | ||
import Registry from 'ui/registry/_registry'; | ||
|
||
describe('chrome nav controls', function () { | ||
let compile; | ||
let stubRegistry; | ||
|
||
beforeEach(ngMock.module('kibana', function (PrivateProvider) { | ||
stubRegistry = new Registry({ | ||
order: ['order'] | ||
}); | ||
|
||
PrivateProvider.swap(chromeNavControlsRegistry, stubRegistry); | ||
})); | ||
|
||
beforeEach(ngMock.inject(function ($compile, $rootScope) { | ||
compile = function () { | ||
const $el = $('<div kbn-chrome-append-nav-controls>'); | ||
$rootScope.$apply(); | ||
$compile($el)($rootScope); | ||
return $el; | ||
}; | ||
})); | ||
|
||
it('injects templates from the ui/registry/chrome_nav_controls registry', function () { | ||
stubRegistry.register(function () { | ||
return { | ||
name: 'control', | ||
order: 100, | ||
template: `<span id="testTemplateEl"></span>` | ||
}; | ||
}); | ||
|
||
var $el = compile(); | ||
expect($el.find('#testTemplateEl')).to.have.length(1); | ||
}); | ||
|
||
it('renders controls in order', function () { | ||
stubRegistry.register(function () { | ||
return { | ||
name: 'control2', | ||
order: 2, | ||
template: `<span id="2", class="testControl"></span>` | ||
}; | ||
}); | ||
stubRegistry.register(function () { | ||
return { | ||
name: 'control1', | ||
order: 1, | ||
template: `<span id="1", class="testControl"></span>` | ||
}; | ||
}); | ||
stubRegistry.register(function () { | ||
return { | ||
name: 'control3', | ||
order: 3, | ||
template: `<span id="3", class="testControl"></span>` | ||
}; | ||
}); | ||
|
||
var $el = compile(); | ||
expect( | ||
$el.find('.testControl') | ||
.toArray() | ||
.map(el => el.id) | ||
).to.eql(['1', '2', '3']); | ||
}); | ||
}); |
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
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
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
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,26 @@ | ||
import $ from 'jquery'; | ||
|
||
import chromeNavControlsRegistry from 'ui/registry/chrome_nav_controls'; | ||
import UiModules from 'ui/modules'; | ||
|
||
export default function (chrome, internals) { | ||
|
||
UiModules | ||
.get('kibana') | ||
.directive('kbnChromeAppendNavControls', function (Private) { | ||
return { | ||
template: function ($element) { | ||
const parts = [$element.html()]; | ||
const controls = Private(chromeNavControlsRegistry); | ||
|
||
for (const control of controls.inOrder) { | ||
parts.push(`<!-- nav control ${control.name} -->`); | ||
parts.push(control.template); | ||
} | ||
|
||
return parts.join('\n'); | ||
} | ||
}; | ||
}); | ||
|
||
} |
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 |
---|---|---|
@@ -1,6 +1,10 @@ | ||
import 'ui/directives/config'; | ||
|
||
import appSwitcherProv from './app_switcher'; | ||
import './app_switcher'; | ||
import kbnChromeProv from './kbn_chrome'; | ||
import kbnChromeNavControlsProv from './append_nav_controls'; | ||
|
||
export default function (chrome, internals) { | ||
kbnChromeProv(chrome, internals); | ||
kbnChromeNavControlsProv(chrome, internals); | ||
} |
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,58 @@ | ||
import $ from 'jquery'; | ||
|
||
import UiModules from 'ui/modules'; | ||
import ConfigTemplate from 'ui/ConfigTemplate'; | ||
|
||
export default function (chrome, internals) { | ||
|
||
UiModules | ||
.get('kibana') | ||
.directive('kbnChrome', function ($rootScope) { | ||
return { | ||
template($el) { | ||
const $content = $(require('ui/chrome/chrome.html')); | ||
const $app = $content.find('.application'); | ||
|
||
if (internals.rootController) { | ||
$app.attr('ng-controller', internals.rootController); | ||
} | ||
|
||
if (internals.rootTemplate) { | ||
$app.removeAttr('ng-view'); | ||
$app.html(internals.rootTemplate); | ||
} | ||
|
||
return $content; | ||
}, | ||
|
||
controllerAs: 'chrome', | ||
controller($scope, $rootScope, $location, $http) { | ||
|
||
// are we showing the embedded version of the chrome? | ||
internals.setVisibleDefault(!$location.search().embed); | ||
|
||
// listen for route changes, propogate to tabs | ||
const onRouteChange = function () { | ||
let { href } = window.location; | ||
let persist = chrome.getVisible(); | ||
internals.trackPossibleSubUrl(href); | ||
internals.tabs.consumeRouteUpdate(href, persist); | ||
}; | ||
|
||
$rootScope.$on('$routeChangeSuccess', onRouteChange); | ||
$rootScope.$on('$routeUpdate', onRouteChange); | ||
onRouteChange(); | ||
|
||
// and some local values | ||
$scope.httpActive = $http.pendingRequests; | ||
$scope.notifList = require('ui/notify')._notifs; | ||
$scope.appSwitcherTemplate = new ConfigTemplate({ | ||
switcher: '<app-switcher></app-switcher>' | ||
}); | ||
|
||
return chrome; | ||
} | ||
}; | ||
}); | ||
|
||
} |
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,6 @@ | ||
define(function (require) { | ||
return require('ui/registry/_registry')({ | ||
name: 'chromeNavControls', | ||
order: ['order'] | ||
}); | ||
}); |
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
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,37 @@ | ||
<ul | ||
kbn-timpicker-toggle | ||
ng-show="timefilter.enabled" | ||
class="nav navbar-nav navbar-right navbar-timepicker"> | ||
|
||
<li> | ||
<a | ||
ng-click="toggleRefresh()" | ||
ng-show="timefilter.refreshInterval.value > 0"> | ||
|
||
<i class="fa" ng-class="timefilter.refreshInterval.pause ? 'fa-play' : 'fa-pause'"></i> | ||
</a> | ||
</li> | ||
|
||
<li | ||
ng-class="{active: pickerTemplate.is('interval') }" | ||
ng-show="timefilter.refreshInterval.value > 0 || !!pickerTemplate.current" | ||
class="to-body"> | ||
|
||
<a ng-click="pickerTemplate.toggle('interval')" class="navbar-timepicker-auto-refresh-desc"> | ||
<span ng-show="timefilter.refreshInterval.value === 0"><i class="fa fa-repeat"></i> Auto-refresh</span> | ||
<span ng-show="timefilter.refreshInterval.value > 0">{{timefilter.refreshInterval.display}}</span> | ||
</a> | ||
|
||
</li> | ||
|
||
<li class="to-body" ng-class="{active: pickerTemplate.is('filter')}"> | ||
<a | ||
ng-click="pickerTemplate.toggle('filter')" | ||
aria-haspopup="true" | ||
aria-expanded="false" | ||
class="navbar-timepicker-time-desc"> | ||
<i aria-hidden="true" class="fa fa-clock-o"></i> | ||
<pretty-duration from="timefilter.time.from" to="timefilter.time.to"></pretty-duration> | ||
</a> | ||
</li> | ||
</ul> |
Oops, something went wrong.