Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/move append nav controls #6645

Merged
merged 16 commits into from
Mar 29, 2016
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/plugins/kibana/public/dashboard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
ng-click="configTemplate.toggle('options');">
<span>Options</span>
</button>
<div class="chrome-actions"kbn-chrome-append-nav-controls></div>
<kbn-global-timepicker></kbn-global-timepicker>
</div>
</navbar>
<config config-template="configTemplate" config-object="opts"></config>
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/kibana/public/discover/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
ng-click="configTemplate.toggle('share');">
<span>Share</span>
</button>
<div class="chrome-actions" kbn-chrome-append-nav-controls></div>
<kbn-global-timepicker></kbn-global-timepicker>
</div>
</navbar>
<config
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/kibana/public/visualize/editor/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
aria-label="Refresh">
<span>Refresh</span>
</button>
<div class="chrome-actions"kbn-chrome-append-nav-controls></div>
<kbn-global-timepicker></kbn-global-timepicker>
</div>
</navbar>
<config
Expand Down
1 change: 0 additions & 1 deletion src/ui/public/autoload/modules.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'angular';
import 'ui/chrome';
import 'ui/chrome/context';
import 'ui/bind';
import 'ui/bound_to_config_obj';
import 'ui/config';
Expand Down
41 changes: 41 additions & 0 deletions src/ui/public/chrome/__tests__/kbn_loading_indicator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import ngMock from 'ng_mock';
import expect from 'expect.js';
import uiModules from 'ui/modules';
import $ from 'jquery';

import '../directives/kbn_loading_indicator';


describe('kbnLoadingIndicator', function () {
let compile;

beforeEach(() => {
ngMock.module('kibana');
ngMock.inject(function ($compile, $rootScope) {
compile = function (hasActiveConnections) {
$rootScope.chrome = {
httpActive: (hasActiveConnections ? [1] : [])
};
const $el = $('<kbn-loading-indicator></kbn-loading-indicator>');
$rootScope.$apply();
$compile($el)($rootScope);
return $el;
};
});

});

it('injects a loading .spinner into the element', function () {
const $el = compile();
expect($el.find('.spinner')).to.have.length(1);
});
// Doesn't work...
xit('applies the ng-hide class when there are no connections', function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xit? Is this some kind of alias for it.skip?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops this slipped past me i'll remove this.

const $el = compile(false);
expect($el.find('.spinner.ng-hide')).to.have.length(1);
});
it('applies removes ng-hide class when there are connections', function () {
const $el = compile(true);
expect($el.find('.spinner.ng-hide')).to.have.length(0);
});
});
25 changes: 5 additions & 20 deletions src/ui/public/chrome/chrome.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="content" chrome-context >
<!-- TODO: These config dropdowns shouldn't be hard coded -->
<nav class="app-links-wrapper">
<nav class="app-links-wrapper" ng-show="chrome.getVisible()">
<li
ng-if="!chrome.getBrand('logo') && !chrome.getBrand('smallLogo')"
aria-label="{{ chrome.getAppTitle() }} Logo"
Expand All @@ -21,28 +21,12 @@

<app-switcher>
</app-switcher>
<div class="bottom-apps hide app-links">
<div class="app-link">
<a href="http://elastic.co">
<div class="app-icon">
<i class="fa fa-gear"></i>
</div>
<div class="app-title">settings</div>
</a>
</div>
<div class="app-link">
<a href="http://elastic.co">
<div class="app-icon">
<i class="fa fa-user"></i>
</div>
<div class="app-title">Jon Doe</div>
<div class="app-title">Logout</div>
</a>
</div>
<div class="bottom-apps">
<div class="chrome-actions app-links" kbn-chrome-append-nav-controls></div>
</div>
</nav>

<div class="app-wrapper">
<div class="app-wrapper" ng-class="{ 'hidden-chrome': !chrome.getVisible() }">
<div class="app-wrapper-panel">
<kbn-notifications list="notifList"></kbn-notifications>
<nav
Expand Down Expand Up @@ -80,6 +64,7 @@
</div>
<!-- /Full navbar -->
</nav>
<kbn-loading-indicator></kbn-loading-indicator>
<div class="application" ng-class="'tab-' + chrome.getFirstPathSegment() + ' ' + chrome.getApplicationClasses()" ng-view></div>
</div>
</div>
Expand Down
30 changes: 0 additions & 30 deletions src/ui/public/chrome/context.js

This file was deleted.

1 change: 0 additions & 1 deletion src/ui/public/chrome/directives/active_http_spinner.html

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ body { overflow-x: hidden; }
margin: 0 auto;
background-color: #fff;

&.hidden-chrome { left: 0; }
&-panel {
.flex-parent(@shrink: 0);
box-shadow: -4px 0px 3px rgba(0,0,0,0.2);
Expand Down Expand Up @@ -84,7 +85,6 @@ body { overflow-x: hidden; }

.app-icon {
float: left;
filter: invert(100%);
font-weight: bold;
text-align: center;
font-size: 1.7em;
Expand All @@ -95,6 +95,11 @@ body { overflow-x: hidden; }
> img {
height: 18px;
margin-top: 8px;
filter: invert(100%);
}
> i {
color: #fff;
line-height: @app-icon-height
}
}

Expand Down Expand Up @@ -128,7 +133,7 @@ body { overflow-x: hidden; }
text-decoration: none;
}
img {
filter: invert(100%);
filter: none;
}
}

Expand Down
8 changes: 1 addition & 7 deletions src/ui/public/chrome/directives/append_nav_controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import $ from 'jquery';

import chromeNavControlsRegistry from 'ui/registry/chrome_nav_controls';
import UiModules from 'ui/modules';
import spinnerHtml from './active_http_spinner.html';

const spinner = {
name: 'active http requests',
template: spinnerHtml
};

export default function (chrome, internals) {

Expand All @@ -19,7 +13,7 @@ export default function (chrome, internals) {
const parts = [$element.html()];
const controls = Private(chromeNavControlsRegistry);

for (const control of [spinner, ...controls.inOrder]) {
for (const control of controls.inOrder) {
parts.unshift(
`<!-- nav control ${control.name} -->`,
control.template
Expand Down
1 change: 1 addition & 0 deletions src/ui/public/chrome/directives/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'ui/directives/config';
import './app_switcher';
import kbnChromeProv from './kbn_chrome';
import kbnChromeNavControlsProv from './append_nav_controls';
import './kbn_loading_indicator';

export default function (chrome, internals) {
kbnChromeProv(chrome, internals);
Expand Down
13 changes: 13 additions & 0 deletions src/ui/public/chrome/directives/kbn_loading_indicator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import UiModules from 'ui/modules';
import angular from 'angular';

const spinnerTemplate = '<div class="spinner" ng-show="chrome.httpActive.length"></div>';

UiModules
.get('ui/kibana')
.directive('kbnLoadingIndicator', function ($compile) {
return {
restrict: 'E',
template: spinnerTemplate,
};
});
1 change: 1 addition & 0 deletions src/ui/public/styles/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ a {

.kibana-nav-actions {
margin-left: auto;
line-height: 20px;

.button-group > :last-child {
border-radius: 0;
Expand Down
1 change: 1 addition & 0 deletions src/ui/public/styles/spinner.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
right: 0;
height: 2px;
position: absolute;
z-index: 10;
visibility: visible;
display: block;
animation: move 2s linear infinite;
Expand Down
23 changes: 23 additions & 0 deletions src/ui/public/timepicker/__tests__/toggle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import expect from 'expect.js';
import ngMock from 'ng_mock';
import uiModules from 'ui/modules';
import $ from 'jquery';

describe('kbnGlobalTimepicker', function () {
let compile;
beforeEach(() => {
ngMock.module('kibana');
ngMock.inject(($compile, $rootScope) => {
compile = () => {
const $el = $('<kbn-global-timepicker></kbn-global-timepicker>');
$rootScope.$apply();
$compile($el)($rootScope);
return $el;
};
});
});
it('injects the timepicker into the DOM', () => {
const $el = compile();
expect($el.find('button[ng-click]')).to.have.length(3);
});
});
29 changes: 29 additions & 0 deletions src/ui/public/timepicker/kbn_global_timepicker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import UiModules from 'ui/modules';
import chromeNavControlsRegistry from 'ui/registry/chrome_nav_controls';
import { once, clone } from 'lodash';

import toggleHtml from './kbn_global_timepicker.html';

UiModules
.get('kibana')
.directive('kbnGlobalTimepicker', (timefilter, globalState, $rootScope) => {
const listenForUpdates = once($scope => {
$scope.$listen(timefilter, 'update', (newVal, oldVal) => {
globalState.time = clone(timefilter.time);
globalState.refreshInterval = clone(timefilter.refreshInterval);
globalState.save();
});
});

return {
template: toggleHtml,
link: ($scope, $el, attrs) => {
listenForUpdates($rootScope);

$rootScope.timefilter = timefilter;
$rootScope.toggleRefresh = () => {
timefilter.refreshInterval.pause = !timefilter.refreshInterval.pause;
};
},
};
});
2 changes: 1 addition & 1 deletion src/ui/public/timepicker/timepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'ui/directives/inequality';
import 'ui/timepicker/quick_ranges';
import 'ui/timepicker/refresh_intervals';
import 'ui/timepicker/time_units';
import 'ui/timepicker/toggle';
import 'ui/timepicker/kbn_global_timepicker';
import uiModules from 'ui/modules';
var module = uiModules.get('ui/timepicker');
var notify = new Notifier({
Expand Down
16 changes: 0 additions & 16 deletions src/ui/public/timepicker/toggle.js

This file was deleted.