-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Create "chromeConfigControls" for plugins to add chrome config sections #6151
Changes from 6 commits
20f7f6e
f484adf
070d87d
e6a3680
072dbc6
53ef631
255f2d4
afa3684
096d2ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import ngMock from 'ngMock'; | ||
import $ from 'jquery'; | ||
import expect from 'expect.js'; | ||
|
||
import uiModules from 'ui/modules'; | ||
import chromeConfigControlsRegistry from 'ui/registry/chrome_config_controls'; | ||
import Registry from 'ui/registry/_registry'; | ||
import 'ui/chrome/directives/config_controls'; | ||
import 'ui/directives/config'; | ||
|
||
describe('chrome config controls', function () { | ||
let compile; | ||
let stubRegistry; | ||
|
||
beforeEach(ngMock.module('kibana', function (PrivateProvider) { | ||
stubRegistry = new Registry({ | ||
order: ['order'] | ||
}); | ||
|
||
PrivateProvider.swap(chromeConfigControlsRegistry, stubRegistry); | ||
})); | ||
|
||
beforeEach(ngMock.inject(function ($compile, $rootScope) { | ||
compile = function () { | ||
const $el = $('<kbn-chrome-config-controls></kbn-chrome-config-controls>'); | ||
let $scope = $rootScope.$new(); | ||
$compile($el)($scope); | ||
$scope.$digest(); | ||
return $el; | ||
}; | ||
})); | ||
|
||
it('injects configs from the ui/registry/chrome_config_controls registry', function () { | ||
stubRegistry.register(function () { | ||
return { | ||
name: 'control1', | ||
order: 1, | ||
config: { | ||
} | ||
}; | ||
}); | ||
stubRegistry.register(function () { | ||
return { | ||
name: 'control2', | ||
order: 2, | ||
config: { | ||
} | ||
}; | ||
}); | ||
|
||
var $el = compile(); | ||
expect($el.find('config')).to.have.length(2); | ||
}); | ||
}); |
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div ng-repeat="control in controls"> | ||
<config | ||
config-template="control.config.template" | ||
config-object="control.config.object" | ||
config-submit="::control.config.submit" | ||
config-close="::control.config.close"> | ||
</config> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import $ from 'jquery'; | ||
|
||
import chromeConfigControlsRegistry from 'ui/registry/chrome_config_controls'; | ||
import UiModules from 'ui/modules'; | ||
import configControlsHtml from './config_controls.html'; | ||
|
||
export default function (chrome, internals) { | ||
|
||
UiModules | ||
.get('kibana') | ||
.directive('kbnChromeConfigControls', function (Private) { | ||
const controls = Private(chromeConfigControlsRegistry); | ||
return { | ||
restrict: 'E', | ||
template: configControlsHtml, | ||
controller: function ($scope) { | ||
$scope.controls = controls.inOrder; | ||
} | ||
}; | ||
}); | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,9 +131,9 @@ uiModules.get('kibana/courier') | |
}; | ||
|
||
// Listen for refreshInterval changes | ||
$rootScope.$watchCollection('timefilter.refreshInterval', function () { | ||
var refreshValue = _.get($rootScope, 'timefilter.refreshInterval.value'); | ||
var refreshPause = _.get($rootScope, 'timefilter.refreshInterval.pause'); | ||
$rootScope.$watchCollection('$$timefilter.refreshInterval', function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we can't use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That gist worked for me so I committed it. |
||
var refreshValue = _.get($rootScope, '$$timefilter.refreshInterval.value'); | ||
var refreshPause = _.get($rootScope, '$$timefilter.refreshInterval.pause'); | ||
if (_.isNumber(refreshValue) && !refreshPause) { | ||
self.fetchInterval(refreshValue); | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import _ from 'lodash'; | ||
define(function (require) { | ||
return require('ui/registry/_registry')({ | ||
name: 'chromeConfigControls', | ||
order: ['order'], | ||
index: ['name'] | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<kbn-timepicker | ||
from="configObject.time.from" | ||
to="configObject.time.to" | ||
mode="configObject.time.mode" | ||
active-tab="'filter'" | ||
interval="configObject.refreshInterval"> | ||
</kbn-timepicker> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how I missed this the first time, but we should probably take a tad-bit more care with how we build
configHtml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I guess we have to trust the template value, but I would feel better if we changed the injection of
config.name
to something like:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JSON.stringify didn't work since it add double quotes which messed up the html parsing. I instead add a regex piece in the registry that forces the names to only allow a-z, A-Z, or 0-9.