diff --git a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.js b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.js index 2f64e8d96160d..6c0a4f417209c 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.js +++ b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.js @@ -125,7 +125,7 @@ app.directive('dashboardApp', function ($injector) { // The 'previouslyStored' check is so we only update the time filter on dashboard open, not during // normal cross app navigation. if (dashboardStateManager.getIsTimeSavedWithDashboard() && !getAppState.previouslyStored()) { - dashboardStateManager.syncTimefilterWithDashboard(timefilter, config.get('timepicker:quickRanges')); + dashboardStateManager.syncTimefilterWithDashboard(timefilter); } const updateState = () => { @@ -307,7 +307,7 @@ app.directive('dashboardApp', function ($injector) { // it does on 'open' because it's been saved to the url and the getAppState.previouslyStored() check on // reload will cause it not to sync. if (dashboardStateManager.getIsTimeSavedWithDashboard()) { - dashboardStateManager.syncTimefilterWithDashboard(timefilter, config.get('timepicker:quickRanges')); + dashboardStateManager.syncTimefilterWithDashboard(timefilter); } } diff --git a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_state.test.js b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_state.test.js index 57207ef60e341..b3d817361e6d8 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_state.test.js +++ b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_state.test.js @@ -33,7 +33,6 @@ describe('DashboardState', function () { time: {}, setTime: function (time) { this.time = time; }, }; - const mockQuickTimeRanges = [{ from: 'now/w', to: 'now/w', display: 'This week', section: 0 }]; const mockIndexPattern = { id: 'index1' }; function initDashboardState() { @@ -52,12 +51,10 @@ describe('DashboardState', function () { mockTimefilter.time.from = '2015-09-19 06:31:44.000'; mockTimefilter.time.to = '2015-09-29 06:31:44.000'; - mockTimefilter.time.mode = 'absolute'; initDashboardState(); - dashboardState.syncTimefilterWithDashboard(mockTimefilter, mockQuickTimeRanges); + dashboardState.syncTimefilterWithDashboard(mockTimefilter); - expect(mockTimefilter.time.mode).toBe('quick'); expect(mockTimefilter.time.to).toBe('now/w'); expect(mockTimefilter.time.from).toBe('now/w'); }); @@ -69,12 +66,10 @@ describe('DashboardState', function () { mockTimefilter.time.from = '2015-09-19 06:31:44.000'; mockTimefilter.time.to = '2015-09-29 06:31:44.000'; - mockTimefilter.time.mode = 'absolute'; initDashboardState(); - dashboardState.syncTimefilterWithDashboard(mockTimefilter, mockQuickTimeRanges); + dashboardState.syncTimefilterWithDashboard(mockTimefilter); - expect(mockTimefilter.time.mode).toBe('relative'); expect(mockTimefilter.time.to).toBe('now'); expect(mockTimefilter.time.from).toBe('now-13d'); }); @@ -86,12 +81,10 @@ describe('DashboardState', function () { mockTimefilter.time.from = 'now/w'; mockTimefilter.time.to = 'now/w'; - mockTimefilter.time.mode = 'quick'; initDashboardState(); - dashboardState.syncTimefilterWithDashboard(mockTimefilter, mockQuickTimeRanges); + dashboardState.syncTimefilterWithDashboard(mockTimefilter); - expect(mockTimefilter.time.mode).toBe('absolute'); expect(mockTimefilter.time.to).toBe(savedDashboard.timeTo); expect(mockTimefilter.time.from).toBe(savedDashboard.timeFrom); }); diff --git a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_state_manager.js b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_state_manager.js index cff4438ce3a5d..e8480435d9816 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_state_manager.js +++ b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_state_manager.js @@ -19,7 +19,6 @@ import { i18n } from '@kbn/i18n'; import _ from 'lodash'; -import moment from 'moment'; import { DashboardViewMode } from './dashboard_view_mode'; import { FilterUtils } from './lib/filter_utils'; @@ -144,13 +143,11 @@ export class DashboardStateManager { * or a relative time (now-15m), or a moment object * @param {String|Object} newTimeFilter.from - either a string representing an absolute or a relative time, or a * moment object - * @param {String} newTimeFilter.mode */ handleTimeChange(newTimeFilter) { store.dispatch(updateTimeRange({ from: FilterUtils.convertTimeToUTCString(newTimeFilter.from), to: FilterUtils.convertTimeToUTCString(newTimeFilter.to), - mode: newTimeFilter.mode, })); } @@ -543,30 +540,17 @@ export class DashboardStateManager { * @param {Object} timeFilter * @param {func} timeFilter.setTime * @param {func} timeFilter.setRefreshInterval - * @param quickTimeRanges */ - syncTimefilterWithDashboard(timeFilter, quickTimeRanges) { + syncTimefilterWithDashboard(timeFilter) { if (!this.getIsTimeSavedWithDashboard()) { throw new Error(i18n.translate('kbn.dashboard.stateManager.timeNotSavedWithDashboardErrorMessage', { defaultMessage: 'The time is not saved with this dashboard so should not be synced.', })); } - let mode; - const isMoment = moment(this.savedDashboard.timeTo).isValid(); - if (isMoment) { - mode = 'absolute'; - } else { - const quickTime = _.find( - quickTimeRanges, - (timeRange) => timeRange.from === this.savedDashboard.timeFrom && timeRange.to === this.savedDashboard.timeTo); - - mode = quickTime ? 'quick' : 'relative'; - } timeFilter.setTime({ from: this.savedDashboard.timeFrom, to: this.savedDashboard.timeTo, - mode }); if (this.savedDashboard.refreshInterval) { diff --git a/src/legacy/core_plugins/kibana/public/discover/directives/__snapshots__/no_results.test.js.snap b/src/legacy/core_plugins/kibana/public/discover/directives/__snapshots__/no_results.test.js.snap index a6eacbf0ec7fb..ebc27316d4675 100644 --- a/src/legacy/core_plugins/kibana/public/discover/directives/__snapshots__/no_results.test.js.snap +++ b/src/legacy/core_plugins/kibana/public/discover/directives/__snapshots__/no_results.test.js.snap @@ -425,20 +425,13 @@ Array [
-

+

Expand your time range

- One or more of the indices you’re looking at contains a date field. Your query may not match anything in the current time range, or there may not be any data at all in the currently selected time range. You can try - - and changing the time range to one which contains data. + One or more of the indices you’re looking at contains a date field. Your query may not match anything in the current time range, or there may not be any data at all in the currently selected time range. You can try changing the time range to one which contains data.

diff --git a/src/legacy/core_plugins/kibana/public/discover/directives/no_results.js b/src/legacy/core_plugins/kibana/public/discover/directives/no_results.js index 4427658a2792f..9f57c49977f5a 100644 --- a/src/legacy/core_plugins/kibana/public/discover/directives/no_results.js +++ b/src/legacy/core_plugins/kibana/public/discover/directives/no_results.js @@ -33,18 +33,13 @@ import { EuiText, } from '@elastic/eui'; +// eslint-disable-next-line react/prefer-stateless-function export class DiscoverNoResults extends Component { static propTypes = { shardFailures: PropTypes.array, timeFieldName: PropTypes.string, queryLanguage: PropTypes.string, - isTimePickerOpen: PropTypes.bool.isRequired, getDocLink: PropTypes.func.isRequired, - topNavToggle: PropTypes.func.isRequired, - }; - - onClickTimePickerButton = () => { - this.props.topNavToggle('filter'); }; render() { @@ -53,7 +48,6 @@ export class DiscoverNoResults extends Component { timeFieldName, queryLanguage, getDocLink, - isTimePickerOpen, } = this.props; let shardFailuresMessage; @@ -125,7 +119,7 @@ export class DiscoverNoResults extends Component { -

+

- - - ) - }} + the currently selected time range. You can try changing the time range to one which contains data." />

diff --git a/src/legacy/core_plugins/kibana/public/discover/directives/no_results.test.js b/src/legacy/core_plugins/kibana/public/discover/directives/no_results.test.js index 1aeb66ceccc91..afc9ec14f51c0 100644 --- a/src/legacy/core_plugins/kibana/public/discover/directives/no_results.test.js +++ b/src/legacy/core_plugins/kibana/public/discover/directives/no_results.test.js @@ -18,9 +18,7 @@ */ import React from 'react'; -import { renderWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers'; -import sinon from 'sinon'; -import { findTestSubject } from '@elastic/eui/lib/test'; +import { renderWithIntl } from 'test_utils/enzyme_helpers'; import { DiscoverNoResults, @@ -43,8 +41,6 @@ describe('DiscoverNoResults', () => { const component = renderWithIntl( {}} getDocLink={() => ''} /> ); @@ -58,8 +54,6 @@ describe('DiscoverNoResults', () => { const component = renderWithIntl( {}} getDocLink={() => ''} /> ); @@ -68,45 +62,11 @@ describe('DiscoverNoResults', () => { }); }); - describe('isTimePickerOpen', () => { - test('false is reflected in the aria-expanded state of the button', () => { - const component = renderWithIntl( - {}} - getDocLink={() => ''} - /> - ); - - expect( - component.find('[data-test-subj="discoverNoResultsTimefilter"]')[0].attribs['aria-expanded'] - ).toBe('false'); - }); - - test('true is reflected in the aria-expanded state of the button', () => { - const component = renderWithIntl( - {}} - getDocLink={() => ''} - /> - ); - - expect( - component.find('[data-test-subj="discoverNoResultsTimefilter"]')[0].attribs['aria-expanded'] - ).toBe('true'); - }); - }); - describe('timeFieldName', () => { test('renders time range feedback', () => { const component = renderWithIntl( {}} getDocLink={() => ''} /> ); @@ -120,8 +80,6 @@ describe('DiscoverNoResults', () => { const component = renderWithIntl( {}} getDocLink={() => 'documentation-link'} /> ); @@ -129,22 +87,5 @@ describe('DiscoverNoResults', () => { expect(component).toMatchSnapshot(); }); }); - - describe('topNavToggle', () => { - test('is called whe time picker button is clicked', () => { - const topNavToggleSpy = sinon.stub(); - const component = mountWithIntl( - ''} - /> - ); - - findTestSubject(component, 'discoverNoResultsTimefilter').simulate('click'); - sinon.assert.calledOnce(topNavToggleSpy); - }); - }); }); }); diff --git a/src/legacy/core_plugins/kibana/public/discover/index.html b/src/legacy/core_plugins/kibana/public/discover/index.html index a7ab5f9604644..e109b273a199a 100644 --- a/src/legacy/core_plugins/kibana/public/discover/index.html +++ b/src/legacy/core_plugins/kibana/public/discover/index.html @@ -71,8 +71,6 @@

`); $compile($el)($scope); $scope.$digest(); @@ -224,7 +224,7 @@ describe('AggTable Directive', function () { '', '2014-09-28', '9,283', - 'September 28th 2014, 00:00:00.000', + 'Sep 28, 2014 @ 00:00:00.000', '1', '11' ]); @@ -234,7 +234,7 @@ describe('AggTable Directive', function () { '', '2014-10-03', '220,943', - 'October 3rd 2014, 00:00:00.000', + 'Oct 3, 2014 @ 00:00:00.000', '239', '837' ]); diff --git a/src/ui/public/angular-bootstrap/datepicker/datepicker.html b/src/ui/public/angular-bootstrap/datepicker/datepicker.html deleted file mode 100755 index 807ef80a936a5..0000000000000 --- a/src/ui/public/angular-bootstrap/datepicker/datepicker.html +++ /dev/null @@ -1,5 +0,0 @@ -
- - - -
diff --git a/src/ui/public/angular-bootstrap/datepicker/datepicker.js b/src/ui/public/angular-bootstrap/datepicker/datepicker.js deleted file mode 100755 index 1a90e1e88218e..0000000000000 --- a/src/ui/public/angular-bootstrap/datepicker/datepicker.js +++ /dev/null @@ -1,625 +0,0 @@ -import { i18n } from '@kbn/i18n'; - -angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootstrap.position']) - -.constant('datepickerConfig', { - formatDay: 'dd', - formatMonth: 'MMMM', - formatYear: 'yyyy', - formatDayHeader: 'EEE', - formatDayTitle: 'MMMM yyyy', - formatMonthTitle: 'yyyy', - datepickerMode: 'day', - minMode: 'day', - maxMode: 'year', - showWeeks: true, - startingDay: 0, - yearRange: 20, - minDate: null, - maxDate: null -}) - -.controller('DatepickerController', ['$scope', '$attrs', '$parse', '$interpolate', '$timeout', '$log', 'dateFilter', 'datepickerConfig', function($scope, $attrs, $parse, $interpolate, $timeout, $log, dateFilter, datepickerConfig) { - var self = this, - ngModelCtrl = { $setViewValue: angular.noop }; // nullModelCtrl; - - // Modes chain - this.modes = ['day', 'month', 'year']; - - // Configuration attributes - angular.forEach(['formatDay', 'formatMonth', 'formatYear', 'formatDayHeader', 'formatDayTitle', 'formatMonthTitle', - 'minMode', 'maxMode', 'showWeeks', 'startingDay', 'yearRange'], function( key, index ) { - self[key] = angular.isDefined($attrs[key]) ? (index < 8 ? $interpolate($attrs[key])($scope.$parent) : $scope.$parent.$eval($attrs[key])) : datepickerConfig[key]; - }); - - // Watchable date attributes - angular.forEach(['minDate', 'maxDate'], function( key ) { - if ( $attrs[key] ) { - $scope.$parent.$watch($parse($attrs[key]), function(value) { - self[key] = value ? new Date(value) : null; - self.refreshView(); - }); - } else { - self[key] = datepickerConfig[key] ? new Date(datepickerConfig[key]) : null; - } - }); - - $scope.datepickerMode = $scope.datepickerMode || datepickerConfig.datepickerMode; - $scope.uniqueId = 'datepicker-' + $scope.$id + '-' + Math.floor(Math.random() * 10000); - this.activeDate = angular.isDefined($attrs.initDate) ? $scope.$parent.$eval($attrs.initDate) : new Date(); - - $scope.isActive = function(dateObject) { - if (self.compare(dateObject.date, self.activeDate) === 0) { - $scope.activeDateId = dateObject.uid; - return true; - } - return false; - }; - - this.init = function( ngModelCtrl_ ) { - ngModelCtrl = ngModelCtrl_; - - ngModelCtrl.$render = function() { - self.render(); - }; - }; - - this.render = function() { - if ( ngModelCtrl.$modelValue ) { - var date = new Date( ngModelCtrl.$modelValue ), - isValid = !isNaN(date); - - if ( isValid ) { - this.activeDate = date; - } else { - $log.error('Datepicker directive: "ng-model" value must be a Date object, a number of milliseconds since 01.01.1970 or a string representing an RFC2822 or ISO 8601 date.'); - } - ngModelCtrl.$setValidity('date', isValid); - } - this.refreshView(); - }; - - this.refreshView = function() { - if ( this.element ) { - this._refreshView(); - - var date = ngModelCtrl.$modelValue ? new Date(ngModelCtrl.$modelValue) : null; - ngModelCtrl.$setValidity('date-disabled', !date || (this.element && !this.isDisabled(date))); - } - }; - - this.createDateObject = function(date, format) { - var model = ngModelCtrl.$modelValue ? new Date(ngModelCtrl.$modelValue) : null; - return { - date: date, - label: dateFilter(date, format), - selected: model && this.compare(date, model) === 0, - disabled: this.isDisabled(date), - current: this.compare(date, new Date()) === 0 - }; - }; - - this.isDisabled = function( date ) { - return ((this.minDate && this.compare(date, this.minDate) < 0) || (this.maxDate && this.compare(date, this.maxDate) > 0) || ($attrs.dateDisabled && $scope.dateDisabled({date: date, mode: $scope.datepickerMode}))); - }; - - // Split array into smaller arrays - this.split = function(arr, size) { - var arrays = []; - while (arr.length > 0) { - arrays.push(arr.splice(0, size)); - } - return arrays; - }; - - $scope.select = function( date ) { - if ( $scope.datepickerMode === self.minMode ) { - var dt = ngModelCtrl.$modelValue ? new Date( ngModelCtrl.$modelValue ) : new Date(0, 0, 0, 0, 0, 0, 0); - dt.setFullYear( date.getFullYear(), date.getMonth(), date.getDate() ); - ngModelCtrl.$setViewValue( dt ); - ngModelCtrl.$render(); - } else { - self.activeDate = date; - $scope.datepickerMode = self.modes[ self.modes.indexOf( $scope.datepickerMode ) - 1 ]; - focusElement(); - } - }; - - $scope.move = function( direction ) { - var year = self.activeDate.getFullYear() + direction * (self.step.years || 0), - month = self.activeDate.getMonth() + direction * (self.step.months || 0); - self.activeDate.setFullYear(year, month, 1); - self.refreshView(); - }; - - $scope.toggleMode = function( direction ) { - direction = direction || 1; - - if (($scope.datepickerMode === self.maxMode && direction === 1) || ($scope.datepickerMode === self.minMode && direction === -1)) { - return; - } - - $scope.datepickerMode = self.modes[ self.modes.indexOf( $scope.datepickerMode ) + direction ]; - focusElement(); - }; - - // Key event mapper - $scope.keys = { 13:'enter', 32:'space', 33:'pageup', 34:'pagedown', 35:'end', 36:'home', 37:'left', 38:'up', 39:'right', 40:'down' }; - - var focusElement = function() { - $timeout(function() { - self.element[0].focus(); - }, 0 , false); - }; - - // Listen for focus requests from popup directive - $scope.$on('datepicker.focus', focusElement); -}]) - -.directive( 'datepicker', function () { - return { - restrict: 'EA', - replace: true, - templateUrl: 'template/datepicker/datepicker.html', - scope: { - datepickerMode: '=?', - dateDisabled: '&' - }, - require: ['datepicker', '?^ngModel'], - controller: 'DatepickerController', - link: function(scope, element, attrs, ctrls) { - var datepickerCtrl = ctrls[0], ngModelCtrl = ctrls[1]; - - if ( ngModelCtrl ) { - datepickerCtrl.init( ngModelCtrl ); - } - } - }; -}) - -.directive('daypicker', ['dateFilter', function (dateFilter) { - return { - restrict: 'EA', - replace: true, - templateUrl: 'template/datepicker/day.html', - require: '^datepicker', - link: function(scope, element, attrs, ctrl) { - scope.showWeeks = ctrl.showWeeks; - - ctrl.step = { months: 1 }; - ctrl.element = element; - - var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; - function getDaysInMonth( year, month ) { - return ((month === 1) && (year % 4 === 0) && ((year % 100 !== 0) || (year % 400 === 0))) ? 29 : DAYS_IN_MONTH[month]; - } - - function getDates(startDate, n) { - var dates = new Array(n), current = new Date(startDate), i = 0; - current.setHours(12); // Prevent repeated dates because of timezone bug - while ( i < n ) { - dates[i++] = new Date(current); - current.setDate( current.getDate() + 1 ); - } - return dates; - } - - ctrl._refreshView = function() { - var year = ctrl.activeDate.getFullYear(), - month = ctrl.activeDate.getMonth(), - firstDayOfMonth = new Date(year, month, 1), - difference = ctrl.startingDay - firstDayOfMonth.getDay(), - numDisplayedFromPreviousMonth = (difference > 0) ? 7 - difference : - difference, - firstDate = new Date(firstDayOfMonth); - - if ( numDisplayedFromPreviousMonth > 0 ) { - firstDate.setDate( - numDisplayedFromPreviousMonth + 1 ); - } - - // 42 is the number of days on a six-month calendar - var days = getDates(firstDate, 42); - for (var i = 0; i < 42; i ++) { - days[i] = angular.extend(ctrl.createDateObject(days[i], ctrl.formatDay), { - secondary: days[i].getMonth() !== month, - uid: scope.uniqueId + '-' + i - }); - } - - scope.labels = new Array(7); - for (var j = 0; j < 7; j++) { - scope.labels[j] = { - abbr: dateFilter(days[j].date, ctrl.formatDayHeader), - full: dateFilter(days[j].date, 'EEEE') - }; - } - - scope.title = dateFilter(ctrl.activeDate, ctrl.formatDayTitle); - scope.rows = ctrl.split(days, 7); - - if ( scope.showWeeks ) { - scope.weekNumbers = []; - var weekNumber = getISO8601WeekNumber( scope.rows[0][0].date ), - numWeeks = scope.rows.length; - while( scope.weekNumbers.push(weekNumber++) < numWeeks ) {} - } - }; - - ctrl.compare = function(date1, date2) { - return (new Date( date1.getFullYear(), date1.getMonth(), date1.getDate() ) - new Date( date2.getFullYear(), date2.getMonth(), date2.getDate() ) ); - }; - - function getISO8601WeekNumber(date) { - var checkDate = new Date(date); - checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7)); // Thursday - var time = checkDate.getTime(); - checkDate.setMonth(0); // Compare with Jan 1 - checkDate.setDate(1); - return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1; - } - - ctrl.handleKeyDown = function( key, evt ) { - var date = ctrl.activeDate.getDate(); - - if (key === 'left') { - date = date - 1; // up - } else if (key === 'up') { - date = date - 7; // down - } else if (key === 'right') { - date = date + 1; // down - } else if (key === 'down') { - date = date + 7; - } else if (key === 'pageup' || key === 'pagedown') { - var month = ctrl.activeDate.getMonth() + (key === 'pageup' ? - 1 : 1); - ctrl.activeDate.setMonth(month, 1); - date = Math.min(getDaysInMonth(ctrl.activeDate.getFullYear(), ctrl.activeDate.getMonth()), date); - } else if (key === 'home') { - date = 1; - } else if (key === 'end') { - date = getDaysInMonth(ctrl.activeDate.getFullYear(), ctrl.activeDate.getMonth()); - } - ctrl.activeDate.setDate(date); - }; - - ctrl.refreshView(); - } - }; -}]) - -.directive('monthpicker', ['dateFilter', function (dateFilter) { - return { - restrict: 'EA', - replace: true, - templateUrl: 'template/datepicker/month.html', - require: '^datepicker', - link: function(scope, element, attrs, ctrl) { - ctrl.step = { years: 1 }; - ctrl.element = element; - - ctrl._refreshView = function() { - var months = new Array(12), - year = ctrl.activeDate.getFullYear(); - - for ( var i = 0; i < 12; i++ ) { - months[i] = angular.extend(ctrl.createDateObject(new Date(year, i, 1), ctrl.formatMonth), { - uid: scope.uniqueId + '-' + i - }); - } - - scope.title = dateFilter(ctrl.activeDate, ctrl.formatMonthTitle); - scope.rows = ctrl.split(months, 3); - }; - - ctrl.compare = function(date1, date2) { - return new Date( date1.getFullYear(), date1.getMonth() ) - new Date( date2.getFullYear(), date2.getMonth() ); - }; - - ctrl.handleKeyDown = function( key, evt ) { - var date = ctrl.activeDate.getMonth(); - - if (key === 'left') { - date = date - 1; // up - } else if (key === 'up') { - date = date - 3; // down - } else if (key === 'right') { - date = date + 1; // down - } else if (key === 'down') { - date = date + 3; - } else if (key === 'pageup' || key === 'pagedown') { - var year = ctrl.activeDate.getFullYear() + (key === 'pageup' ? - 1 : 1); - ctrl.activeDate.setFullYear(year); - } else if (key === 'home') { - date = 0; - } else if (key === 'end') { - date = 11; - } - ctrl.activeDate.setMonth(date); - }; - - ctrl.refreshView(); - } - }; -}]) - -.directive('yearpicker', ['dateFilter', function (dateFilter) { - return { - restrict: 'EA', - replace: true, - templateUrl: 'template/datepicker/year.html', - require: '^datepicker', - link: function(scope, element, attrs, ctrl) { - var range = ctrl.yearRange; - - ctrl.step = { years: range }; - ctrl.element = element; - - function getStartingYear( year ) { - return parseInt((year - 1) / range, 10) * range + 1; - } - - ctrl._refreshView = function() { - var years = new Array(range); - - for ( var i = 0, start = getStartingYear(ctrl.activeDate.getFullYear()); i < range; i++ ) { - years[i] = angular.extend(ctrl.createDateObject(new Date(start + i, 0, 1), ctrl.formatYear), { - uid: scope.uniqueId + '-' + i - }); - } - - scope.title = [years[0].label, years[range - 1].label].join(' - '); - scope.rows = ctrl.split(years, 5); - scope.yearRange = ctrl.yearRange; - }; - - ctrl.compare = function(date1, date2) { - return date1.getFullYear() - date2.getFullYear(); - }; - - ctrl.handleKeyDown = function( key, evt ) { - var date = ctrl.activeDate.getFullYear(); - - if (key === 'left') { - date = date - 1; // up - } else if (key === 'up') { - date = date - 5; // down - } else if (key === 'right') { - date = date + 1; // down - } else if (key === 'down') { - date = date + 5; - } else if (key === 'pageup' || key === 'pagedown') { - date += (key === 'pageup' ? - 1 : 1) * ctrl.step.years; - } else if (key === 'home') { - date = getStartingYear( ctrl.activeDate.getFullYear() ); - } else if (key === 'end') { - date = getStartingYear( ctrl.activeDate.getFullYear() ) + range - 1; - } - ctrl.activeDate.setFullYear(date); - }; - - ctrl.refreshView(); - } - }; -}]) - -.constant('datepickerPopupConfig', { - datepickerPopup: 'yyyy-MM-dd', - currentText: i18n.translate('common.ui.angularBootstrap.datepicker.datepickerPopupConfig.todayLabel', { - defaultMessage: 'Today' - }), - clearText: i18n.translate('common.ui.angularBootstrap.datepicker.datepickerPopupConfig.clearLabel', { - defaultMessage: 'Clear' - }), - closeText: i18n.translate('common.ui.angularBootstrap.datepicker.datepickerPopupConfig.doneLabel', { - defaultMessage: 'Done' - }), - closeOnDateSelection: true, - appendToBody: false, - showButtonBar: true -}) - -.directive('datepickerPopup', ['$compile', '$parse', '$document', '$position', 'dateFilter', 'dateParser', 'datepickerPopupConfig', -function ($compile, $parse, $document, $position, dateFilter, dateParser, datepickerPopupConfig) { - return { - restrict: 'EA', - require: 'ngModel', - scope: { - isOpen: '=?', - currentText: '@', - clearText: '@', - closeText: '@', - dateDisabled: '&' - }, - link: function(scope, element, attrs, ngModel) { - var dateFormat, - closeOnDateSelection = angular.isDefined(attrs.closeOnDateSelection) ? scope.$parent.$eval(attrs.closeOnDateSelection) : datepickerPopupConfig.closeOnDateSelection, - appendToBody = angular.isDefined(attrs.datepickerAppendToBody) ? scope.$parent.$eval(attrs.datepickerAppendToBody) : datepickerPopupConfig.appendToBody; - - scope.showButtonBar = angular.isDefined(attrs.showButtonBar) ? scope.$parent.$eval(attrs.showButtonBar) : datepickerPopupConfig.showButtonBar; - - scope.getText = function( key ) { - return scope[key + 'Text'] || datepickerPopupConfig[key + 'Text']; - }; - - attrs.$observe('datepickerPopup', function(value) { - dateFormat = value || datepickerPopupConfig.datepickerPopup; - ngModel.$render(); - }); - - // popup element used to display calendar - var popupEl = angular.element('
'); - popupEl.attr({ - 'ng-model': 'date', - 'ng-change': 'dateSelection()' - }); - - function cameltoDash( string ){ - return string.replace(/([A-Z])/g, function($1) { return '-' + $1.toLowerCase(); }); - } - - // datepicker element - var datepickerEl = angular.element(popupEl.children()[0]); - if ( attrs.datepickerOptions ) { - angular.forEach(scope.$parent.$eval(attrs.datepickerOptions), function( value, option ) { - datepickerEl.attr( cameltoDash(option), value ); - }); - } - - scope.watchData = {}; - angular.forEach(['minDate', 'maxDate', 'datepickerMode'], function( key ) { - if ( attrs[key] ) { - var getAttribute = $parse(attrs[key]); - scope.$parent.$watch(getAttribute, function(value){ - scope.watchData[key] = value; - }); - datepickerEl.attr(cameltoDash(key), 'watchData.' + key); - - // Propagate changes from datepicker to outside - if ( key === 'datepickerMode' ) { - var setAttribute = getAttribute.assign; - scope.$watch('watchData.' + key, function(value, oldvalue) { - if ( value !== oldvalue ) { - setAttribute(scope.$parent, value); - } - }); - } - } - }); - if (attrs.dateDisabled) { - datepickerEl.attr('date-disabled', 'dateDisabled({ date: date, mode: mode })'); - } - - function parseDate(viewValue) { - if (!viewValue) { - ngModel.$setValidity('date', true); - return null; - } else if (angular.isDate(viewValue) && !isNaN(viewValue)) { - ngModel.$setValidity('date', true); - return viewValue; - } else if (angular.isString(viewValue)) { - var date = dateParser.parse(viewValue, dateFormat) || new Date(viewValue); - if (isNaN(date)) { - ngModel.$setValidity('date', false); - return undefined; - } else { - ngModel.$setValidity('date', true); - return date; - } - } else { - ngModel.$setValidity('date', false); - return undefined; - } - } - ngModel.$parsers.unshift(parseDate); - - // Inner change - scope.dateSelection = function(dt) { - if (angular.isDefined(dt)) { - scope.date = dt; - } - ngModel.$setViewValue(scope.date); - ngModel.$render(); - - if ( closeOnDateSelection ) { - scope.isOpen = false; - element[0].focus(); - } - }; - - element.bind('input change keyup', function() { - scope.$apply(function() { - scope.date = ngModel.$modelValue; - }); - }); - - // Outer change - ngModel.$render = function() { - var date = ngModel.$viewValue ? dateFilter(ngModel.$viewValue, dateFormat) : ''; - element.val(date); - scope.date = parseDate( ngModel.$modelValue ); - }; - - var documentClickBind = function(event) { - if (scope.isOpen && event.target !== element[0]) { - scope.$apply(function() { - scope.isOpen = false; - }); - } - }; - - var keydown = function(evt, noApply) { - scope.keydown(evt); - }; - element.bind('keydown', keydown); - - scope.keydown = function(evt) { - if (evt.which === 27) { - evt.preventDefault(); - evt.stopPropagation(); - scope.close(); - } else if (evt.which === 40 && !scope.isOpen) { - scope.isOpen = true; - } - }; - - scope.$watch('isOpen', function(value) { - if (value) { - scope.$broadcast('datepicker.focus'); - scope.position = appendToBody ? $position.offset(element) : $position.position(element); - scope.position.top = scope.position.top + element.prop('offsetHeight'); - - $document.bind('click', documentClickBind); - } else { - $document.unbind('click', documentClickBind); - } - }); - - scope.select = function( date ) { - if (date === 'today') { - var today = new Date(); - if (angular.isDate(ngModel.$modelValue)) { - date = new Date(ngModel.$modelValue); - date.setFullYear(today.getFullYear(), today.getMonth(), today.getDate()); - } else { - date = new Date(today.setHours(0, 0, 0, 0)); - } - } - scope.dateSelection( date ); - }; - - scope.close = function() { - scope.isOpen = false; - element[0].focus(); - }; - - var $popup = $compile(popupEl)(scope); - // Prevent jQuery cache memory leak (template is now redundant after linking) - popupEl.remove(); - - if ( appendToBody ) { - $document.find('body').append($popup); - } else { - element.after($popup); - } - - scope.$on('$destroy', function() { - $popup.remove(); - element.unbind('keydown', keydown); - $document.unbind('click', documentClickBind); - }); - } - }; -}]) - -.directive('datepickerPopupWrap', function() { - return { - restrict:'EA', - replace: true, - transclude: true, - templateUrl: 'template/datepicker/popup.html', - link:function (scope, element, attrs) { - element.bind('click', function(event) { - event.preventDefault(); - event.stopPropagation(); - }); - } - }; -}); diff --git a/src/ui/public/angular-bootstrap/datepicker/day.html b/src/ui/public/angular-bootstrap/datepicker/day.html deleted file mode 100755 index 764c57a237230..0000000000000 --- a/src/ui/public/angular-bootstrap/datepicker/day.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - - - - -
-
- - - - - -
-
- {{label.abbr}} -
- {{ weekNumbers[$index] }} - - -
diff --git a/src/ui/public/angular-bootstrap/datepicker/month.html b/src/ui/public/angular-bootstrap/datepicker/month.html deleted file mode 100755 index 08b2327afc377..0000000000000 --- a/src/ui/public/angular-bootstrap/datepicker/month.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - -
-
- - - - - -
-
- -
diff --git a/src/ui/public/angular-bootstrap/datepicker/popup.html b/src/ui/public/angular-bootstrap/datepicker/popup.html deleted file mode 100755 index 11c4a6ba25e7e..0000000000000 --- a/src/ui/public/angular-bootstrap/datepicker/popup.html +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/src/ui/public/angular-bootstrap/datepicker/year.html b/src/ui/public/angular-bootstrap/datepicker/year.html deleted file mode 100755 index 52c955d8f8eb5..0000000000000 --- a/src/ui/public/angular-bootstrap/datepicker/year.html +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - -
-
- - - - - -
-
- -
diff --git a/src/ui/public/angular-bootstrap/index.js b/src/ui/public/angular-bootstrap/index.js index c01f7f4a21064..b519abcaf5dee 100644 --- a/src/ui/public/angular-bootstrap/index.js +++ b/src/ui/public/angular-bootstrap/index.js @@ -21,7 +21,6 @@ angular.module('ui.bootstrap', [ 'ui.bootstrap.buttons', 'ui.bootstrap.dateparser', 'ui.bootstrap.position', - 'ui.bootstrap.datepicker', 'ui.bootstrap.dropdown', 'ui.bootstrap.modal', 'ui.bootstrap.pagination', @@ -36,11 +35,6 @@ angular.module('ui.bootstrap', [ angular.module('ui.bootstrap.tpls', [ 'template/alert/alert.html', - 'template/datepicker/datepicker.html', - 'template/datepicker/day.html', - 'template/datepicker/month.html', - 'template/datepicker/popup.html', - 'template/datepicker/year.html', 'template/modal/backdrop.html', 'template/modal/window.html', 'template/pagination/pager.html', @@ -65,7 +59,6 @@ import './bindHtml/bindHtml'; import './buttons/buttons'; import './collapse/collapse'; import './dateparser/dateparser'; -import './datepicker/datepicker'; import './dropdown/dropdown'; import './modal/modal'; import './pagination/pagination'; @@ -85,36 +78,6 @@ angular.module('template/alert/alert.html', []).run(['$templateCache', function( $templateCache.put('template/alert/alert.html', alert); }]); -import datepicker from './datepicker/datepicker.html'; - -angular.module('template/datepicker/datepicker.html', []).run(['$templateCache', function($templateCache) { - $templateCache.put('template/datepicker/datepicker.html', datepicker); -}]); - -import day from './datepicker/day.html'; - -angular.module('template/datepicker/day.html', []).run(['$templateCache', function($templateCache) { - $templateCache.put('template/datepicker/day.html', day); -}]); - -import month from './datepicker/month.html'; - -angular.module('template/datepicker/month.html', []).run(['$templateCache', function($templateCache) { - $templateCache.put('template/datepicker/month.html', month); -}]); - -import popup from './datepicker/popup.html'; - -angular.module('template/datepicker/popup.html', []).run(['$templateCache', function($templateCache) { - $templateCache.put('template/datepicker/popup.html', popup); -}]); - -import year from './datepicker/year.html'; - -angular.module('template/datepicker/year.html', []).run(['$templateCache', function($templateCache) { - $templateCache.put('template/datepicker/year.html', year); -}]); - import backdrop from './modal/backdrop.html'; angular.module('template/modal/backdrop.html', []).run(['$templateCache', function($templateCache) { diff --git a/src/ui/public/chrome/config/filter.html b/src/ui/public/chrome/config/filter.html deleted file mode 100644 index 91953acb23175..0000000000000 --- a/src/ui/public/chrome/config/filter.html +++ /dev/null @@ -1,9 +0,0 @@ - - diff --git a/src/ui/public/chrome/config/interval.html b/src/ui/public/chrome/config/interval.html deleted file mode 100644 index 9055429800c1a..0000000000000 --- a/src/ui/public/chrome/config/interval.html +++ /dev/null @@ -1,9 +0,0 @@ - - diff --git a/src/ui/public/directives/__tests__/timepicker.js b/src/ui/public/directives/__tests__/timepicker.js deleted file mode 100644 index 7eb9180a453a9..0000000000000 --- a/src/ui/public/directives/__tests__/timepicker.js +++ /dev/null @@ -1,454 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import angular from 'angular'; -import moment from 'moment'; -import expect from 'expect.js'; -import _ from 'lodash'; -import sinon from 'sinon'; -import ngMock from 'ng_mock'; -import 'plugins/kibana/visualize/index'; -import 'plugins/kibana/dashboard/index'; -import 'plugins/kibana/discover/index'; - - -// TODO: This should not be needed, timefilter is only included here, it should move - -let $parentScope; - -let $scope; - -let $elem; -const anchor = '2014-01-01T06:06:06.666Z'; - -const init = function () { - // Load the application - ngMock.module('kibana'); - - // Create the scope - ngMock.inject(function ($rootScope, $compile) { - - // Give us a scope - $parentScope = $rootScope; - - // Add some parameters to it - const timefilter = { - time: { - from: moment().subtract(15, 'minutes'), - to: moment(), - mode: undefined - }, - refreshInterval: { - value: 0, - display: 'Off' - } - }; - $parentScope.timefilter = timefilter; - $parentScope.updateInterval = sinon.spy(); - $parentScope.updateFilter = sinon.spy(); - - // Create the element - $elem = angular.element( - '' + - '' - ); - - // And compile it - $compile($elem)($parentScope); - - // Fire a digest cycle - $elem.scope().$digest(); - - // Grab the isolate scope so we can test it - $scope = $elem.isolateScope(); - }); -}; - - -describe('timepicker directive', function () { - const sandbox = sinon.createSandbox(); - - beforeEach(function () { - // Stub out the clock so 'now' doesn't move - sandbox.useFakeTimers(moment(anchor).valueOf()); - - init(); - }); - - afterEach(function () { - sandbox.restore(); - }); - - describe('tabs', function () { - it('should contain two tabs', function () { - expect($elem.find('.tab-pane').length).to.be(2); - }); - }); - - describe('refresh interval', function () { - beforeEach(function () { - ngMock.inject(function ($rootScope) { - $rootScope.$apply(); - }); - }); - - it('should contain a list of options', function () { - expect($elem.find('.kbn-refresh-section').length).to.be.greaterThan(0); - }); - - it('should have a $scope.setRefreshInterval() that calls handler', function () { - $scope.setRefreshInterval({ value: 10000 }); - sinon.assert.calledOnce($parentScope.updateInterval); - expect($parentScope.updateInterval.firstCall.args[0]).to.have.property('value', 10000); - }); - - it('should unpause when setRefreshInterval is called without pause:true', function () { - $scope.setRefreshInterval({ value: 1000, pause: true }); - expect($parentScope.updateInterval.getCall(0).args[0]).to.have.property('pause', true); - - $scope.setRefreshInterval({ value: 1000, pause: false }); - expect($parentScope.updateInterval.getCall(1).args[0]).to.have.property('pause', false); - - $scope.setRefreshInterval({ value: 1000 }); - expect($parentScope.updateInterval.getCall(2).args[0]).to.have.property('pause', false); - }); - - - it('should highlight the current active interval', function () { - $scope.interval = { value: 300000 }; - $elem.scope().$digest(); - expect($elem.find('.refresh-interval-active').length).to.be(1); - expect($elem.find('.refresh-interval-active').text().trim()).to.be('5 minutes'); - }); - }); - - describe('mode setting', function () { - it('should be in quick mode by default', function () { - expect($scope.mode).to.be('quick'); - }); - - it('should highlight the right mode', function () { - expect($elem.find('.kbn-timepicker-modes .euiTab-isSelected').text().trim()).to.be('Quick'); - - // Each of the 3 modes - const modes = ['absolute', 'relative', 'quick']; - _.each(modes, function (mode) { - $scope.setMode(mode); - $scope.$digest(); - expect($elem.find('.kbn-timepicker-modes .euiTab-isSelected').text().trim().toLowerCase()).to.be(mode); - }); - }); - }); - - describe('quick mode', function () { - - beforeEach(function () { - $scope.setMode('quick'); - $scope.$digest(); - }); - - it('should contain 3 lists of options', function () { - expect($elem.find('.kbn-timepicker-section .list-unstyled').length).to.be(3); - }); - - it('should have a $scope.setQuick() that calls handler', function () { - $scope.setQuick('now', 'now'); - sinon.assert.calledOnce($parentScope.updateFilter); - expect($parentScope.updateFilter.firstCall.args[0]).to.be('now'); - expect($parentScope.updateFilter.firstCall.args[1]).to.be('now'); - }); - }); - - describe('relative mode', function () { - - beforeEach(function () { - $scope.setMode('relative'); - $scope.$digest(); - }); - - it('has a preview of the "from" input', function () { - const preview = $elem.find('.kbn-timepicker-section span[ng-show="relative.from.preview"]'); - expect(preview.text().trim()).to.be(moment().subtract(15, 'minutes').format($scope.format)); - }); - - it('has a disabled "to" field that contains "Now"', function () { - expect($elem.find('.kbn-timepicker-section span[ng-show="relative.to.preview"]').text().trim()).to.be('Now'); - }); - - it('has a submit handler', function () { - const form = $elem.find('form[ng-submit="applyRelative()"]'); - expect(form.length).to.be(1); - }); - - it('disables the submit button if the form is invalid', function () { - let button; - button = $elem.find('button[disabled]'); - expect(button.length).to.be(0); - - // Make the form invalid - $scope.relative.from.count = -3; - $scope.formatRelative('from'); - $scope.$digest(); - - button = $elem.find('button[disabled]'); - expect(button.length).to.be(1); - }); - - it('has a dropdown bound to relative.from.unit that contains all of the intervals', function () { - const select = $elem.find('.kbn-timepicker-section select[ng-model="relative.from.unit"]'); - expect(select.length).to.be(1); - expect(select.find('option').length).to.be(14); - - // Check each relative option, make sure it is in the list - _.each($scope.relativeOptions, function (unit, i) { - expect(select.find('option')[i].text).to.be(unit.text); - }); - }); - - it('has a checkbox that is checked when rounding is enabled', function () { - const checkbox = $elem.find('.kbn-timepicker-section input[ng-model="relative.from.round"]'); - expect(checkbox.length).to.be(1); - - // Rounding is disabled by default - expect(checkbox.prop('checked')).to.be(false); - - // Enable rounding - $scope.relative.from.round = true; - $scope.$digest(); - expect(checkbox.prop('checked')).to.be(true); - }); - - it('rounds the preview down to the unit when rounding is enabled', function () { - // Enable rounding - $scope.relative.from.round = true; - $scope.relative.from.count = 0; - - _.each($scope.units, function (longUnit, shortUnit) { - $scope.relative.from.count = 0; - $scope.relative.from.unit = shortUnit; - $scope.formatRelative('from'); - - // The preview should match the start of the unit e.g., the start of the minute - expect($scope.relative.from.preview).to.be(moment().startOf(longUnit).format($scope.format)); - }); - }); - - it('does not round the preview down to the unit when rounding is disable', function () { - // Disable rounding - $scope.relative.from.round = false; - $scope.relative.from.count = 1; - - _.each($scope.units, function (longUnit, shortUnit) { - $scope.relative.from.unit = shortUnit; - $scope.formatRelative('from'); - - const matches = shortUnit.match(/([smhdwMy])(\+)?/); - let unit; - let opp = '-'; - if (matches) { - unit = matches[1]; - opp = matches[2]; - } - - const fn = opp === '+' ? 'add' : 'subtract'; - - // The preview should match the start of the unit e.g., the start of the minute - expect($scope.relative.from.preview).to.be(moment()[fn](1, unit).format($scope.format)); - }); - }); - - it('has a $scope.applyRelative() that sets from and to based on relative.round, relative.count and relative.unit', function () { - // Disable rounding - $scope.relative.from.round = false; - $scope.relative.from.count = 1; - $scope.relative.from.unit = 's'; - $scope.applyRelative(); - sinon.assert.calledOnce($parentScope.updateFilter); - expect($parentScope.updateFilter.getCall(0).args[0]).to.be('now-1s'); - - $scope.relative.from.count = 2; - $scope.relative.from.unit = 'm'; - $scope.applyRelative(); - expect($parentScope.updateFilter.getCall(1).args[0]).to.be('now-2m'); - - $scope.relative.from.count = 3; - $scope.relative.from.unit = 'h'; - $scope.applyRelative(); - expect($parentScope.updateFilter.getCall(2).args[0]).to.be('now-3h'); - - // Enable rounding - $scope.relative.from.round = true; - $scope.relative.from.count = 7; - $scope.relative.from.unit = 'd'; - $scope.applyRelative(); - expect($parentScope.updateFilter.getCall(3).args[0]).to.be('now-7d/d'); - }); - - it('updates the input fields when the scope variables are changed', function () { - const input = $elem.find('.kbn-timepicker-section input[ng-model="relative.from.count"]'); - const select = $elem.find('.kbn-timepicker-section select[ng-model="relative.from.unit"]'); - - $scope.relative.from.count = 5; - $scope.$digest(); - expect(input.val()).to.be('5'); - - - // Should update the selected option - _.each($scope.units, function (longUnit, shortUnit) { - $scope.relative.from.unit = shortUnit; - $scope.$digest(); - - expect(select.val().split(':')[1]).to.be(shortUnit); - }); - }); - }); - - describe('absolute mode', function () { - - let inputs; - - beforeEach(function () { - $scope.setMode('absolute'); - $scope.$digest(); - - inputs = { - fromInput: $elem.find('.kbn-timepicker-section input[ng-model="absolute.from"]'), - toInput: $elem.find('.kbn-timepicker-section input[ng-model="absolute.to"]'), - fromCalendar: $elem.find('.kbn-timepicker-section div[ng-model="pickFromDate"] '), - toCalendar: $elem.find('.kbn-timepicker-section div[ng-model="pickToDate"] '), - }; - }); - - it('should have input boxes for absolute.from and absolute.to', function () { - expect(inputs.fromInput.length).to.be(1); - expect(inputs.toInput.length).to.be(1); - }); - - it('should have tables that contain calendars bound to absolute.from and absolute.to', function () { - expect(inputs.fromCalendar.length).to.be(1); - expect(inputs.toCalendar.length).to.be(1); - }); - - it('should present a timeframe of 15 minutes ago to now if scope.from and scope.to are not set', function () { - delete $scope.from; - delete $scope.to; - $scope.setMode('absolute'); - $scope.$digest(); - - expect($scope.absolute.from.valueOf()).to.be(moment().subtract(15, 'minutes').valueOf()); - expect($scope.absolute.to.valueOf()).to.be(moment().valueOf()); - }); - - it('should update its own variables if timefilter time is updated', function () { - $scope.setMode('absolute'); - $scope.$digest(); - - const startDate = moment('1980-01-01T00:11:02.001Z'); - const endDate = moment('1983-10-11T00:03:32.051Z'); - - $parentScope.timefilter.time.from = startDate; - $parentScope.timefilter.time.to = endDate; - $parentScope.$digest(); - - expect($scope.absolute.from.valueOf()).to.be(startDate.valueOf()); - expect($scope.absolute.to.valueOf()).to.be(endDate.valueOf()); - }); - - it('should disable the "Go" button if from > to', function () { - $scope.absolute.from = moment('2012-02-01'); - $scope.absolute.to = moment('2012-02-11'); - $scope.$digest(); - expect($elem.find('[data-test-subj="timepickerGoButton"]').attr('disabled')).to.be(undefined); - - $scope.absolute.from = moment('2012-02-12'); - $scope.absolute.to = moment('2012-02-11'); - $scope.$digest(); - expect($elem.find('[data-test-subj="timepickerGoButton"]').attr('disabled')).to.be('disabled'); - }); - - it('should only copy its input to scope.from and scope.to when scope.applyAbsolute() is called', function () { - $scope.from = 'now-30m'; - $scope.to = 'now'; - - $scope.absolute.from = moment('2012-02-01'); - $scope.absolute.to = moment('2012-02-11'); - expect($scope.from).to.be('now-30m'); - expect($scope.to).to.be('now'); - - $scope.applyAbsolute(); - expect($parentScope.updateFilter.firstCall.args[0]).to.eql(moment('2012-02-01')); - expect($parentScope.updateFilter.firstCall.args[1]).to.eql(moment('2012-02-11')); - - $scope.$digest(); - }); - - it('should set from/to to start/end of day if set from datepicker', function () { - $scope.pickFromDate(new Date('2012-02-01 12:00')); - $scope.pickToDate(new Date('2012-02-11 12:00')); - $scope.applyAbsolute(); - - expect($parentScope.updateFilter.firstCall.args[0].valueOf()).to.be(moment('2012-02-01 00:00:00.000').valueOf()); - expect($parentScope.updateFilter.firstCall.args[1].valueOf()).to.be(moment('2012-02-11 23:59:59.999').valueOf()); - }); - - it('should allow setting hour/minute/second after setting from datepicker', function () { - $scope.pickFromDate(new Date('2012-02-01 12:00')); - $scope.pickToDate(new Date('2012-02-11 12:00')); - $scope.applyAbsolute(); - - expect($parentScope.updateFilter.firstCall.args[0].valueOf()).to.be(moment('2012-02-01 00:00:00.000').valueOf()); - expect($parentScope.updateFilter.firstCall.args[1].valueOf()).to.be(moment('2012-02-11 23:59:59.999').valueOf()); - - $scope.absolute.from = moment('2012-02-01 01:23:45'); - $scope.absolute.to = moment('2012-02-11 12:34:56'); - $scope.applyAbsolute(); - - expect($parentScope.updateFilter.secondCall.args[0].valueOf()).to.be(moment('2012-02-01 01:23:45').valueOf()); - expect($parentScope.updateFilter.secondCall.args[1].valueOf()).to.be(moment('2012-02-11 12:34:56').valueOf()); - }); - - describe('datepicker timezone issue', function () { - it('should ignore the timezone from the datepicker because it does not respect dateFormat:tz advanced setting', function () { - moment.tz.setDefault('UTC'); - - $scope.pickFromDate(new Date('2012-02-01 12:00-05:00')); - $scope.pickToDate(new Date('2012-02-11 12:00-05:00')); - $scope.$digest(); - - const formattedFrom = inputs.fromInput.val(); - const formattedTo = inputs.toInput.val(); - - expect(formattedFrom).to.be('2012-02-01 00:00:00.000'); - expect(formattedTo).to.be('2012-02-11 23:59:59.999'); - }); - - after(function () { - moment.tz.setDefault('Browser'); - }); - }); - - }); -}); diff --git a/src/ui/public/filter_bar/lib/__tests__/change_time_filter.test.js b/src/ui/public/filter_bar/lib/__tests__/change_time_filter.test.js index 6f02c06aea5b1..b9916c1f08a06 100644 --- a/src/ui/public/filter_bar/lib/__tests__/change_time_filter.test.js +++ b/src/ui/public/filter_bar/lib/__tests__/change_time_filter.test.js @@ -25,7 +25,7 @@ jest.mock('ui/chrome', get: (key) => { switch(key) { case 'timepicker:timeDefaults': - return { from: 'now-15m', to: 'now', mode: 'quick' }; + return { from: 'now-15m', to: 'now' }; case 'timepicker:refreshIntervalDefaults': return { display: 'Off', pause: false, value: 0 }; default: @@ -47,8 +47,7 @@ describe('changeTimeFilter()', function () { test('should change the timefilter to match the range gt/lt', function () { const filter = { range: { '@timestamp': { gt, lt } } }; changeTimeFilter(filter); - const { mode, to, from } = timefilter.getTime(); - expect(mode).to.be('absolute'); + const { to, from } = timefilter.getTime(); expect(to).to.be(new Date(lt).toISOString()); expect(from).to.be(new Date(gt).toISOString()); }); @@ -56,8 +55,7 @@ describe('changeTimeFilter()', function () { test('should change the timefilter to match the range gte/lte', function () { const filter = { range: { '@timestamp': { gte: gt, lte: lt } } }; changeTimeFilter(filter); - const { mode, to, from } = timefilter.getTime(); - expect(mode).to.be('absolute'); + const { to, from } = timefilter.getTime(); expect(to).to.be(new Date(lt).toISOString()); expect(from).to.be(new Date(gt).toISOString()); }); diff --git a/src/ui/public/filters/__tests__/moment.js b/src/ui/public/filters/__tests__/moment.js index ffc404630c4ca..e3550df031ee7 100644 --- a/src/ui/public/filters/__tests__/moment.js +++ b/src/ui/public/filters/__tests__/moment.js @@ -57,11 +57,11 @@ describe('moment formatting filter', function () { // MMMM Do YYYY, HH:mm:ss.SSS it('should format moments', function () { - expect(filter(moment())).to.be('January 1st 2014, 06:06:06.666'); + expect(filter(moment())).to.be('Jan 1, 2014 @ 06:06:06.666'); }); it('should format dates', function () { - expect(filter(new Date())).to.be('January 1st 2014, 06:06:06.666'); + expect(filter(new Date())).to.be('Jan 1, 2014 @ 06:06:06.666'); }); it('should return the original value if passed anything other than a moment or Date', function () { diff --git a/src/ui/public/kbn_top_nav/kbn_top_nav.js b/src/ui/public/kbn_top_nav/kbn_top_nav.js index b08d469b20642..5daac89f97121 100644 --- a/src/ui/public/kbn_top_nav/kbn_top_nav.js +++ b/src/ui/public/kbn_top_nav/kbn_top_nav.js @@ -38,10 +38,10 @@ /** * kbnTopNav directive * - * The top section that shows the timepicker, load, share and save dialogues. + * The top section that optionally shows the timepicker and menu items. * * ``` - * + * * ``` * * Menu items/templates are passed to the kbnTopNav via the config attribute @@ -149,6 +149,10 @@ module.directive('kbnTopNav', function (Private) { initTopNav(topNavConfig, null); + if (!_.has($scope, 'showTimepickerInTopNav')) { + $scope.showTimepickerInTopNav = true; + } + return $scope.kbnTopNav; }, diff --git a/src/ui/public/kbn_top_nav/kbn_top_nav_controller.js b/src/ui/public/kbn_top_nav/kbn_top_nav_controller.js index d3df4bb6f704f..00400b93f994c 100644 --- a/src/ui/public/kbn_top_nav/kbn_top_nav_controller.js +++ b/src/ui/public/kbn_top_nav/kbn_top_nav_controller.js @@ -20,8 +20,6 @@ import { capitalize, isArray, isFunction, get } from 'lodash'; import chrome from '../chrome'; -import filterTemplate from '../chrome/config/filter.html'; -import intervalTemplate from '../chrome/config/interval.html'; import { i18n } from '@kbn/i18n'; export function KbnTopNavControllerProvider($compile) { @@ -34,10 +32,7 @@ export function KbnTopNavControllerProvider($compile) { this.opts = []; this.menuItems = []; this.currentKey = null; - this.templates = { - interval: intervalTemplate, - filter: filterTemplate, - }; + this.templates = {}; this.locals = new Map(); this.addItems(opts); diff --git a/src/ui/public/react_components.js b/src/ui/public/react_components.js index 3475eefba926e..542fe19d8a09d 100644 --- a/src/ui/public/react_components.js +++ b/src/ui/public/react_components.js @@ -29,6 +29,7 @@ import { EuiColorPicker, EuiIconTip, EuiCallOut, + EuiSuperDatePicker, } from '@elastic/eui'; import { uiModules } from './modules'; @@ -46,3 +47,19 @@ app.directive('colorPicker', reactDirective => reactDirective(EuiColorPicker)); app.directive('iconTip', reactDirective => reactDirective(EuiIconTip, ['content', 'type', 'position', 'title', 'color'])); app.directive('callOut', reactDirective => reactDirective(EuiCallOut, ['title', 'color', 'size', 'iconType', 'children'])); + +app.directive('superDatePicker', reactDirective => reactDirective(EuiSuperDatePicker, [ + 'start', + 'end', + 'isPaused', + 'refreshInterval', + 'commonlyUsedRanges', + 'dateFormat', + 'recentlyUsedRanges', + 'onTimeChange', + 'onRefreshChange', + 'isAutoRefreshOnly', + 'commonlyUsedRanges', + 'dateFormat', + 'recentlyUsedRanges', +])); diff --git a/src/ui/public/styles/bootstrap/bootstrap_dark.less b/src/ui/public/styles/bootstrap/bootstrap_dark.less index 7f9e37f6294e9..459efed37dd75 100644 --- a/src/ui/public/styles/bootstrap/bootstrap_dark.less +++ b/src/ui/public/styles/bootstrap/bootstrap_dark.less @@ -62,7 +62,7 @@ @import "responsive-utilities.less"; // Minimal usage // Decent usage in multiple areas -@import "dropdowns.less"; // Used in console, datepicker, watcher +@import "dropdowns.less"; // Used in console, watcher @import "input-groups.less"; // Used in ML, typeahead, reporting, graph @import "pagination.less"; @import "pager.less"; diff --git a/src/ui/public/styles/bootstrap_dark.less b/src/ui/public/styles/bootstrap_dark.less index 0e1dd7b017825..a0079df56a4e2 100644 --- a/src/ui/public/styles/bootstrap_dark.less +++ b/src/ui/public/styles/bootstrap_dark.less @@ -2,6 +2,3 @@ // COMPILER FOR BOOTSTRAP @import "~ui/styles/bootstrap/bootstrap_dark"; - -// Components -- waiting on EUI conversion -@import "~ui/timepicker/timepicker"; diff --git a/src/ui/public/styles/bootstrap_light.less b/src/ui/public/styles/bootstrap_light.less index 9c15f6c0d5646..b251875489fb5 100644 --- a/src/ui/public/styles/bootstrap_light.less +++ b/src/ui/public/styles/bootstrap_light.less @@ -5,4 +5,3 @@ // Components -- waiting on EUI conversion @import "~ui/filter_bar/filter_bar"; -@import "~ui/timepicker/timepicker"; diff --git a/src/ui/public/timefilter/time_history.d.ts b/src/ui/public/timefilter/time_history.d.ts index 4a7331dbb8c58..bc13fb06d03b1 100644 --- a/src/ui/public/timefilter/time_history.d.ts +++ b/src/ui/public/timefilter/time_history.d.ts @@ -20,7 +20,6 @@ interface TimeRange { from: string; to: string; - mode?: string; } export interface TimeHistory { diff --git a/src/ui/public/timefilter/time_history.js b/src/ui/public/timefilter/time_history.js index 50d6d0d3917e0..1ae908d174f97 100644 --- a/src/ui/public/timefilter/time_history.js +++ b/src/ui/public/timefilter/time_history.js @@ -19,13 +19,15 @@ import moment from 'moment'; import { PersistedLog } from '../persisted_log'; -import { TIME_MODES } from '../timepicker/modes'; class TimeHistory { constructor() { const historyOptions = { maxLength: 10, - filterDuplicates: true + filterDuplicates: true, + isDuplicate: (oldItem, newItem) => { + return oldItem.from === newItem.from && oldItem.to === newItem.to; + } }; this.history = new PersistedLog('kibana.timepicker.timeHistory', historyOptions); } @@ -38,7 +40,6 @@ class TimeHistory { // time from/to can be strings or moment objects - convert to strings so always dealing with same types const justStringsTime = { from: moment.isMoment(time.from) ? time.from.toISOString() : time.from, - mode: TIME_MODES.RECENT, to: moment.isMoment(time.to) ? time.to.toISOString() : time.to }; this.history.add(justStringsTime); diff --git a/src/ui/public/timefilter/timefilter.js b/src/ui/public/timefilter/timefilter.js index 8f2bbd799efa4..f2d2f4dea5c6b 100644 --- a/src/ui/public/timefilter/timefilter.js +++ b/src/ui/public/timefilter/timefilter.js @@ -51,7 +51,6 @@ class Timefilter extends SimpleEmitter { * @param {Object} time * @property {string|moment} time.from * @property {string|moment} time.to - * @property {string} time.mode (quick | relative | absolute) */ setTime = (time) => { // Object.assign used for partially composed updates @@ -60,7 +59,6 @@ class Timefilter extends SimpleEmitter { this._time = { from: newTime.from, to: newTime.to, - mode: newTime.mode }; timeHistory.add(this._time); this.emit('timeUpdate'); diff --git a/src/ui/public/timefilter/timefilter.test.js b/src/ui/public/timefilter/timefilter.test.js index f35f5addaa250..eb07711126e48 100644 --- a/src/ui/public/timefilter/timefilter.test.js +++ b/src/ui/public/timefilter/timefilter.test.js @@ -25,7 +25,7 @@ jest.mock('ui/chrome', get: (key) => { switch (key) { case 'timepicker:timeDefaults': - return { from: 'now-15m', to: 'now', mode: 'quick' }; + return { from: 'now-15m', to: 'now' }; case 'timepicker:refreshIntervalDefaults': return { pause: false, value: 0 }; default: @@ -69,15 +69,14 @@ describe('setTime', () => { timefilter.setTime({ from: 0, to: 1, - mode: 'absolute' }); timefilter.on('timeUpdate', update); timefilter.on('fetch', fetch); }); test('should update time', () => { - timefilter.setTime({ from: 5, to: 10, mode: 'absolute' }); - expect(timefilter.getTime()).to.eql({ from: 5, to: 10, mode: 'absolute' }); + timefilter.setTime({ from: 5, to: 10 }); + expect(timefilter.getTime()).to.eql({ from: 5, to: 10 }); }); test('should not add unexpected object keys to time state', () => { @@ -88,7 +87,7 @@ describe('setTime', () => { test('should allow partial updates to time', () => { timefilter.setTime({ from: 5, to: 10 }); - expect(timefilter.getTime()).to.eql({ from: 5, to: 10, mode: 'absolute' }); + expect(timefilter.getTime()).to.eql({ from: 5, to: 10 }); }); test('not emit anything if the time has not changed', () => { @@ -106,11 +105,10 @@ describe('setTime', () => { test('should return strings and not moment objects', () => { const from = moment().subtract(15, 'minutes'); const to = moment(); - timefilter.setTime({ to, from, mode: 'absolute' }); + timefilter.setTime({ to, from }); expect(timefilter.getTime()).to.eql({ from: from.toISOString(), to: to.toISOString(), - mode: 'absolute' }); }); }); diff --git a/src/ui/public/timepicker/__tests__/parse_relative_parts.js b/src/ui/public/timepicker/__tests__/parse_relative_parts.js deleted file mode 100644 index 52e4dc41262e7..0000000000000 --- a/src/ui/public/timepicker/__tests__/parse_relative_parts.js +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { parseRelativeString, parseRelativeParts } from '../parse_relative_parts'; -import expect from 'expect.js'; -import moment from 'moment'; - -describe('parseRelativeParts(from, to, relativeOptions)', () => { - - it('should parse relative string', () => { - const results = parseRelativeString('now-2h'); - expect(results).to.have.property('count', 2); - expect(results).to.have.property('unit', 'h'); - expect(results).to.have.property('round', false); - }); - - it('should parse now', () => { - const results = parseRelativeString('now'); - expect(results).to.have.property('count', 0); - expect(results).to.have.property('unit', 's'); - expect(results).to.have.property('round', false); - }); - - it('should parse set round options', () => { - const results = parseRelativeString('now-2h/h'); - expect(results).to.have.property('round', true); - }); - - it('should parse now-2h to now-10m/m', () => { - expect(parseRelativeParts('now-2h', 'now-10m/m')).to.eql({ - from: { - count: 2, - unit: 'h', - round: false - }, - to: { - count: 10, - unit: 'm', - round: true - } - }); - }); - - it('should parse now-2h to now+10m/m', () => { - expect(parseRelativeParts('now-2h', 'now+10m/m')).to.eql({ - from: { - count: 2, - unit: 'h', - round: false - }, - to: { - count: 10, - unit: 'm+', - round: true - } - }); - }); - - it('should parse 3 months ago to now', () => { - expect(parseRelativeParts(moment().subtract(3, 'M'), moment())).to.eql({ - from: { - count: 3, - unit: 'M', - round: false - }, - to: { - count: 0, - unit: 's', - round: false - } - }); - }); - - it('should parse 3 months ago to 15 minutes ago', () => { - const from = moment().subtract(3, 'M'); - const to = moment().subtract(15, 'm'); - expect(parseRelativeParts(from, to)).to.eql({ - from: { - count: 3, - unit: 'M', - round: false - }, - to: { - count: 15, - unit: 'm', - round: false - } - }); - }); - - it('should parse 3 months ago to 2 hours from now', () => { - const from = moment().subtract(3, 'M'); - const to = moment().add(2, 'h'); - expect(parseRelativeParts(from, to)).to.eql({ - from: { - count: 3, - unit: 'M', - round: false - }, - to: { - count: 2, - unit: 'h+', - round: false - } - }); - }); - -}); diff --git a/src/ui/public/timepicker/__tests__/time_navigation.js b/src/ui/public/timepicker/__tests__/time_navigation.js deleted file mode 100644 index ab5e9cef1b053..0000000000000 --- a/src/ui/public/timepicker/__tests__/time_navigation.js +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import expect from 'expect.js'; -import moment from 'moment'; -import { timeNavigation } from '../time_navigation'; - -describe('timeNavigation', () => { - let bounds; - - beforeEach(() => { - bounds = { - min: moment('2016-01-01T00:00:00.000Z'), - max: moment('2016-01-01T00:15:00.000Z') - }; - }); - - it('should step forward by the amount of the duration', () => { - const { from, to, mode } = timeNavigation.stepForward(bounds); - expect(from).to.be('2016-01-01T00:15:00.001Z'); - expect(to).to.be('2016-01-01T00:30:00.001Z'); - expect(mode).to.be('absolute'); - }); - - it('should step backward by the amount of the duration', () => { - const { from, to, mode } = timeNavigation.stepBackward(bounds); - expect(from).to.be('2015-12-31T23:44:59.999Z'); - expect(to).to.be('2015-12-31T23:59:59.999Z'); - expect(mode).to.be('absolute'); - }); - - it('should zoom out to be double the original duration', () => { - const { from, to, mode } = timeNavigation.zoomOut(bounds); - expect(from).to.be('2015-12-31T23:52:30.000Z'); - expect(to).to.be('2016-01-01T00:22:30.000Z'); - expect(mode).to.be('absolute'); - }); - - it('should zoom in to be half the original duration', () => { - const { from, to, mode } = timeNavigation.zoomIn(bounds); - expect(from).to.be('2016-01-01T00:03:45.000Z'); - expect(to).to.be('2016-01-01T00:11:15.000Z'); - expect(mode).to.be('absolute'); - }); -}); diff --git a/src/ui/public/timepicker/__tests__/toggle.js b/src/ui/public/timepicker/__tests__/toggle.js deleted file mode 100644 index 57684bcc3c8e5..0000000000000 --- a/src/ui/public/timepicker/__tests__/toggle.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import expect from 'expect.js'; -import ngMock from 'ng_mock'; -import $ from 'jquery'; -import { timefilter } from 'ui/timefilter'; - -describe('kbnGlobalTimepicker', function () { - let compile; - let scope; - - beforeEach(() => { - ngMock.module('kibana'); - ngMock.inject(($compile, $rootScope) => { - scope = $rootScope.$new(); - compile = () => { - const $el = $(''); - $el.data('$kbnTopNavController', {}); // Mock the kbnTopNav - $compile($el)(scope); - scope.$apply(); - return $el; - }; - }); - }); - - it('injects the timepicker into the DOM', () => { - const $el = compile(); - expect($el.attr('data-test-subj')).to.be('globalTimepicker'); - }); - - it('sets data-shared-timefilter-* using the timefilter when auto-refresh selector is enabled', function () { - const minString = '2000-01-01T00:00:00Z'; - const maxString = '2001-01-01T00:00:00Z'; - - timefilter.enableAutoRefreshSelector(); - timefilter.disableTimeRangeSelector(); - timefilter.setTime({ - from: minString, - to: maxString, - mode: 'absolute' - }); - - const $el = compile(); - - expect($el.attr('data-shared-timefilter-from')).to.eql(minString); - expect($el.attr('data-shared-timefilter-to')).to.eql(maxString); - }); - - it('sets data-shared-timefilter-* using the timefilter when time range selector is enabled', function () { - const minString = '2000-01-01T00:00:00Z'; - const maxString = '2001-01-01T00:00:00Z'; - - timefilter.disableAutoRefreshSelector(); - timefilter.enableTimeRangeSelector(); - timefilter.setTime({ - from: minString, - to: maxString, - mode: 'absolute' - }); - - const $el = compile(); - - expect($el.attr('data-shared-timefilter-from')).to.eql(minString); - expect($el.attr('data-shared-timefilter-to')).to.eql(maxString); - }); - - it(`doesn't set data-shared-timefilter-* when auto-refresh and time range selectors are both disabled`, function () { - const minString = '2000-01-01T00:00:00Z'; - const maxString = '2001-01-01T00:00:00Z'; - - timefilter.disableAutoRefreshSelector(); - timefilter.disableTimeRangeSelector(); - timefilter.setTime({ - from: minString, - to: maxString, - mode: 'absolute' - }); - - const $el = compile(); - - expect($el.attr('data-shared-timefilter-from')).to.eql(''); - expect($el.attr('data-shared-timefilter-to')).to.eql(''); - }); -}); diff --git a/src/ui/public/timepicker/absolute_panel/index.js b/src/ui/public/timepicker/absolute_panel/index.js deleted file mode 100644 index 0433e8fe86a6f..0000000000000 --- a/src/ui/public/timepicker/absolute_panel/index.js +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import './kbn_timepicker_absolute_panel'; diff --git a/src/ui/public/timepicker/absolute_panel/kbn_timepicker_absolute_panel.html b/src/ui/public/timepicker/absolute_panel/kbn_timepicker_absolute_panel.html deleted file mode 100644 index d12e78c1c14f1..0000000000000 --- a/src/ui/public/timepicker/absolute_panel/kbn_timepicker_absolute_panel.html +++ /dev/null @@ -1,110 +0,0 @@ -
-
-
-
- - -
- - - -
-
- - -
- - -
- -
- -
-
- -
-
- - -
- - - -
-
- - - - - - - -
- -
-
-
- -
- - - -
-
diff --git a/src/ui/public/timepicker/absolute_panel/kbn_timepicker_absolute_panel.js b/src/ui/public/timepicker/absolute_panel/kbn_timepicker_absolute_panel.js deleted file mode 100644 index 37504cec058c4..0000000000000 --- a/src/ui/public/timepicker/absolute_panel/kbn_timepicker_absolute_panel.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import template from './kbn_timepicker_absolute_panel.html'; -import { uiModules } from '../../modules'; - -const module = uiModules.get('ui/timepicker'); - -module.directive('kbnTimepickerAbsolutePanel', function () { - return { - restrict: 'E', - replace: true, - scope: { - absolute: '=', - applyAbsolute: '&', - format: '=', - pickFromDate: '=', - pickToDate: '=', - setToNow: '&' - }, - template, - controller: function () { - } - }; -}); diff --git a/src/ui/public/timepicker/index.js b/src/ui/public/timepicker/index.js index 2cea4af1a5430..5e68b5bc41103 100644 --- a/src/ui/public/timepicker/index.js +++ b/src/ui/public/timepicker/index.js @@ -17,4 +17,4 @@ * under the License. */ -import './timepicker'; +import './kbn_global_timepicker'; diff --git a/src/ui/public/timepicker/kbn_global_timepicker.html b/src/ui/public/timepicker/kbn_global_timepicker.html index 9413ef4f35ad7..8ef4dcfe1c960 100644 --- a/src/ui/public/timepicker/kbn_global_timepicker.html +++ b/src/ui/public/timepicker/kbn_global_timepicker.html @@ -1,90 +1,20 @@
- - - - - - - - - +
diff --git a/src/ui/public/timepicker/kbn_global_timepicker.js b/src/ui/public/timepicker/kbn_global_timepicker.js index 8d4dcbae0be16..2ff0e8b1c8f54 100644 --- a/src/ui/public/timepicker/kbn_global_timepicker.js +++ b/src/ui/public/timepicker/kbn_global_timepicker.js @@ -20,16 +20,12 @@ import { uiModules } from '../modules'; import toggleHtml from './kbn_global_timepicker.html'; -import { timeNavigation } from './time_navigation'; import { timefilter } from 'ui/timefilter'; -import { prettyDuration } from './pretty_duration'; -import { prettyInterval } from './pretty_interval'; +import { timeHistory } from 'ui/timefilter/time_history'; uiModules .get('kibana') .directive('kbnGlobalTimepicker', (globalState, config) => { - const getConfig = (...args) => config.get(...args); - const listenForUpdates = ($scope) => { $scope.$listenAndDigestAsync(timefilter, 'refreshIntervalUpdate', () => { setTimefilterValues($scope); @@ -48,44 +44,51 @@ uiModules $scope.timefilterValues = { refreshInterval: refreshInterval, time: time, - display: { - time: prettyDuration(time.from, time.to, getConfig), - refreshInterval: prettyInterval(refreshInterval.value), - }, isAutoRefreshSelectorEnabled: timefilter.isAutoRefreshSelectorEnabled, isTimeRangeSelectorEnabled: timefilter.isTimeRangeSelectorEnabled, }; + $scope.recentlyUsedRanges = timeHistory.get().map(({ from, to }) => { + return { + start: from, + end: to, + }; + }); } return { template: toggleHtml, replace: true, - require: '^kbnTopNav', - link: ($scope, element, attributes, kbnTopNav) => { + link: ($scope) => { listenForUpdates($scope); setTimefilterValues($scope); - $scope.toggleRefresh = () => { - timefilter.toggleRefresh(); - }; + config.watch('timepicker:quickRanges', (quickRanges) => { + // quickRanges is null when timepicker:quickRanges is set to default value + const ranges = quickRanges ? quickRanges : config.get('timepicker:quickRanges'); + $scope.commonlyUsedRanges = ranges.map(({ from, to, display }) => { + return { + start: from, + end: to, + label: display, + }; + }); + }); - $scope.forward = function () { - timefilter.setTime(timeNavigation.stepForward(timefilter.getBounds())); - }; - - $scope.back = function () { - timefilter.setTime(timeNavigation.stepBackward(timefilter.getBounds())); - }; + config.watch('dateFormat', (dateFormat) => { + // dateFormat is null when dateFormat is set to default value + $scope.dateFormat = dateFormat ? dateFormat : config.get('dateFormat'); + }); - $scope.updateFilter = function (from, to, mode) { - timefilter.setTime({ from, to, mode }); - kbnTopNav.close('filter'); + $scope.updateFilter = function ({ start, end }) { + timefilter.setTime({ from: start, to: end }); }; - $scope.updateInterval = function (interval) { - timefilter.setRefreshInterval(interval); - kbnTopNav.close('interval'); + $scope.updateInterval = function ({ isPaused, refreshInterval }) { + timefilter.setRefreshInterval({ + pause: isPaused, + value: refreshInterval ? refreshInterval : $scope.timefilterValues.refreshInterval.value + }); }; $scope.getSharedTimeFilterFromDate = function () { diff --git a/src/ui/public/timepicker/modes.js b/src/ui/public/timepicker/modes.js deleted file mode 100644 index 150c1c6d59a4e..0000000000000 --- a/src/ui/public/timepicker/modes.js +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export const TIME_MODES = { - ABSOLUTE: 'absolute', - QUICK: 'quick', - RECENT: 'recent', - RELATIVE: 'relative', -}; diff --git a/src/ui/public/timepicker/parse_relative_parts.js b/src/ui/public/timepicker/parse_relative_parts.js deleted file mode 100644 index 1c4ffbf69f567..0000000000000 --- a/src/ui/public/timepicker/parse_relative_parts.js +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import dateMath from '@elastic/datemath'; -import moment from 'moment'; -import _ from 'lodash'; -import { relativeOptions } from './relative_options'; - -export function parseRelativeString(part) { - let results = {}; - const matches = _.isString(part) && part.match(/now(([\-\+])([0-9]+)([smhdwMy])(\/[smhdwMy])?)?/); - - const isNow = matches && !matches[1]; - const operator = matches && matches[2]; - const count = matches && matches[3]; - const unit = matches && matches[4]; - const roundBy = matches && matches[5]; - - if (isNow) { - return { count: 0, unit: 's', round: false }; - } - - if (count && unit) { - results.count = parseInt(count, 10); - results.unit = unit; - if (operator === '+') results.unit += '+'; - results.round = roundBy ? true : false; - return results; - - } else { - results = { count: 0, unit: 's', round: false }; - const duration = moment.duration(moment().diff(dateMath.parse(part))); - const units = _.pluck(_.clone(relativeOptions).reverse(), 'value') - .filter(s => /^[smhdwMy]$/.test(s)); - let unitOp = ''; - for (let i = 0; i < units.length; i++) { - const as = duration.as(units[i]); - if (as < 0) unitOp = '+'; - if (Math.abs(as) > 1) { - results.count = Math.round(Math.abs(as)); - results.unit = units[i] + unitOp; - results.round = false; - break; - } - } - return results; - } - - -} - -export function parseRelativeParts(from, to) { - const results = {}; - results.from = parseRelativeString(from); - results.to = parseRelativeString(to); - if (results.from && results.to) return results; -} diff --git a/src/ui/public/timepicker/pretty_duration.js b/src/ui/public/timepicker/pretty_duration.js deleted file mode 100644 index 0ce945cdb08be..0000000000000 --- a/src/ui/public/timepicker/pretty_duration.js +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import dateMath from '@elastic/datemath'; -import moment from 'moment'; -import { timeUnits } from './time_units'; -import { i18n } from '@kbn/i18n'; - -const TIME_NOW = 'now'; - -function cantLookup(timeFrom, timeTo, dateFormat) { - const displayFrom = formatTimeString(timeFrom, dateFormat); - const displayTo = formatTimeString(timeTo, dateFormat, true); - return i18n.translate('common.ui.timepicker.fullTimeRange', { - defaultMessage: '{displayFrom} to {displayTo}', - values: { - displayFrom, - displayTo - } - }); -} - -function formatTimeString(timeString, dateFormat, roundUp = false) { - if (moment(timeString).isValid()) { - return moment(timeString).format(dateFormat); - } else { - if (timeString === TIME_NOW) { - return i18n.translate('common.ui.timepicker.timeNow', { defaultMessage: 'now' }); - } else { - const tryParse = dateMath.parse(timeString, { roundUp: roundUp }); - return moment.isMoment(tryParse) ? '~ ' + tryParse.fromNow() : timeString; - } - } -} - -function getDateLookupKey(startDate, endDate) { - return startDate + ' to ' + endDate; -} - -export function prettyDuration(timeFrom, timeTo, getConfig) { - const quickRanges = getConfig('timepicker:quickRanges'); - const dateFormat = getConfig('dateFormat'); - - const lookupByRange = {}; - quickRanges.forEach((frame) => { - lookupByRange[getDateLookupKey(frame.from, frame.to)] = frame; - }); - - // If both parts are date math, try to look up a reasonable string - if (timeFrom && timeTo && !moment.isMoment(timeFrom) && !moment.isMoment(timeTo)) { - const tryLookup = lookupByRange[getDateLookupKey(timeFrom, timeTo)]; - if (tryLookup) { - return tryLookup.display; - } else { - const [start, end] = timeFrom.toString().split('-'); - if (timeTo.toString() === TIME_NOW && start === TIME_NOW && end) { - const [amount, unitId] = end.split('/'); - let text = i18n.translate('common.ui.timepicker.timeUntilNowStr', { - defaultMessage: 'Last {amount}', - values: { amount } - }); - - if (unitId) { - text = text + ' ' + i18n.translate('common.ui.timepicker.roundedTo', { - defaultMessage: 'rounded to the {unit}', - values: { unit: timeUnits[unitId] } - }); - } - return text; - } else { - return cantLookup(timeFrom, timeTo, dateFormat); - } - } - } - - // If at least one part is a moment, try to make pretty strings by parsing date math - return cantLookup(timeFrom, timeTo, dateFormat); -} diff --git a/src/ui/public/timepicker/pretty_duration.test.js b/src/ui/public/timepicker/pretty_duration.test.js deleted file mode 100644 index 3a49c7c939634..0000000000000 --- a/src/ui/public/timepicker/pretty_duration.test.js +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import expect from 'expect.js'; -import moment from 'moment-timezone'; -import { prettyDuration } from './pretty_duration'; - -const config = {}; -moment.tz.setDefault('UTC'); -config.dateFormat = 'MMMM Do YYYY, HH:mm:ss.SSS'; -config['timepicker:quickRanges'] = [ - { - from: 'now-15m', - to: 'now', - display: 'quick range 15 minutes custom display', - } -]; -const getConfig = (key) => config[key]; - -test('quick range', () => { - const timeFrom = 'now-15m'; - const timeTo = 'now'; - expect(prettyDuration(timeFrom, timeTo, getConfig)).to.be('quick range 15 minutes custom display'); -}); - -describe('relative range', () => { - test('from = now', () => { - const timeFrom = 'now-1M'; - const timeTo = 'now'; - expect(prettyDuration(timeFrom, timeTo, getConfig)).to.be('Last 1M'); - }); - - test('from is in past', () => { - const timeFrom = 'now-17m'; - const timeTo = 'now-15m'; - expect(prettyDuration(timeFrom, timeTo, getConfig)).to.be('~ 17 minutes ago to ~ 15 minutes ago'); - }); -}); - -describe('absolute range', () => { - test('dates in string format)', () => { - const timeFrom = '2018-01-17T18:57:57.149Z'; - const timeTo = '2018-01-17T20:00:00.000Z'; - expect(prettyDuration(timeFrom, timeTo, getConfig)).to.be('January 17th 2018, 18:57:57.149 to January 17th 2018, 20:00:00.000'); - }); - - test('dates as moment objects', () => { - const timeFrom = moment('2018-01-17T18:57:57.149Z'); - const timeTo = moment('2018-01-17T20:00:00.000Z'); - expect(prettyDuration(timeFrom, timeTo, getConfig)).to.be('January 17th 2018, 18:57:57.149 to January 17th 2018, 20:00:00.000'); - }); -}); - - diff --git a/src/ui/public/timepicker/pretty_interval.js b/src/ui/public/timepicker/pretty_interval.js deleted file mode 100644 index 57ba6340ed336..0000000000000 --- a/src/ui/public/timepicker/pretty_interval.js +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { i18n } from '@kbn/i18n'; - -const MS_IN_SECOND = 1000; -const MS_IN_MINUTE = 60 * MS_IN_SECOND; -const MS_IN_HOUR = 60 * MS_IN_MINUTE; -const MS_IN_DAY = 24 * MS_IN_HOUR; - -export function prettyInterval(intervalInMs) { - let interval; - if (intervalInMs === 0) { - return i18n.translate('common.ui.timepicker.off', { defaultMessage: 'Off' }); - } else if (intervalInMs < MS_IN_MINUTE) { - interval = Math.round(intervalInMs / MS_IN_SECOND); - return i18n.translate('common.ui.timepicker.totalSeconds', { - defaultMessage: `{interval} {interval, plural, - one {second} - other {seconds} - }`, - values: { interval }, - }); - } else if (intervalInMs < MS_IN_HOUR) { - interval = Math.round(intervalInMs / MS_IN_MINUTE); - return i18n.translate('common.ui.timepicker.totalMinutes', { - defaultMessage: `{interval} {interval, plural, - one {minute} - other {minutes} - }`, - values: { interval }, - }); - } else if (intervalInMs < MS_IN_DAY) { - interval = Math.round(intervalInMs / MS_IN_HOUR); - return i18n.translate('common.ui.timepicker.totalHours', { - defaultMessage: `{interval} {interval, plural, - one {hour} - other {hours} - }`, - values: { interval }, - }); - } else { - interval = Math.round(intervalInMs / MS_IN_DAY); - return i18n.translate('common.ui.timepicker.totalDays', { - defaultMessage: `{interval} {interval, plural, - one {day} - other {days} - }`, - values: { interval }, - }); - } -} diff --git a/src/ui/public/timepicker/pretty_interval.test.js b/src/ui/public/timepicker/pretty_interval.test.js deleted file mode 100644 index 72b99d0c43908..0000000000000 --- a/src/ui/public/timepicker/pretty_interval.test.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import expect from 'expect.js'; -import { prettyInterval } from './pretty_interval'; - -test('Off', () => { - expect(prettyInterval(0)).to.be('Off'); -}); - -test('seconds', () => { - expect(prettyInterval(1000)).to.be('1 second'); - expect(prettyInterval(15000)).to.be('15 seconds'); -}); - -test('minutes', () => { - expect(prettyInterval(60000)).to.be('1 minute'); - expect(prettyInterval(1800000)).to.be('30 minutes'); -}); - -test('hours', () => { - expect(prettyInterval(3600000)).to.be('1 hour'); - expect(prettyInterval(43200000)).to.be('12 hours'); -}); - -test('days', () => { - expect(prettyInterval(86400000)).to.be('1 day'); - expect(prettyInterval(86400000 * 2)).to.be('2 days'); -}); diff --git a/src/ui/public/timepicker/quick_panel/index.js b/src/ui/public/timepicker/quick_panel/index.js deleted file mode 100644 index 4bdadf9358644..0000000000000 --- a/src/ui/public/timepicker/quick_panel/index.js +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import './kbn_timepicker_quick_panel'; diff --git a/src/ui/public/timepicker/quick_panel/kbn_timepicker_quick_panel.html b/src/ui/public/timepicker/quick_panel/kbn_timepicker_quick_panel.html deleted file mode 100644 index 7855e5aae8f41..0000000000000 --- a/src/ui/public/timepicker/quick_panel/kbn_timepicker_quick_panel.html +++ /dev/null @@ -1,14 +0,0 @@ -
-
-
    -
  • - -
  • -
-
-
diff --git a/src/ui/public/timepicker/quick_panel/kbn_timepicker_quick_panel.js b/src/ui/public/timepicker/quick_panel/kbn_timepicker_quick_panel.js deleted file mode 100644 index 46ef2d7cb84d6..0000000000000 --- a/src/ui/public/timepicker/quick_panel/kbn_timepicker_quick_panel.js +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import _ from 'lodash'; -import template from './kbn_timepicker_quick_panel.html'; -import { uiModules } from '../../modules'; - -const module = uiModules.get('ui/timepicker'); - -module.directive('kbnTimepickerQuickPanel', function (config) { - return { - restrict: 'E', - replace: true, - scope: { - setQuick: '&' - }, - template, - controller: function ($scope) { - const quickRanges = config.get('timepicker:quickRanges'); - $scope.quickLists = _(quickRanges).groupBy('section').values().value(); - } - }; -}); diff --git a/src/ui/public/timepicker/recent_panel/index.js b/src/ui/public/timepicker/recent_panel/index.js deleted file mode 100644 index ac90ee48fc69b..0000000000000 --- a/src/ui/public/timepicker/recent_panel/index.js +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import './kbn_timepicker_recent_panel'; diff --git a/src/ui/public/timepicker/recent_panel/kbn_timepicker_recent_panel.html b/src/ui/public/timepicker/recent_panel/kbn_timepicker_recent_panel.html deleted file mode 100644 index 2be79b1383af6..0000000000000 --- a/src/ui/public/timepicker/recent_panel/kbn_timepicker_recent_panel.html +++ /dev/null @@ -1,21 +0,0 @@ -
- -
-

- No time history. Your most recent time ranges show up here, so you can easily view them later. -

-
- -
-
    -
  • - -
  • -
-
-
diff --git a/src/ui/public/timepicker/recent_panel/kbn_timepicker_recent_panel.js b/src/ui/public/timepicker/recent_panel/kbn_timepicker_recent_panel.js deleted file mode 100644 index 597cc5b1ed22a..0000000000000 --- a/src/ui/public/timepicker/recent_panel/kbn_timepicker_recent_panel.js +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import template from './kbn_timepicker_recent_panel.html'; -import { uiModules } from '../../modules'; -import { timeHistory } from '../../timefilter/time_history'; -import { prettyDuration } from '../pretty_duration'; - -const module = uiModules.get('ui/timepicker'); - -module.directive('kbnTimepickerRecentPanel', function () { - return { - restrict: 'E', - replace: true, - scope: { - setQuick: '&' - }, - template, - controller: function ($scope, config) { - const getConfig = (...args) => config.get(...args); - $scope.recent = timeHistory.get().map(time => { - time.display = prettyDuration(time.from, time.to, getConfig); - return time; - }); - } - }; -}); diff --git a/src/ui/public/timepicker/refresh_intervals.js b/src/ui/public/timepicker/refresh_intervals.js deleted file mode 100644 index 4dd66a16e028d..0000000000000 --- a/src/ui/public/timepicker/refresh_intervals.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { uiModules } from '../modules'; -const module = uiModules.get('kibana'); - -module.constant('refreshIntervals', [ - { value: 0, section: 0 }, - - { value: 5000, section: 1 }, - { value: 10000, section: 1 }, - { value: 30000, section: 1 }, - { value: 45000, section: 1 }, - - { value: 60000, section: 2 }, - { value: 300000, section: 2 }, - { value: 900000, section: 2 }, - { value: 1800000, section: 2 }, - - { value: 3600000, section: 3 }, - { value: 7200000, section: 3 }, - { value: 43200000, section: 3 }, - { value: 86400000, section: 3 } -]); - diff --git a/src/ui/public/timepicker/relative_panel/index.js b/src/ui/public/timepicker/relative_panel/index.js deleted file mode 100644 index 7262dbb26899a..0000000000000 --- a/src/ui/public/timepicker/relative_panel/index.js +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import './kbn_timepicker_relative_panel'; diff --git a/src/ui/public/timepicker/relative_panel/kbn_timepicker_relative_panel.html b/src/ui/public/timepicker/relative_panel/kbn_timepicker_relative_panel.html deleted file mode 100644 index 3a36461734a32..0000000000000 --- a/src/ui/public/timepicker/relative_panel/kbn_timepicker_relative_panel.html +++ /dev/null @@ -1,191 +0,0 @@ -
-
-
-
- - -
- - - -
-
- -
- - {{relative.from.preview}} - - - - - -
- -
-
- -
- -
- -
-
- -
- -
-
- -
-
- - -
- - - -
-
- -
- - {{relative.to.preview}} - - - - - -
- -
-
- -
- -
- -
-
- -
- -
-
-
- -
- - - - -
-
diff --git a/src/ui/public/timepicker/relative_panel/kbn_timepicker_relative_panel.js b/src/ui/public/timepicker/relative_panel/kbn_timepicker_relative_panel.js deleted file mode 100644 index 78bd136b2bb3e..0000000000000 --- a/src/ui/public/timepicker/relative_panel/kbn_timepicker_relative_panel.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import template from './kbn_timepicker_relative_panel.html'; -import { uiModules } from '../../modules'; - -const module = uiModules.get('ui/timepicker'); - -module.directive('kbnTimepickerRelativePanel', function () { - return { - restrict: 'E', - replace: true, - scope: { - applyRelative: '&', - checkRelative: '&', - formatRelative: '&', - relative: '=', - relativeOptions: '=', - setRelativeToNow: '&', - units: '=' - }, - template, - controller: function () { - } - }; -}); diff --git a/src/ui/public/timepicker/time_navigation.js b/src/ui/public/timepicker/time_navigation.js deleted file mode 100644 index 54b0f9fb9fd6b..0000000000000 --- a/src/ui/public/timepicker/time_navigation.js +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import moment from 'moment'; - -export const timeNavigation = { - // travel forward in time based on the interval between from and to - stepForward({ min, max }) { - const diff = max.diff(min); - return { - from: moment(max).add(1, 'ms').toISOString(), - to: moment(max).add(diff + 1, 'ms').toISOString(), - mode: 'absolute' - }; - }, - - // travel backwards in time based on the interval between from and to - stepBackward({ min, max }) { - const diff = max.diff(min); - return { - from: moment(min).subtract(diff + 1, 'ms').toISOString(), - to: moment(min).subtract(1, 'ms').toISOString(), - mode: 'absolute' - }; - }, - - // zoom out, doubling the difference between start and end, keeping the same time range center - zoomOut({ min, max }) { - const diff = max.diff(min); - return { - from: moment(min).subtract(diff / 2, 'ms').toISOString(), - to: moment(max).add(diff / 2, 'ms').toISOString(), - mode: 'absolute' - }; - }, - - // zoom in, halving the difference between start and end, keeping the same time range center - zoomIn({ min, max }) { - const diff = max.diff(min); - return { - from: moment(min).add(diff / 4, 'ms').toISOString(), - to: moment(max).subtract(diff / 4, 'ms').toISOString(), - mode: 'absolute' - }; - } -}; diff --git a/src/ui/public/timepicker/time_units.js b/src/ui/public/timepicker/time_units.js deleted file mode 100644 index 627202264de7a..0000000000000 --- a/src/ui/public/timepicker/time_units.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export const timeUnits = { - s: 'second', - m: 'minute', - h: 'hour', - d: 'day', - w: 'week', - M: 'month', - y: 'year' -}; - diff --git a/src/ui/public/timepicker/timepicker.html b/src/ui/public/timepicker/timepicker.html deleted file mode 100644 index 563491e8dd74d..0000000000000 --- a/src/ui/public/timepicker/timepicker.html +++ /dev/null @@ -1,141 +0,0 @@ -
- -
- -
-
-

-

-
- -
-
- - - - - - - -
-
- -
- - - - - - - -
-
- - -
-

- -

- - -
-
-
diff --git a/src/ui/public/timepicker/timepicker.js b/src/ui/public/timepicker/timepicker.js deleted file mode 100644 index 42efc4f564644..0000000000000 --- a/src/ui/public/timepicker/timepicker.js +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import html from './timepicker.html'; -import './quick_panel'; -import './recent_panel'; -import './relative_panel'; -import './absolute_panel'; -import _ from 'lodash'; -import { relativeOptions } from './relative_options'; -import { parseRelativeParts } from './parse_relative_parts'; -import dateMath from '@elastic/datemath'; -import moment from 'moment'; -import '../directives/input_datetime'; -import '../directives/inequality'; -import './refresh_intervals'; -import './kbn_global_timepicker'; -import { uiModules } from '../modules'; -import { TIME_MODES } from './modes'; -import { timeUnits } from './time_units'; -import { prettyInterval } from './pretty_interval'; -import { i18n } from '@kbn/i18n'; -const module = uiModules.get('ui/timepicker'); - -module.directive('kbnTimepicker', function (refreshIntervals) { - return { - restrict: 'E', - scope: { - from: '=', - to: '=', - mode: '=', - interval: '=', - activeTab: '=', - onFilterSelect: '&', - onIntervalSelect: '&' - }, - template: html, - controller: function ($scope) { - $scope.format = 'MMMM Do YYYY, HH:mm:ss.SSS'; - $scope.modes = Object.values(TIME_MODES); - $scope.activeTab = $scope.activeTab || 'filter'; - - if (_.isUndefined($scope.mode)) $scope.mode = TIME_MODES.QUICK; - - $scope.refreshLists = _(refreshIntervals).groupBy('section').values().value(); - - $scope.relative = { - from: { - count: 1, - unit: 'm', - preview: undefined, - round: false - }, - to: { - count: 0, - unit: 's', - preview: undefined, - round: false - } - }; - - $scope.absolute = { - from: moment(), - to: moment() - }; - - $scope.units = timeUnits; - - $scope.relativeOptions = relativeOptions; - - $scope.$watch('from', function (date) { - if (moment.isMoment(date) && $scope.mode === TIME_MODES.ABSOLUTE) { - $scope.absolute.from = date; - } - }); - - $scope.$watch('to', function (date) { - if (moment.isMoment(date) && $scope.mode === TIME_MODES.ABSOLUTE) { - $scope.absolute.to = date; - } - }); - - // If we always return a new object from the getters below (pickFromDate and pickToDate) we'll create an - // infinite digest loop, so we maintain these copies to return instead. - $scope.$watch('absolute.from', function (newDate) { - if (!newDate) { - return; - } - - _.set($scope, 'browserAbsolute.from', new Date(newDate.year(), newDate.month(), newDate.date())); - }); - - $scope.$watch('absolute.to', function (newDate) { - if (!newDate) { - return; - } - - _.set($scope, 'browserAbsolute.to', new Date(newDate.year(), newDate.month(), newDate.date())); - }); - - // The datepicker directive uses native JavaScript Dates, ignoring moment's default timezone. This causes - // the datepicker and the text input above it to get out of sync if the user changed the `dateFormat:tz` config - // in advanced settings. The text input will show the date in the user selected timezone, the datepicker will - // show the date in the local browser timezone. Since we really just want a day, month, year from the datepicker - // instead of a moment in time, we grab those individual values from the native date. - $scope.pickFromDate = function (date) { - if (!date) return _.get($scope, 'browserAbsolute.from'); - - const defaultTimeZoneDate = moment({ - year: date.getFullYear(), - month: date.getMonth(), - day: date.getDate(), - hour: 0, - minute: 0, - second: 0, - millisecond: 0, - }); - return $scope.absolute.from = defaultTimeZoneDate; - }; - - $scope.pickToDate = function (date) { - if (!date) return _.get($scope, 'browserAbsolute.to'); - - const defaultTimeZoneDate = moment({ - year: date.getFullYear(), - month: date.getMonth(), - day: date.getDate(), - hour: 23, - minute: 59, - second: 59, - millisecond: 999, - }); - return $scope.absolute.to = defaultTimeZoneDate; - }; - - $scope.setMode = function (thisMode) { - switch (thisMode) { - case TIME_MODES.QUICK: - break; - case TIME_MODES.RECENT: - break; - case TIME_MODES.RELATIVE: - $scope.relative = parseRelativeParts($scope.from, $scope.to); - $scope.formatRelative('from'); - $scope.formatRelative('to'); - break; - case TIME_MODES.ABSOLUTE: - $scope.absolute.from = dateMath.parse($scope.from || moment().subtract(15, 'minutes')); - $scope.absolute.to = dateMath.parse($scope.to || moment(), { roundUp: true }); - break; - } - - $scope.mode = thisMode; - }; - - $scope.setQuick = function (from, to) { - $scope.onFilterSelect({ from, to, mode: TIME_MODES.QUICK }); - }; - - $scope.setToNow = function (key) { - $scope.absolute[key] = moment(); - }; - - $scope.setRelativeToNow = function (key) { - $scope.relative[key].count = 0; - $scope.relative[key].round = false; - $scope.formatRelative(key); - }; - - $scope.checkRelative = function () { - if ($scope.relative.from.count != null && $scope.relative.to.count != null) { - const from = dateMath.parse(getRelativeString('from')); - const to = dateMath.parse(getRelativeString('to'), { roundUp: true }); - if (to && from) return to.isBefore(from); - return true; - } - }; - - $scope.formatRelative = function (key) { - const relativeString = getRelativeString(key); - const parsed = dateMath.parse(relativeString, { roundUp: key === 'to' }); - let preview; - if (relativeString === 'now') { - preview = i18n.translate('common.ui.timepicker.now', { defaultMessage: 'Now' }); - } else { - preview = parsed ? parsed.format($scope.format) : undefined; - } - _.set($scope, `relative.${key}.preview`, preview); - return parsed; - }; - - $scope.applyRelative = function () { - $scope.onFilterSelect({ - from: getRelativeString('from'), - to: getRelativeString('to'), - mode: TIME_MODES.RELATIVE, - }); - }; - - function getRelativeString(key) { - const count = _.get($scope, `relative.${key}.count`, 0); - const round = _.get($scope, `relative.${key}.round`, false); - const matches = _.get($scope, `relative.${key}.unit`, 's').match(/([smhdwMy])(\+)?/); - let unit; - let operator = '-'; - if (matches && matches[1]) unit = matches[1]; - if (matches && matches[2]) operator = matches[2]; - if (count === 0 && !round) return 'now'; - let result = `now${operator}${count}${unit}`; - result += (round ? '/' + unit : ''); - return result; - } - - $scope.applyAbsolute = function () { - $scope.onFilterSelect({ - from: moment($scope.absolute.from), - to: moment($scope.absolute.to), - mode: TIME_MODES.ABSOLUTE, - }); - }; - - $scope.prettyInterval = function (interval) { - return prettyInterval(interval.value); - }; - - $scope.setRefreshInterval = function (interval) { - interval = _.clone(interval || {}); - interval.pause = (interval.pause == null || interval.pause === false) ? false : true; - - $scope.onIntervalSelect({ - interval: { - value: interval.value, - pause: interval.pause, - } - }); - }; - - $scope.setMode($scope.mode); - } - }; -}); diff --git a/src/ui/public/timepicker/timepicker.less b/src/ui/public/timepicker/timepicker.less deleted file mode 100644 index dd265d9997a1e..0000000000000 --- a/src/ui/public/timepicker/timepicker.less +++ /dev/null @@ -1,98 +0,0 @@ -.kbn-timepicker { - display: flex; - justify-content: flex-end; - - .kbn-timepicker-content { - width: 100%; - max-width: 600px; - } - - [kbn-time-input] { - text-align: center; - } - .kbn-timepicker-modes { - text-transform: capitalize; - } - .kbn-timepicker-section { - float: left; - - & + .kbn-timepicker-section { - padding-left: 15px; - } - } - .kbn-timepicker-quick-section { - width: 25%; - } - .kbn-timepicker-body { - display: flex; - align-items: top; - justify-content: stretch; - width: 100%; - - @media (max-width: 660px) { - flex-direction: column; - } - } - .kbn-timepicker-body-column { - width: 100%; - } - .kbn-timepicker-form-header { - margin-bottom: 0 !important; - } - .kbn-timepicker-actions { - display: flex; - justify-content: flex-end; - align-items: baseline; - } - .kbn-timepicker-action-item, - .kbn-timepicker-submit-button { - margin-left: 10px; - } - .kbn-timepicker-submit-button { - min-width: 100px; - } - .kbn-refresh-section { - float: left; - padding: 0px 15px; - } - .kbn-timepicket-alert { - width: 100px; - } - .kbn-timepicker-error { - color: @brand-danger; - } - .kbn-timepicker-title { - display: flex; - justify-content: space-between; - } - /** - * 1. Override kuiLocalNav styles. - */ - .kbn-timepicker-title__text { - margin-bottom: 0 !important; /* 1 */ - } - .kbn-timepicker-title__section { - display: flex; - align-items: center; - } - /** - * Avoid last nav overlapping collapse button - */ - .nav:last-child { - margin-right: 24px; - } - - .refresh-interval { - padding: 0.2em 0.4em; - border-radius: @border-radius-small; - } - - .refresh-interval-active { - background-color: @brand-info; - color: @white; - } -} - -.navbar-timepicker-time-desc > .fa-clock-o { - padding-right: 5px; -} diff --git a/src/ui/public/utils/__tests__/brush_event.test.js b/src/ui/public/utils/__tests__/brush_event.test.js index 8ab0977a5d130..0fdf17791a693 100644 --- a/src/ui/public/utils/__tests__/brush_event.test.js +++ b/src/ui/public/utils/__tests__/brush_event.test.js @@ -25,7 +25,7 @@ jest.mock('ui/chrome', get: (key) => { switch (key) { case 'timepicker:timeDefaults': - return { from: 'now-15m', to: 'now', mode: 'quick' }; + return { from: 'now-15m', to: 'now' }; case 'timepicker:refreshIntervalDefaults': return { display: 'Off', pause: false, value: 0 }; default: @@ -126,8 +126,7 @@ describe('brushEvent', () => { const event = _.cloneDeep(dateEvent); event.range = [JAN_01_2014, JAN_01_2014 + DAY_IN_MS]; onBrushEvent(event, $state); - const { mode, from, to } = timefilter.getTime(); - expect(mode).to.be('absolute'); + const { from, to } = timefilter.getTime(); // Set to a baseline timezone for comparison. expect(from).to.be(new Date(JAN_01_2014).toISOString()); // Set to a baseline timezone for comparison. diff --git a/test/functional/apps/context/_discover_navigation.js b/test/functional/apps/context/_discover_navigation.js index 6be4400add141..3a6c357c1ad07 100644 --- a/test/functional/apps/context/_discover_navigation.js +++ b/test/functional/apps/context/_discover_navigation.js @@ -28,12 +28,12 @@ export default function ({ getService, getPageObjects }) { const retry = getService('retry'); const docTable = getService('docTable'); const filterBar = getService('filterBar'); - const PageObjects = getPageObjects(['common', 'header', 'discover']); + const PageObjects = getPageObjects(['common', 'discover', 'timePicker']); describe('context link in discover', function contextSize() { before(async function () { await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.setAbsoluteRange(TEST_DISCOVER_START_TIME, TEST_DISCOVER_END_TIME); + await PageObjects.timePicker.setAbsoluteRange(TEST_DISCOVER_START_TIME, TEST_DISCOVER_END_TIME); await Promise.all(TEST_COLUMN_NAMES.map((columnName) => ( PageObjects.discover.clickFieldListItemAdd(columnName) ))); diff --git a/test/functional/apps/dashboard/_dashboard_time.js b/test/functional/apps/dashboard/_dashboard_time.js index e804d8e3f732e..b34d061f608a0 100644 --- a/test/functional/apps/dashboard/_dashboard_time.js +++ b/test/functional/apps/dashboard/_dashboard_time.js @@ -25,7 +25,7 @@ const fromTime = '2015-09-19 06:31:44.000'; const toTime = '2015-09-23 18:31:44.000'; export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['dashboard', 'header']); + const PageObjects = getPageObjects(['dashboard', 'header', 'timePicker']); const browser = getService('browser'); describe('dashboard time', () => { @@ -46,48 +46,31 @@ export default function ({ getPageObjects, getService }) { }); it('Does not set the time picker on open', async () => { - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.dashboard.loadSavedDashboard(dashboardName); - const fromTimeNext = await PageObjects.header.getFromTime(); - const toTimeNext = await PageObjects.header.getToTime(); - expect(fromTimeNext).to.equal(fromTime); - expect(toTimeNext).to.equal(toTime); + const time = await PageObjects.timePicker.getTimeConfig(); + expect(time.start).to.equal('Sep 19, 2015 @ 06:31:44.000'); + expect(time.end).to.equal('Sep 23, 2015 @ 18:31:44.000'); }); }); describe('dashboard with stored timed', async function () { - it('is saved with quick time', async function () { + it('is saved with time', async function () { await PageObjects.dashboard.switchToEditMode(); - await PageObjects.header.setQuickTime('Today'); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.dashboard.saveDashboard(dashboardName, { storeTimeWithDashboard: true }); }); - it('sets quick time on open', async function () { - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + it('sets time on open', async function () { + await PageObjects.timePicker.setAbsoluteRange('2019-01-01 00:00:00.000', '2019-01-02 00:00:00.000'); await PageObjects.dashboard.loadSavedDashboard(dashboardName); - const prettyPrint = await PageObjects.header.getPrettyDuration(); - expect(prettyPrint).to.equal('Today'); - }); - - it('is saved with absolute time', async function () { - await PageObjects.dashboard.switchToEditMode(); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); - await PageObjects.dashboard.saveDashboard(dashboardName, { storeTimeWithDashboard: true }); - }); - - it('sets absolute time on open', async function () { - await PageObjects.header.setQuickTime('Today'); - - await PageObjects.dashboard.loadSavedDashboard(dashboardName); - - const fromTimeNext = await PageObjects.header.getFromTime(); - const toTimeNext = await PageObjects.header.getToTime(); - expect(fromTimeNext).to.equal(fromTime); - expect(toTimeNext).to.equal(toTime); + const time = await PageObjects.timePicker.getTimeConfig(); + expect(time.start).to.equal('Sep 19, 2015 @ 06:31:44.000'); + expect(time.end).to.equal('Sep 23, 2015 @ 18:31:44.000'); }); // If time is stored with a dashboard, it's supposed to override the current time settings when opened. @@ -100,10 +83,11 @@ export default function ({ getPageObjects, getService }) { await PageObjects.dashboard.gotoDashboardLandingPage(); - const urlWithGlobalTime = `${kibanaBaseUrl}#/dashboard/${id}?_g=(time:(from:now-1h,mode:quick,to:now))`; + const urlWithGlobalTime = `${kibanaBaseUrl}#/dashboard/${id}?_g=(time:(from:now-1h,to:now))`; await browser.get(urlWithGlobalTime, false); - const prettyPrint = await PageObjects.header.getPrettyDuration(); - expect(prettyPrint).to.equal('Last 1 hour'); + const time = await PageObjects.timePicker.getTimeConfig(); + expect(time.start).to.equal('~ an hour ago'); + expect(time.end).to.equal('now'); }); }); @@ -115,12 +99,13 @@ export default function ({ getPageObjects, getService }) { it('preserved during navigation', async function () { await PageObjects.dashboard.loadSavedDashboard(dashboardName); - await PageObjects.header.setQuickTime('Today'); + await PageObjects.timePicker.setAbsoluteRange('2019-01-01 00:00:00.000', '2019-01-02 00:00:00.000'); await PageObjects.header.clickVisualize(); await PageObjects.header.clickDashboard(); - const prettyPrint = await PageObjects.header.getPrettyDuration(); - expect(prettyPrint).to.equal('Today'); + const time = await PageObjects.timePicker.getTimeConfig(); + expect(time.start).to.equal('Jan 1, 2019 @ 00:00:00.000'); + expect(time.end).to.equal('Jan 2, 2019 @ 00:00:00.000'); }); }); }); diff --git a/test/functional/apps/dashboard/_dashboard_time_picker.js b/test/functional/apps/dashboard/_dashboard_time_picker.js index 1cbb0c44e5c67..77e6601f44d58 100644 --- a/test/functional/apps/dashboard/_dashboard_time_picker.js +++ b/test/functional/apps/dashboard/_dashboard_time_picker.js @@ -23,7 +23,7 @@ export default function ({ getService, getPageObjects }) { const dashboardExpect = getService('dashboardExpect'); const pieChart = getService('pieChart'); const dashboardVisualizations = getService('dashboardVisualizations'); - const PageObjects = getPageObjects(['dashboard', 'header', 'visualize']); + const PageObjects = getPageObjects(['dashboard', 'header', 'visualize', 'timePicker']); describe('dashboard time picker', function describeIndexTests() { before(async function () { @@ -54,7 +54,8 @@ export default function ({ getService, getPageObjects }) { await dashboardVisualizations.createAndAddSavedSearch({ name: 'saved search', fields: ['bytes', 'agent'] }); await dashboardExpect.docTableFieldCount(150); - await PageObjects.header.setQuickTime('Today'); + // Set to time range with no data + await PageObjects.timePicker.setAbsoluteRange('2000-01-01 00:00:00.000', '2000-01-01 01:00:00.000'); await dashboardExpect.docTableFieldCount(0); }); }); diff --git a/test/functional/apps/dashboard/_embeddable_rendering.js b/test/functional/apps/dashboard/_embeddable_rendering.js index 0073c3a955a2b..5f7cf2fec9f66 100644 --- a/test/functional/apps/dashboard/_embeddable_rendering.js +++ b/test/functional/apps/dashboard/_embeddable_rendering.js @@ -33,7 +33,7 @@ export default function ({ getService, getPageObjects }) { const pieChart = getService('pieChart'); const dashboardExpect = getService('dashboardExpect'); const dashboardAddPanel = getService('dashboardAddPanel'); - const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'visualize', 'discover']); + const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'visualize', 'discover', 'timePicker']); const expectAllDataRenders = async () => { await pieChart.expectPieSliceCount(16); @@ -96,7 +96,7 @@ export default function ({ getService, getPageObjects }) { const fromTime = '2018-01-01 00:00:00.000'; const toTime = '2018-04-13 00:00:00.000'; - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); }); after(async () => { @@ -139,7 +139,7 @@ export default function ({ getService, getPageObjects }) { // Change the time to make sure that it's updated when re-opened from the listing page. const fromTime = '2018-05-10 00:00:00.000'; const toTime = '2018-05-11 00:00:00.000'; - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.dashboard.loadSavedDashboard('embeddable rendering test'); await PageObjects.dashboard.waitForRenderComplete(); await expectAllDataRenders(); @@ -156,8 +156,7 @@ export default function ({ getService, getPageObjects }) { it('panels are updated when time changes outside of data', async () => { const fromTime = '2018-05-11 00:00:00.000'; const toTime = '2018-05-12 00:00:00.000'; - await PageObjects.header.setAbsoluteRange(fromTime, toTime); - await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.dashboard.waitForRenderComplete(); await expectNoDataRenders(); }); @@ -165,8 +164,7 @@ export default function ({ getService, getPageObjects }) { it('panels are updated when time changes inside of data', async () => { const fromTime = '2018-01-01 00:00:00.000'; const toTime = '2018-04-13 00:00:00.000'; - await PageObjects.header.setAbsoluteRange(fromTime, toTime); - await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.dashboard.waitForRenderComplete(); await expectAllDataRenders(); }); diff --git a/test/functional/apps/dashboard/_time_zones.js b/test/functional/apps/dashboard/_time_zones.js index 73931f225da52..514b0366d19bb 100644 --- a/test/functional/apps/dashboard/_time_zones.js +++ b/test/functional/apps/dashboard/_time_zones.js @@ -22,7 +22,7 @@ import expect from 'expect.js'; export default function ({ getService, getPageObjects }) { const pieChart = getService('pieChart'); - const PageObjects = getPageObjects(['dashboard', 'header', 'settings', 'common']); + const PageObjects = getPageObjects(['dashboard', 'timePicker', 'settings', 'common']); describe('dashboard time zones', () => { before(async () => { @@ -41,8 +41,9 @@ export default function ({ getService, getPageObjects }) { }); it('Exported dashboard adjusts EST time to UTC', async () => { - const timeRange = await PageObjects.header.getPrettyDuration(); - expect(timeRange).to.be('April 10th 2018, 03:00:00.000 to April 10th 2018, 04:00:00.000'); + const time = await PageObjects.timePicker.getTimeConfigAsAbsoluteTimes(); + expect(time.start).to.be('2018-04-10 03:00:00.000'); + expect(time.end).to.be('2018-04-10 04:00:00.000'); await pieChart.expectPieSliceCount(4); }); @@ -52,8 +53,9 @@ export default function ({ getService, getPageObjects }) { await PageObjects.settings.setAdvancedSettingsSelect('dateFormat:tz', 'EST'); await PageObjects.common.navigateToApp('dashboard'); await PageObjects.dashboard.loadSavedDashboard('time zone test'); - const timeRange = await PageObjects.header.getPrettyDuration(); - expect(timeRange).to.be('April 9th 2018, 22:00:00.000 to April 9th 2018, 23:00:00.000'); + const time = await PageObjects.timePicker.getTimeConfigAsAbsoluteTimes(); + expect(time.start).to.be('2018-04-09 22:00:00.000'); + expect(time.end).to.be('2018-04-09 23:00:00.000'); await pieChart.expectPieSliceCount(4); }); }); diff --git a/test/functional/apps/dashboard/_view_edit.js b/test/functional/apps/dashboard/_view_edit.js index c4cdb97a593af..7851d5320f2e3 100644 --- a/test/functional/apps/dashboard/_view_edit.js +++ b/test/functional/apps/dashboard/_view_edit.js @@ -22,7 +22,7 @@ import expect from 'expect.js'; export default function ({ getService, getPageObjects }) { const queryBar = getService('queryBar'); const dashboardAddPanel = getService('dashboardAddPanel'); - const PageObjects = getPageObjects(['dashboard', 'header', 'common', 'visualize']); + const PageObjects = getPageObjects(['dashboard', 'header', 'common', 'visualize', 'timePicker']); const dashboardName = 'dashboard with filter'; const filterBar = getService('filterBar'); @@ -62,23 +62,21 @@ export default function ({ getService, getPageObjects }) { it('when time changed is stored with dashboard', async function () { await PageObjects.dashboard.setTimepickerInDataRange(); - const originalFromTime = await PageObjects.header.getFromTime(); - const originalToTime = await PageObjects.header.getToTime(); + const originalTime = await PageObjects.timePicker.getTimeConfig(); await PageObjects.dashboard.saveDashboard(dashboardName, { storeTimeWithDashboard: true }); await PageObjects.dashboard.switchToEditMode(); - await PageObjects.header.setAbsoluteRange('2013-09-19 06:31:44.000', '2013-09-19 06:31:44.000'); + await PageObjects.timePicker.setAbsoluteRange('2013-09-19 06:31:44.000', '2013-09-19 06:31:44.000'); await PageObjects.dashboard.clickCancelOutOfEditMode(); // confirm lose changes await PageObjects.common.clickConfirmOnModal(); - const newFromTime = await PageObjects.header.getFromTime(); - const newToTime = await PageObjects.header.getToTime(); + const newTime = await PageObjects.timePicker.getTimeConfig(); - expect(newFromTime).to.equal(originalFromTime); - expect(newToTime).to.equal(originalToTime); + expect(newTime.start).to.equal(originalTime.start); + expect(newTime.end).to.equal(originalTime.end); }); it('when the query is edited and applied', async function () { @@ -153,12 +151,10 @@ export default function ({ getService, getPageObjects }) { describe('and preserves edits on cancel', function () { it('when time changed is stored with dashboard', async function () { await PageObjects.dashboard.gotoDashboardEditMode(dashboardName); - const newFromTime = '2015-09-19 06:31:44.000'; - const newToTime = '2015-09-19 06:31:44.000'; - await PageObjects.header.setAbsoluteRange('2013-09-19 06:31:44.000', '2013-09-19 06:31:44.000'); + await PageObjects.timePicker.setAbsoluteRange('2013-09-19 06:31:44.000', '2013-09-19 06:31:44.000'); await PageObjects.dashboard.saveDashboard(dashboardName, true); await PageObjects.dashboard.switchToEditMode(); - await PageObjects.header.setAbsoluteRange(newToTime, newToTime); + await PageObjects.timePicker.setAbsoluteRange('2015-09-19 06:31:44.000', '2015-09-19 06:31:44.000'); await PageObjects.dashboard.clickCancelOutOfEditMode(); await PageObjects.common.clickCancelOnModal(); @@ -166,11 +162,10 @@ export default function ({ getService, getPageObjects }) { await PageObjects.dashboard.loadSavedDashboard(dashboardName); - const fromTime = await PageObjects.header.getFromTime(); - const toTime = await PageObjects.header.getToTime(); + const time = await PageObjects.timePicker.getTimeConfig(); - expect(fromTime).to.equal(newFromTime); - expect(toTime).to.equal(newToTime); + expect(time.start).to.equal('Sep 19, 2015 @ 06:31:44.000'); + expect(time.end).to.equal('Sep 19, 2015 @ 06:31:44.000'); }); }); }); @@ -181,10 +176,8 @@ export default function ({ getService, getPageObjects }) { await PageObjects.dashboard.setTimepickerInDataRange(); await PageObjects.dashboard.saveDashboard(dashboardName, true); await PageObjects.dashboard.switchToEditMode(); - await PageObjects.header.setAbsoluteRange('2013-09-19 06:31:44.000', '2013-09-19 06:31:44.000'); - - const newFromTime = await PageObjects.header.getFromTime(); - const newToTime = await PageObjects.header.getToTime(); + await PageObjects.timePicker.setAbsoluteRange('2013-09-19 06:31:44.000', '2013-09-19 06:31:44.000'); + const newTime = await PageObjects.timePicker.getTimeConfig(); await PageObjects.dashboard.clickCancelOutOfEditMode(); @@ -193,11 +186,10 @@ export default function ({ getService, getPageObjects }) { await PageObjects.dashboard.loadSavedDashboard(dashboardName); - const fromTime = await PageObjects.header.getFromTime(); - const toTime = await PageObjects.header.getToTime(); + const time = await PageObjects.timePicker.getTimeConfig(); - expect(fromTime).to.equal(newFromTime); - expect(toTime).to.equal(newToTime); + expect(time.start).to.equal(newTime.start); + expect(time.end).to.equal(newTime.end); }); }); @@ -206,7 +198,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.dashboard.gotoDashboardEditMode(dashboardName); await PageObjects.dashboard.saveDashboard(dashboardName, { storeTimeWithDashboard: false }); await PageObjects.dashboard.switchToEditMode(); - await PageObjects.header.setAbsoluteRange('2014-10-19 06:31:44.000', '2014-12-19 06:31:44.000'); + await PageObjects.timePicker.setAbsoluteRange('2014-10-19 06:31:44.000', '2014-12-19 06:31:44.000'); await PageObjects.dashboard.clickCancelOutOfEditMode(); await PageObjects.common.expectConfirmModalOpenState(false); diff --git a/test/functional/apps/discover/_discover.js b/test/functional/apps/discover/_discover.js index 03098bb468a8b..009914b777e25 100644 --- a/test/functional/apps/discover/_discover.js +++ b/test/functional/apps/discover/_discover.js @@ -18,7 +18,6 @@ */ import expect from 'expect.js'; -import moment from 'moment'; export default function ({ getService, getPageObjects }) { const log = getService('log'); @@ -27,7 +26,7 @@ export default function ({ getService, getPageObjects }) { const browser = getService('browser'); const kibanaServer = getService('kibanaServer'); const filterBar = getService('filterBar'); - const PageObjects = getPageObjects(['common', 'discover', 'header', 'visualize']); + const PageObjects = getPageObjects(['common', 'discover', 'header', 'visualize', 'timePicker']); const defaultSettings = { 'dateFormat:tz': 'UTC', defaultIndex: 'logstash-*', @@ -35,9 +34,7 @@ export default function ({ getService, getPageObjects }) { describe('discover app', function describeIndexTests() { const fromTime = '2015-09-19 06:31:44.000'; - const fromTimeString = 'September 19th 2015, 06:31:44.000'; const toTime = '2015-09-23 18:31:44.000'; - const toTimeString = 'September 23rd 2015, 18:31:44.000'; before(async function () { // delete .kibana index and update configDoc @@ -50,18 +47,16 @@ export default function ({ getService, getPageObjects }) { await esArchiver.loadIfNeeded('logstash_functional'); log.debug('discover'); await PageObjects.common.navigateToApp('discover'); - log.debug('setAbsoluteRange'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); }); describe('query', function () { const queryName1 = 'Query # 1'; it('should show correct time range string by timepicker', async function () { - const actualTimeString = await PageObjects.header.getPrettyDuration(); - - const expectedTimeString = `${fromTimeString} to ${toTimeString}`; - expect(actualTimeString).to.be(expectedTimeString); + const time = await PageObjects.timePicker.getTimeConfig(); + expect(time.start).to.be('Sep 19, 2015 @ 06:31:44.000'); + expect(time.end).to.be('Sep 23, 2015 @ 18:31:44.000'); }); it('save query should show toast message and display query name', async function () { @@ -121,8 +116,7 @@ export default function ({ getService, getPageObjects }) { it('should show correct time range string in chart', async function () { const actualTimeString = await PageObjects.discover.getChartTimespan(); - - const expectedTimeString = `${fromTimeString} - ${toTimeString}`; + const expectedTimeString = `Sep 19, 2015 @ 06:31:44.000 - Sep 23, 2015 @ 18:31:44.000`; expect(actualTimeString).to.be(expectedTimeString); }); @@ -146,30 +140,29 @@ export default function ({ getService, getPageObjects }) { }); it('should modify the time range when a bar is clicked', async function () { - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.visualize.waitForVisualization(); await PageObjects.discover.clickHistogramBar(0); await PageObjects.visualize.waitForVisualization(); - const actualTimeString = await PageObjects.header.getPrettyDuration(); - expect(actualTimeString).to.be('September 20th 2015, 00:00:00.000 to September 20th 2015, 03:00:00.000'); + const time = await PageObjects.timePicker.getTimeConfig(); + expect(time.start).to.be('Sep 20, 2015 @ 00:00:00.000'); + expect(time.end).to.be('Sep 20, 2015 @ 03:00:00.000'); }); it('should modify the time range when the histogram is brushed', async function () { - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.visualize.waitForVisualization(); await PageObjects.discover.brushHistogram(0, 1); await PageObjects.visualize.waitForVisualization(); - const newFromTime = await PageObjects.header.getFromTime(); - const newToTime = await PageObjects.header.getToTime(); - const newDurationHours = moment.duration(moment(newToTime) - moment(newFromTime)).asHours(); + const newDurationHours = await PageObjects.timePicker.getTimeDurationInHours(); if (newDurationHours < 1 || newDurationHours >= 5) { throw new Error(`expected new duration of ${newDurationHours} hours to be between 1 and 5 hours`); } }); it('should show correct initial chart interval of Auto', async function () { - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); const actualInterval = await PageObjects.discover.getChartInterval(); const expectedInterval = 'Auto'; @@ -177,6 +170,7 @@ export default function ({ getService, getPageObjects }) { }); it('should show correct data for chart interval Hourly', async function () { + await PageObjects.header.awaitGlobalLoadingIndicatorHidden(); await PageObjects.discover.setChartInterval('Hourly'); const expectedBarChartData = [ @@ -391,7 +385,7 @@ export default function ({ getService, getPageObjects }) { before(() => { log.debug('setAbsoluteRangeForAnotherQuery'); - return PageObjects.header.setAbsoluteRange(fromTime, toTime); + return PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); }); it('should show "no results"', async () => { @@ -403,17 +397,6 @@ export default function ({ getService, getPageObjects }) { const isVisible = await PageObjects.discover.hasNoResultsTimepicker(); expect(isVisible).to.be(true); }); - - it('should have a link that opens and closes the time picker', async function () { - const noResultsTimepickerLink = await PageObjects.discover.getNoResultsTimepicker(); - expect(await PageObjects.header.isTimepickerOpen()).to.be(false); - - await noResultsTimepickerLink.click(); - expect(await PageObjects.header.isTimepickerOpen()).to.be(true); - - await noResultsTimepickerLink.click(); - expect(await PageObjects.header.isTimepickerOpen()).to.be(false); - }); }); describe('filter editor', function () { @@ -453,7 +436,7 @@ export default function ({ getService, getPageObjects }) { it('should show bars in the correct time zone after switching', async function () { await kibanaServer.uiSettings.replace({ 'dateFormat:tz': 'America/Phoenix' }); await browser.refresh(); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); const maxTicks = [ '2015-09-19 17:00', diff --git a/test/functional/apps/discover/_field_data.js b/test/functional/apps/discover/_field_data.js index 0f9a6b123aa5e..ebfb1d4dcdfbf 100644 --- a/test/functional/apps/discover/_field_data.js +++ b/test/functional/apps/discover/_field_data.js @@ -24,7 +24,7 @@ export default function ({ getService, getPageObjects }) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const queryBar = getService('queryBar'); - const PageObjects = getPageObjects(['common', 'header', 'discover', 'visualize']); + const PageObjects = getPageObjects(['common', 'header', 'discover', 'visualize', 'timePicker']); describe('discover tab', function describeIndexTests() { before(async function () { @@ -40,16 +40,15 @@ export default function ({ getService, getPageObjects }) { }); await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); }); describe('field data', function () { it('search php should show the correct hit count', async function () { const expectedHitCount = '445'; - await queryBar.setQuery('php'); - await queryBar.submitQuery(); - - await retry.try(async function tryingForTime() { + await retry.try(async function () { + await queryBar.setQuery('php'); + await queryBar.submitQuery(); const hitCount = await PageObjects.discover.getHitCount(); expect(hitCount).to.be(expectedHitCount); }); @@ -80,7 +79,7 @@ export default function ({ getService, getPageObjects }) { }); it('doc view should sort ascending', async function () { - const expectedTimeStamp = 'September 20th 2015, 00:00:00.000'; + const expectedTimeStamp = 'Sep 20, 2015 @ 00:00:00.000'; await PageObjects.discover.clickDocSortDown(); // we don't technically need this sleep here because the tryForTime will retry and the diff --git a/test/functional/apps/discover/_inspector.js b/test/functional/apps/discover/_inspector.js index 960fde388f967..847c1af2aa1fe 100644 --- a/test/functional/apps/discover/_inspector.js +++ b/test/functional/apps/discover/_inspector.js @@ -20,7 +20,7 @@ import expect from 'expect.js'; export default function ({ getService, getPageObjects }) { - const PageObjects = getPageObjects(['common', 'header', 'visualize']); + const PageObjects = getPageObjects(['common', 'visualize', 'timePicker']); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const inspector = getService('inspector'); @@ -59,7 +59,7 @@ export default function ({ getService, getPageObjects }) { }); it('should display request stats with results', async () => { - await PageObjects.header.setAbsoluteRange('2015-09-19 06:31:44.000', '2015-09-23 18:31:44.000'); + await PageObjects.timePicker.setAbsoluteRange('2015-09-19 06:31:44.000', '2015-09-23 18:31:44.000'); await inspector.open(); const requestStats = await inspector.getTableData(); diff --git a/test/functional/apps/discover/_shared_links.js b/test/functional/apps/discover/_shared_links.js index cac5954c4db2f..933f11246fae3 100644 --- a/test/functional/apps/discover/_shared_links.js +++ b/test/functional/apps/discover/_shared_links.js @@ -24,7 +24,7 @@ export default function ({ getService, getPageObjects }) { const log = getService('log'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['common', 'discover', 'header', 'share']); + const PageObjects = getPageObjects(['common', 'discover', 'share', 'timePicker']); describe('shared links', function describeIndexTests() { let baseUrl; @@ -54,8 +54,7 @@ export default function ({ getService, getPageObjects }) { log.debug('discover'); await PageObjects.common.navigateToApp('discover'); - log.debug('setAbsoluteRange'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); //After hiding the time picker, we need to wait for //the refresh button to hide before clicking the share button @@ -70,7 +69,7 @@ export default function ({ getService, getPageObjects }) { baseUrl + '/app/kibana?_t=1453775307251#' + '/discover?_g=(refreshInterval:(pause:!t,value:0),time' + - ':(from:\'2015-09-19T06:31:44.000Z\',mode:absolute,to:\'2015-09' + + ':(from:\'2015-09-19T06:31:44.000Z\',to:\'2015-09' + '-23T18:31:44.000Z\'))&_a=(columns:!(_source),index:\'logstash-' + '*\',interval:auto,query:(language:lucene,query:\'\')' + ',sort:!(\'@timestamp\',desc))'; @@ -97,7 +96,7 @@ export default function ({ getService, getPageObjects }) { '/discover/ab12e3c0-f231-11e6-9486-733b1ac9221a' + '?_g=(refreshInterval%3A(pause%3A!t%2Cvalue%3A0)' + '%2Ctime%3A(from%3A\'2015-09-19T06%3A31%3A44.000Z\'%2C' + - 'mode%3Aabsolute%2Cto%3A\'2015-09-23T18%3A31%3A44.000Z\'))'; + 'to%3A\'2015-09-23T18%3A31%3A44.000Z\'))'; await PageObjects.discover.loadSavedSearch('A Saved Search'); await PageObjects.share.clickShareTopNavButton(); await PageObjects.share.exportAsSavedObject(); diff --git a/test/functional/apps/discover/_sidebar.js b/test/functional/apps/discover/_sidebar.js index 82b9d99bc80b1..6b26b17ac660e 100644 --- a/test/functional/apps/discover/_sidebar.js +++ b/test/functional/apps/discover/_sidebar.js @@ -23,7 +23,7 @@ export default function ({ getService, getPageObjects }) { const log = getService('log'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['common', 'discover', 'header']); + const PageObjects = getPageObjects(['common', 'discover', 'timePicker']); describe('discover sidebar', function describeIndexTests() { before(async function () { @@ -45,8 +45,7 @@ export default function ({ getService, getPageObjects }) { log.debug('discover'); await PageObjects.common.navigateToApp('discover'); - log.debug('setAbsoluteRange'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); }); describe('field filtering', function () { diff --git a/test/functional/apps/discover/_source_filters.js b/test/functional/apps/discover/_source_filters.js index ca274fc7551c3..070041a453142 100644 --- a/test/functional/apps/discover/_source_filters.js +++ b/test/functional/apps/discover/_source_filters.js @@ -23,7 +23,7 @@ export default function ({ getService, getPageObjects }) { const log = getService('log'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['common', 'header', 'discover']); + const PageObjects = getPageObjects(['common', 'timePicker', 'discover']); describe('source filters', function describeIndexTests() { before(async function () { @@ -45,8 +45,7 @@ export default function ({ getService, getPageObjects }) { log.debug('discover'); await PageObjects.common.navigateToApp('discover'); - log.debug('setAbsoluteRange'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); //After hiding the time picker, we need to wait for //the refresh button to hide before clicking the share button diff --git a/test/functional/apps/home/_sample_data.js b/test/functional/apps/home/_sample_data.js index cc1b8f11adc4d..700eea39f4613 100644 --- a/test/functional/apps/home/_sample_data.js +++ b/test/functional/apps/home/_sample_data.js @@ -24,7 +24,7 @@ export default function ({ getService, getPageObjects }) { const find = getService('find'); const pieChart = getService('pieChart'); const dashboardExpect = getService('dashboardExpect'); - const PageObjects = getPageObjects(['common', 'header', 'home', 'dashboard']); + const PageObjects = getPageObjects(['common', 'header', 'home', 'dashboard', 'timePicker']); describe('sample data', function describeIndexTests() { @@ -85,7 +85,7 @@ export default function ({ getService, getPageObjects }) { const todayYearMonthDay = today.toISOString().substring(0, 10); const fromTime = `${todayYearMonthDay} 00:00:00.000`; const toTime = `${todayYearMonthDay} 23:59:59.999`; - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); const panelCount = await PageObjects.dashboard.getPanelCount(); expect(panelCount).to.be(19); }); @@ -123,7 +123,7 @@ export default function ({ getService, getPageObjects }) { const todayYearMonthDay = today.toISOString().substring(0, 10); const fromTime = `${todayYearMonthDay} 00:00:00.000`; const toTime = `${todayYearMonthDay} 23:59:59.999`; - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); const panelCount = await PageObjects.dashboard.getPanelCount(); expect(panelCount).to.be(11); }); @@ -135,7 +135,7 @@ export default function ({ getService, getPageObjects }) { const todayYearMonthDay = today.toISOString().substring(0, 10); const fromTime = `${todayYearMonthDay} 00:00:00.000`; const toTime = `${todayYearMonthDay} 23:59:59.999`; - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); const panelCount = await PageObjects.dashboard.getPanelCount(); expect(panelCount).to.be(12); }); diff --git a/test/functional/apps/management/_handle_alias.js b/test/functional/apps/management/_handle_alias.js index de89aa626112b..7a866a0274bcb 100644 --- a/test/functional/apps/management/_handle_alias.js +++ b/test/functional/apps/management/_handle_alias.js @@ -23,7 +23,7 @@ export default function ({ getService, getPageObjects }) { const esArchiver = getService('esArchiver'); const es = getService('es'); const retry = getService('retry'); - const PageObjects = getPageObjects(['common', 'home', 'settings', 'discover', 'header']); + const PageObjects = getPageObjects(['common', 'home', 'settings', 'discover', 'timePicker']); describe('Index patterns on aliases', function () { before(async function () { @@ -77,7 +77,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.common.navigateToApp('discover'); await PageObjects.discover.selectIndexPattern('alias2'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await retry.try(async function () { expect(await PageObjects.discover.getHitCount()).to.be(expectedHitCount); diff --git a/test/functional/apps/management/_kibana_settings.js b/test/functional/apps/management/_kibana_settings.js index c675593597437..dd56b721a68a0 100644 --- a/test/functional/apps/management/_kibana_settings.js +++ b/test/functional/apps/management/_kibana_settings.js @@ -22,7 +22,7 @@ import expect from 'expect.js'; export default function ({ getService, getPageObjects }) { const kibanaServer = getService('kibanaServer'); const browser = getService('browser'); - const PageObjects = getPageObjects(['settings', 'common', 'dashboard', 'header']); + const PageObjects = getPageObjects(['settings', 'common', 'dashboard', 'timePicker']); describe('kibana settings', function describeIndexTests() { before(async function () { @@ -57,7 +57,7 @@ export default function ({ getService, getPageObjects }) { it('when false, dashboard state is unhashed', async function () { await PageObjects.common.navigateToApp('dashboard'); await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.header.setAbsoluteRange('2015-09-19 06:31:44.000', '2015-09-23 18:31:44.000'); + await PageObjects.timePicker.setAbsoluteRange('2015-09-19 06:31:44.000', '2015-09-23 18:31:44.000'); const currentUrl = await browser.getCurrentUrl(); const urlPieces = currentUrl.match(/(.*)?_g=(.*)&_a=(.*)/); const globalState = urlPieces[2]; @@ -80,7 +80,7 @@ export default function ({ getService, getPageObjects }) { it('when true, dashboard state is hashed', async function () { await PageObjects.common.navigateToApp('dashboard'); await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.header.setAbsoluteRange('2015-09-19 06:31:44.000', '2015-09-23 18:31:44.000'); + await PageObjects.timePicker.setAbsoluteRange('2015-09-19 06:31:44.000', '2015-09-23 18:31:44.000'); const currentUrl = await browser.getCurrentUrl(); const urlPieces = currentUrl.match(/(.*)?_g=(.*)&_a=(.*)/); const globalState = urlPieces[2]; diff --git a/test/functional/apps/management/_scripted_fields.js b/test/functional/apps/management/_scripted_fields.js index fa12727f21434..59897a367c3f7 100644 --- a/test/functional/apps/management/_scripted_fields.js +++ b/test/functional/apps/management/_scripted_fields.js @@ -39,7 +39,7 @@ export default function ({ getService, getPageObjects }) { const inspector = getService('inspector'); const testSubjects = getService('testSubjects'); const filterBar = getService('filterBar'); - const PageObjects = getPageObjects(['common', 'header', 'settings', 'visualize', 'discover']); + const PageObjects = getPageObjects(['common', 'header', 'settings', 'visualize', 'discover', 'timePicker']); describe('scripted fields', () => { @@ -97,9 +97,7 @@ export default function ({ getService, getPageObjects }) { const fromTime = '2015-09-17 06:31:44.000'; const toTime = '2015-09-18 18:31:44.000'; await PageObjects.common.navigateToApp('discover'); - await log.debug('setAbsoluteRange (' + fromTime + ') to (' + toTime + ')'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); - await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.visualize.waitForVisualization(); await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName); await retry.try(async function () { @@ -109,7 +107,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.waitForVisualization(); await retry.try(async function () { const rowData = await PageObjects.discover.getDocTableIndex(1); - expect(rowData).to.be('September 18th 2015, 18:20:57.916\n18'); + expect(rowData).to.be('Sep 18, 2015 @ 18:20:57.916\n18'); }); }); @@ -160,9 +158,7 @@ export default function ({ getService, getPageObjects }) { const fromTime = '2015-09-17 06:31:44.000'; const toTime = '2015-09-18 18:31:44.000'; await PageObjects.common.navigateToApp('discover'); - await log.debug('setAbsoluteRange (' + fromTime + ') to (' + toTime + ')'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); - await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.visualize.waitForVisualization(); await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName2); await retry.try(async function () { @@ -172,7 +168,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.waitForVisualization(); await retry.try(async function () { const rowData = await PageObjects.discover.getDocTableIndex(1); - expect(rowData).to.be('September 18th 2015, 18:20:57.916\ngood'); + expect(rowData).to.be('Sep 18, 2015 @ 18:20:57.916\ngood'); }); }); @@ -222,9 +218,7 @@ export default function ({ getService, getPageObjects }) { const fromTime = '2015-09-17 06:31:44.000'; const toTime = '2015-09-18 18:31:44.000'; await PageObjects.common.navigateToApp('discover'); - await log.debug('setAbsoluteRange (' + fromTime + ') to (' + toTime + ')'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); - await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.visualize.waitForVisualization(); await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName2); await retry.try(async function () { @@ -234,7 +228,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.waitForVisualization(); await retry.try(async function () { const rowData = await PageObjects.discover.getDocTableIndex(1); - expect(rowData).to.be('September 18th 2015, 18:20:57.916\ntrue'); + expect(rowData).to.be('Sep 18, 2015 @ 18:20:57.916\ntrue'); }); }); @@ -285,9 +279,7 @@ export default function ({ getService, getPageObjects }) { const fromTime = '2015-09-17 19:22:00.000'; const toTime = '2015-09-18 07:00:00.000'; await PageObjects.common.navigateToApp('discover'); - await log.debug('setAbsoluteRange (' + fromTime + ') to (' + toTime + ')'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); - await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.visualize.waitForVisualization(); await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName2); await retry.try(async function () { @@ -297,7 +289,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.waitForVisualization(); await retry.try(async function () { const rowData = await PageObjects.discover.getDocTableIndex(1); - expect(rowData).to.be('September 18th 2015, 06:52:55.953\n2015-09-18 07:00'); + expect(rowData).to.be('Sep 18, 2015 @ 06:52:55.953\n2015-09-18 07:00'); }); }); diff --git a/test/functional/apps/timelion/_expression_typeahead.js b/test/functional/apps/timelion/_expression_typeahead.js index 46d72b0b7e446..aca178a906a86 100644 --- a/test/functional/apps/timelion/_expression_typeahead.js +++ b/test/functional/apps/timelion/_expression_typeahead.js @@ -20,7 +20,7 @@ import expect from 'expect.js'; export default function ({ getPageObjects }) { - const PageObjects = getPageObjects(['common', 'timelion', 'header', 'settings']); + const PageObjects = getPageObjects(['common', 'timelion', 'settings', 'timePicker']); describe('expression typeahead', () => { before(async () => { @@ -28,9 +28,7 @@ export default function ({ getPageObjects }) { const toTime = '2015-09-23 18:31:44.000'; await PageObjects.timelion.initTests(); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); - - await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); }); it('should display function suggestions filtered by function name', async () => { diff --git a/test/functional/apps/visualize/_area_chart.js b/test/functional/apps/visualize/_area_chart.js index 5f2e57dccfaeb..1fffbc2759355 100644 --- a/test/functional/apps/visualize/_area_chart.js +++ b/test/functional/apps/visualize/_area_chart.js @@ -24,7 +24,7 @@ export default function ({ getService, getPageObjects }) { const inspector = getService('inspector'); const browser = getService('browser'); const retry = getService('retry'); - const PageObjects = getPageObjects(['common', 'visualize', 'header', 'settings']); + const PageObjects = getPageObjects(['common', 'visualize', 'header', 'settings', 'timePicker']); describe('area charts', function indexPatternCreation() { const vizName1 = 'Visualization AreaChart Name Test'; @@ -39,8 +39,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.clickAreaChart(); log.debug('clickNewSearch'); await PageObjects.visualize.clickNewSearch(); - log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); log.debug('Click X-Axis'); await PageObjects.visualize.clickBucket('X-Axis'); log.debug('Click Date Histogram'); diff --git a/test/functional/apps/visualize/_data_table.js b/test/functional/apps/visualize/_data_table.js index 014887589d413..f2f8b06e5a418 100644 --- a/test/functional/apps/visualize/_data_table.js +++ b/test/functional/apps/visualize/_data_table.js @@ -25,7 +25,7 @@ export default function ({ getService, getPageObjects }) { const retry = getService('retry'); const filterBar = getService('filterBar'); const renderable = getService('renderable'); - const PageObjects = getPageObjects(['common', 'visualize', 'header']); + const PageObjects = getPageObjects(['common', 'visualize', 'header', 'timePicker']); const fromTime = '2015-09-19 06:31:44.000'; const toTime = '2015-09-23 18:31:44.000'; @@ -40,8 +40,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.clickDataTable(); log.debug('clickNewSearch'); await PageObjects.visualize.clickNewSearch(); - log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); log.debug('Bucket = Split Rows'); await PageObjects.visualize.clickBucket('Split Rows'); log.debug('Aggregation = Histogram'); @@ -103,7 +102,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.navigateToNewVisualization(); await PageObjects.visualize.clickDataTable(); await PageObjects.visualize.clickNewSearch(); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.visualize.clickAddMetric(); await PageObjects.visualize.clickBucket('Metric', 'metric'); await PageObjects.visualize.selectAggregation('Average Bucket', 'metrics'); @@ -119,7 +118,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.navigateToNewVisualization(); await PageObjects.visualize.clickDataTable(); await PageObjects.visualize.clickNewSearch(); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.visualize.clickBucket('Split Rows'); await PageObjects.visualize.selectAggregation('Date Histogram'); await PageObjects.visualize.selectField('@timestamp'); @@ -139,7 +138,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.navigateToNewVisualization(); await PageObjects.visualize.clickDataTable(); await PageObjects.visualize.clickNewSearch(); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.visualize.clickBucket('Split Rows'); await PageObjects.visualize.selectAggregation('Date Histogram'); await PageObjects.visualize.selectField('@timestamp'); @@ -178,7 +177,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.navigateToNewVisualization(); await PageObjects.visualize.clickDataTable(); await PageObjects.visualize.clickNewSearch(); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.visualize.clickMetricEditor(); await PageObjects.visualize.selectAggregation('Top Hit', 'metrics'); await PageObjects.visualize.selectField('agent.raw', 'metrics'); @@ -192,7 +191,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.navigateToNewVisualization(); await PageObjects.visualize.clickDataTable(); await PageObjects.visualize.clickNewSearch(); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.visualize.clickBucket('Split Rows'); await PageObjects.visualize.selectAggregation('Range'); await PageObjects.visualize.selectField('bytes'); @@ -210,7 +209,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.navigateToNewVisualization(); await PageObjects.visualize.clickDataTable(); await PageObjects.visualize.clickNewSearch(); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.visualize.clickBucket('Split Rows'); await PageObjects.visualize.selectAggregation('Terms'); await PageObjects.visualize.selectField('extension.raw'); @@ -248,7 +247,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.navigateToNewVisualization(); await PageObjects.visualize.clickDataTable(); await PageObjects.visualize.clickNewSearch(); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.visualize.clickBucket('Split Rows'); await PageObjects.visualize.selectAggregation('Terms'); await PageObjects.visualize.selectField('extension.raw'); @@ -326,7 +325,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.navigateToNewVisualization(); await PageObjects.visualize.clickDataTable(); await PageObjects.visualize.clickNewSearch(); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.visualize.clickBucket('Split Table'); await PageObjects.visualize.selectAggregation('Terms'); await PageObjects.visualize.selectField('extension.raw'); diff --git a/test/functional/apps/visualize/_embedding_chart.js b/test/functional/apps/visualize/_embedding_chart.js index 5cffa53dc7e77..b6caa77d32406 100644 --- a/test/functional/apps/visualize/_embedding_chart.js +++ b/test/functional/apps/visualize/_embedding_chart.js @@ -24,7 +24,7 @@ export default function ({ getService, getPageObjects }) { const log = getService('log'); const renderable = getService('renderable'); const embedding = getService('embedding'); - const PageObjects = getPageObjects(['common', 'visualize', 'header']); + const PageObjects = getPageObjects(['common', 'visualize', 'header', 'timePicker']); const fromTime = '2015-09-19 06:31:44.000'; const toTime = '2015-09-23 18:31:44.000'; @@ -36,7 +36,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.navigateToNewVisualization(); await PageObjects.visualize.clickDataTable(); await PageObjects.visualize.clickNewSearch(); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.visualize.clickBucket('Split Rows'); await PageObjects.visualize.selectAggregation('Date Histogram'); await PageObjects.visualize.selectField('@timestamp'); diff --git a/test/functional/apps/visualize/_gauge_chart.js b/test/functional/apps/visualize/_gauge_chart.js index cc7c5f2ab7658..080f3eaf52eb6 100644 --- a/test/functional/apps/visualize/_gauge_chart.js +++ b/test/functional/apps/visualize/_gauge_chart.js @@ -23,7 +23,7 @@ export default function ({ getService, getPageObjects }) { const log = getService('log'); const retry = getService('retry'); const inspector = getService('inspector'); - const PageObjects = getPageObjects(['common', 'visualize', 'header']); + const PageObjects = getPageObjects(['common', 'visualize', 'timePicker']); describe('gauge chart', function indexPatternCreation() { const fromTime = '2015-09-19 06:31:44.000'; @@ -35,8 +35,7 @@ export default function ({ getService, getPageObjects }) { log.debug('clickGauge'); await PageObjects.visualize.clickGauge(); await PageObjects.visualize.clickNewSearch(); - log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); }); diff --git a/test/functional/apps/visualize/_heatmap_chart.js b/test/functional/apps/visualize/_heatmap_chart.js index 708f2fc340ed2..795cfbe0e0763 100644 --- a/test/functional/apps/visualize/_heatmap_chart.js +++ b/test/functional/apps/visualize/_heatmap_chart.js @@ -22,7 +22,7 @@ import expect from 'expect.js'; export default function ({ getService, getPageObjects }) { const log = getService('log'); const inspector = getService('inspector'); - const PageObjects = getPageObjects(['common', 'visualize', 'header']); + const PageObjects = getPageObjects(['common', 'visualize', 'timePicker']); describe('heatmap chart', function indexPatternCreation() { const vizName1 = 'Visualization HeatmapChart'; @@ -35,8 +35,7 @@ export default function ({ getService, getPageObjects }) { log.debug('clickHeatmapChart'); await PageObjects.visualize.clickHeatmapChart(); await PageObjects.visualize.clickNewSearch(); - log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); log.debug('Bucket = X-Axis'); await PageObjects.visualize.clickBucket('X-Axis'); log.debug('Aggregation = Date Histogram'); diff --git a/test/functional/apps/visualize/_histogram_request_start.js b/test/functional/apps/visualize/_histogram_request_start.js index e7fd05dc018f5..95eda5003e7f5 100644 --- a/test/functional/apps/visualize/_histogram_request_start.js +++ b/test/functional/apps/visualize/_histogram_request_start.js @@ -22,7 +22,7 @@ import expect from 'expect.js'; export default function ({ getService, getPageObjects }) { const log = getService('log'); const retry = getService('retry'); - const PageObjects = getPageObjects(['common', 'visualize', 'header']); + const PageObjects = getPageObjects(['common', 'visualize', 'timePicker']); describe('histogram agg onSearchRequestStart', function () { before(async function () { @@ -34,8 +34,7 @@ export default function ({ getService, getPageObjects }) { log.debug('clickDataTable'); await PageObjects.visualize.clickDataTable(); await PageObjects.visualize.clickNewSearch(); - log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); log.debug('Bucket = Split Rows'); await PageObjects.visualize.clickBucket('Split Rows'); log.debug('Aggregation = Histogram'); diff --git a/test/functional/apps/visualize/_input_control_vis.js b/test/functional/apps/visualize/_input_control_vis.js index c95991094980b..45e5a74fc1e48 100644 --- a/test/functional/apps/visualize/_input_control_vis.js +++ b/test/functional/apps/visualize/_input_control_vis.js @@ -21,7 +21,7 @@ import expect from 'expect.js'; export default function ({ getService, getPageObjects }) { const filterBar = getService('filterBar'); - const PageObjects = getPageObjects(['common', 'visualize', 'header']); + const PageObjects = getPageObjects(['common', 'visualize', 'header', 'timePicker']); const testSubjects = getService('testSubjects'); const inspector = getService('inspector'); const find = getService('find'); @@ -35,7 +35,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.navigateToNewVisualization(); await PageObjects.visualize.clickInputControlVis(); // set time range to time with no documents - input controls do not use time filter be default - await PageObjects.header.setAbsoluteRange('2017-01-01', '2017-01-02'); + await PageObjects.timePicker.setAbsoluteRange('2017-01-01 00:00:00.000', '2017-01-02 00:00:00.000'); await PageObjects.visualize.clickVisEditorTab('controls'); await PageObjects.visualize.addInputControl(); await comboBox.set('indexPatternSelect-0', 'logstash- '); @@ -168,8 +168,7 @@ export default function ({ getService, getPageObjects }) { }); it('should re-create control when global time filter is updated', async () => { - await PageObjects.header.setAbsoluteRange('2015-01-01', '2016-01-01'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.timePicker.setAbsoluteRange('2015-01-01 00:00:00.000', '2016-01-01 00:00:00.000'); // Expect control to have values for selected time filter const menu = await comboBox.getOptionsList('listControlSelect0'); diff --git a/test/functional/apps/visualize/_inspector.js b/test/functional/apps/visualize/_inspector.js index ea62939a85111..f90a48510c5e5 100644 --- a/test/functional/apps/visualize/_inspector.js +++ b/test/functional/apps/visualize/_inspector.js @@ -22,7 +22,7 @@ export default function ({ getService, getPageObjects }) { const log = getService('log'); const inspector = getService('inspector'); const filterBar = getService('filterBar'); - const PageObjects = getPageObjects(['common', 'visualize', 'header']); + const PageObjects = getPageObjects(['common', 'visualize', 'timePicker']); describe('inspector', function describeIndexTests() { before(async function () { @@ -33,8 +33,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.clickVerticalBarChart(); await PageObjects.visualize.clickNewSearch(); - log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); }); describe('inspector table', function indexPatternCreation() { diff --git a/test/functional/apps/visualize/_line_chart.js b/test/functional/apps/visualize/_line_chart.js index 9f756ffdf3813..350168006227f 100644 --- a/test/functional/apps/visualize/_line_chart.js +++ b/test/functional/apps/visualize/_line_chart.js @@ -23,7 +23,7 @@ export default function ({ getService, getPageObjects }) { const log = getService('log'); const inspector = getService('inspector'); const retry = getService('retry'); - const PageObjects = getPageObjects(['common', 'visualize', 'header']); + const PageObjects = getPageObjects(['common', 'visualize', 'timePicker']); describe('line charts', function () { const vizName1 = 'Visualization LineChart'; @@ -37,8 +37,7 @@ export default function ({ getService, getPageObjects }) { log.debug('clickLineChart'); await PageObjects.visualize.clickLineChart(); await PageObjects.visualize.clickNewSearch(); - log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); log.debug('Bucket = Split Chart'); await PageObjects.visualize.clickBucket('Split Chart'); log.debug('Aggregation = Terms'); diff --git a/test/functional/apps/visualize/_linked_saved_searches.js b/test/functional/apps/visualize/_linked_saved_searches.js index 52ce657ee720a..9a80126f5447c 100644 --- a/test/functional/apps/visualize/_linked_saved_searches.js +++ b/test/functional/apps/visualize/_linked_saved_searches.js @@ -22,7 +22,7 @@ import expect from 'expect.js'; export default function ({ getService, getPageObjects }) { const filterBar = getService('filterBar'); const retry = getService('retry'); - const PageObjects = getPageObjects(['common', 'discover', 'visualize', 'header']); + const PageObjects = getPageObjects(['common', 'discover', 'visualize', 'header', 'timePicker']); describe('visualize app', function describeIndexTests() { const fromTime = '2015-09-19 06:31:44.000'; @@ -45,8 +45,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.navigateToNewVisualization(); await PageObjects.visualize.clickDataTable(); await PageObjects.visualize.clickSavedSearch(savedSearchName); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); - await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await retry.waitFor('wait for count to equal 9,109', async () => { const data = await PageObjects.visualize.getTableVisData(); return data.trim() === '9,109'; @@ -54,8 +53,7 @@ export default function ({ getService, getPageObjects }) { }); it('should respect the time filter when linked to a saved search', async () => { - await PageObjects.header.setAbsoluteRange('2015-09-19 06:31:44.000', '2015-09-21 10:00:00.000'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.timePicker.setAbsoluteRange('2015-09-19 06:31:44.000', '2015-09-21 10:00:00.000'); await retry.waitFor('wait for count to equal 3,950', async () => { const data = await PageObjects.visualize.getTableVisData(); return data.trim() === '3,950'; diff --git a/test/functional/apps/visualize/_metric_chart.js b/test/functional/apps/visualize/_metric_chart.js index c2b7fb0c9b763..fbece9f724814 100644 --- a/test/functional/apps/visualize/_metric_chart.js +++ b/test/functional/apps/visualize/_metric_chart.js @@ -23,7 +23,7 @@ export default function ({ getService, getPageObjects }) { const log = getService('log'); const retry = getService('retry'); const inspector = getService('inspector'); - const PageObjects = getPageObjects(['common', 'visualize', 'header']); + const PageObjects = getPageObjects(['common', 'visualize', 'timePicker']); describe('metric chart', function () { const fromTime = '2015-09-19 06:31:44.000'; @@ -35,8 +35,7 @@ export default function ({ getService, getPageObjects }) { log.debug('clickMetric'); await PageObjects.visualize.clickMetric(); await PageObjects.visualize.clickNewSearch(); - log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); }); it('should have inspector enabled', async function () { diff --git a/test/functional/apps/visualize/_pie_chart.js b/test/functional/apps/visualize/_pie_chart.js index 3b9442e1ffad0..853cabef206f4 100644 --- a/test/functional/apps/visualize/_pie_chart.js +++ b/test/functional/apps/visualize/_pie_chart.js @@ -24,7 +24,7 @@ export default function ({ getService, getPageObjects }) { const filterBar = getService('filterBar'); const pieChart = getService('pieChart'); const inspector = getService('inspector'); - const PageObjects = getPageObjects(['common', 'visualize', 'header', 'settings']); + const PageObjects = getPageObjects(['common', 'visualize', 'header', 'settings', 'timePicker']); const fromTime = '2015-09-19 06:31:44.000'; const toTime = '2015-09-23 18:31:44.000'; @@ -36,8 +36,7 @@ export default function ({ getService, getPageObjects }) { log.debug('clickPieChart'); await PageObjects.visualize.clickPieChart(); await PageObjects.visualize.clickNewSearch(); - log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); log.debug('select bucket Split Slices'); await PageObjects.visualize.clickBucket('Split Slices'); log.debug('Click aggregation Histogram'); @@ -86,8 +85,7 @@ export default function ({ getService, getPageObjects }) { log.debug('clickPieChart'); await PageObjects.visualize.clickPieChart(); await PageObjects.visualize.clickNewSearch(); - log.debug(`Set absolute time range from "${fromTime}" to "${toTime}"`); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); log.debug('select bucket Split Slices'); await PageObjects.visualize.clickBucket('Split Slices'); log.debug('Click aggregation Terms'); @@ -191,8 +189,7 @@ export default function ({ getService, getPageObjects }) { log.debug('clickPieChart'); await PageObjects.visualize.clickPieChart(); await PageObjects.visualize.clickNewSearch(); - log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); log.debug('select bucket Split Slices'); await PageObjects.visualize.clickBucket('Split Slices'); log.debug('Click aggregation Filters'); @@ -207,7 +204,7 @@ export default function ({ getService, getPageObjects }) { const emptyFromTime = '2016-09-19 06:31:44.000'; const emptyToTime = '2016-09-23 18:31:44.000'; log.debug('Switch to a different time range from \"' + emptyFromTime + '\" to \"' + emptyToTime + '\"'); - await PageObjects.header.setAbsoluteRange(emptyFromTime, emptyToTime); + await PageObjects.timePicker.setAbsoluteRange(emptyFromTime, emptyToTime); await PageObjects.visualize.waitForVisualization(); await PageObjects.visualize.expectError(); }); @@ -220,7 +217,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.clickPieChart(); await PageObjects.visualize.clickNewSearch(); log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); log.debug('select bucket Split Slices'); await PageObjects.visualize.clickBucket('Split Slices'); log.debug('Click aggregation Histogram'); @@ -281,8 +278,7 @@ export default function ({ getService, getPageObjects }) { log.debug('clickPieChart'); await PageObjects.visualize.clickPieChart(); await PageObjects.visualize.clickNewSearch(); - log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); log.debug('select bucket Split Slices'); await PageObjects.visualize.clickBucket('Split Slices'); log.debug('Click aggregation Filters'); @@ -311,8 +307,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.navigateToNewVisualization(); await PageObjects.visualize.clickPieChart(); await PageObjects.visualize.clickNewSearch(); - log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); log.debug('select bucket Split Slices'); await PageObjects.visualize.clickBucket('Split Chart'); await PageObjects.visualize.selectAggregation('Terms'); diff --git a/test/functional/apps/visualize/_point_series_options.js b/test/functional/apps/visualize/_point_series_options.js index d4522ece37692..5d5729e75cafb 100644 --- a/test/functional/apps/visualize/_point_series_options.js +++ b/test/functional/apps/visualize/_point_series_options.js @@ -22,7 +22,7 @@ import expect from 'expect.js'; export default function ({ getService, getPageObjects }) { const log = getService('log'); const retry = getService('retry'); - const PageObjects = getPageObjects(['common', 'visualize', 'header', 'pointSeries']); + const PageObjects = getPageObjects(['common', 'visualize', 'header', 'pointSeries', 'timePicker']); const pointSeriesVis = PageObjects.pointSeries; describe('point series', function describeIndexTests() { @@ -35,8 +35,7 @@ export default function ({ getService, getPageObjects }) { log.debug('clickLineChart'); await PageObjects.visualize.clickLineChart(); await PageObjects.visualize.clickNewSearch(); - log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); log.debug('Bucket = X-Axis'); await PageObjects.visualize.clickBucket('X-Axis'); log.debug('Aggregation = Date Histogram'); diff --git a/test/functional/apps/visualize/_region_map.js b/test/functional/apps/visualize/_region_map.js index 652de69023d5a..f724e0029fd7e 100644 --- a/test/functional/apps/visualize/_region_map.js +++ b/test/functional/apps/visualize/_region_map.js @@ -29,7 +29,7 @@ export default function ({ getService, getPageObjects }) { const inspector = getService('inspector'); const log = getService('log'); const find = getService('find'); - const PageObjects = getPageObjects(['common', 'visualize', 'header', 'settings']); + const PageObjects = getPageObjects(['common', 'visualize', 'timePicker', 'settings']); before(async function () { @@ -38,8 +38,7 @@ export default function ({ getService, getPageObjects }) { log.debug('clickRegionMap'); await PageObjects.visualize.clickRegionMap(); await PageObjects.visualize.clickNewSearch(); - log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); log.debug('Bucket = shape field'); await PageObjects.visualize.clickBucket('shape field'); log.debug('Aggregation = Terms'); diff --git a/test/functional/apps/visualize/_tag_cloud.js b/test/functional/apps/visualize/_tag_cloud.js index 754e65fb4b6e6..8f51e35d03d6a 100644 --- a/test/functional/apps/visualize/_tag_cloud.js +++ b/test/functional/apps/visualize/_tag_cloud.js @@ -26,7 +26,7 @@ export default function ({ getService, getPageObjects }) { const browser = getService('browser'); const retry = getService('retry'); const find = getService('find'); - const PageObjects = getPageObjects(['common', 'visualize', 'header', 'settings']); + const PageObjects = getPageObjects(['common', 'visualize', 'header', 'settings', 'timePicker']); describe('tag cloud chart', function () { const vizName1 = 'Visualization tagCloud'; @@ -40,8 +40,7 @@ export default function ({ getService, getPageObjects }) { log.debug('clickTagCloud'); await PageObjects.visualize.clickTagCloud(); await PageObjects.visualize.clickNewSearch(); - log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); log.debug('select Tags'); await PageObjects.visualize.clickBucket('Tags'); log.debug('Click aggregation Terms'); @@ -140,7 +139,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.common.navigateToApp('visualize'); await PageObjects.visualize.loadSavedVisualization(vizName1, { navigateToVisualize: false }); await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.visualize.waitForVisualization(); }); diff --git a/test/functional/apps/visualize/_tile_map.js b/test/functional/apps/visualize/_tile_map.js index a66e6c3941742..f172d811974e3 100644 --- a/test/functional/apps/visualize/_tile_map.js +++ b/test/functional/apps/visualize/_tile_map.js @@ -26,7 +26,7 @@ export default function ({ getService, getPageObjects }) { const find = getService('find'); const testSubjects = getService('testSubjects'); const browser = getService('browser'); - const PageObjects = getPageObjects(['common', 'visualize', 'header', 'settings']); + const PageObjects = getPageObjects(['common', 'visualize', 'timePicker', 'settings']); describe('tile map visualize app', function () { @@ -44,8 +44,7 @@ export default function ({ getService, getPageObjects }) { log.debug('clickTileMap'); await PageObjects.visualize.clickTileMap(); await PageObjects.visualize.clickNewSearch(); - log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); //do not configure aggs }); @@ -70,8 +69,7 @@ export default function ({ getService, getPageObjects }) { log.debug('clickTileMap'); await PageObjects.visualize.clickTileMap(); await PageObjects.visualize.clickNewSearch(); - log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); log.debug('select bucket Geo Coordinates'); await PageObjects.visualize.clickBucket('Geo Coordinates'); log.debug('Click aggregation Geohash'); diff --git a/test/functional/apps/visualize/_tsvb_chart.js b/test/functional/apps/visualize/_tsvb_chart.js index 16d0515ee2303..4ed66b35c776b 100644 --- a/test/functional/apps/visualize/_tsvb_chart.js +++ b/test/functional/apps/visualize/_tsvb_chart.js @@ -26,7 +26,7 @@ export default function ({ getService, getPageObjects }) { const retry = getService('retry'); const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['common', 'visualize', 'header', 'settings', 'visualBuilder']); + const PageObjects = getPageObjects(['common', 'visualize', 'header', 'settings', 'visualBuilder', 'timePicker']); describe('visual builder', function describeIndexTests() { @@ -36,8 +36,11 @@ export default function ({ getService, getPageObjects }) { }); it('should show the correct count in the legend', async function () { - const actualCount = await PageObjects.visualBuilder.getRhythmChartLegendValue(); - expect(actualCount).to.be('156'); + await retry.try(async () => { + await PageObjects.header.waitUntilLoadingHasFinished(); + const actualCount = await PageObjects.visualBuilder.getRhythmChartLegendValue(); + expect(actualCount).to.be('156'); + }); }); it('should show the correct count in the legend with 2h offset', async function () { @@ -134,11 +137,13 @@ export default function ({ getService, getPageObjects }) { }); it('should verify topN label and count display', async function () { - await PageObjects.visualize.waitForVisualization(); - const labelString = await PageObjects.visualBuilder.getTopNLabel(); - expect(labelString).to.be('Count'); - const gaugeCount = await PageObjects.visualBuilder.getTopNCount(); - expect(gaugeCount).to.be('156'); + await retry.try(async () => { + await PageObjects.visualize.waitForVisualization(); + const labelString = await PageObjects.visualBuilder.getTopNLabel(); + expect(labelString).to.be('Count'); + const gaugeCount = await PageObjects.visualBuilder.getTopNCount(); + expect(gaugeCount).to.be('156'); + }); }); }); @@ -149,13 +154,15 @@ export default function ({ getService, getPageObjects }) { before(async () => { await PageObjects.visualBuilder.resetPage(); await PageObjects.visualBuilder.clickMarkdown(); - await PageObjects.header.setAbsoluteRange('2015-09-22 06:00:00.000', '2015-09-22 11:00:00.000'); + await PageObjects.timePicker.setAbsoluteRange('2015-09-22 06:00:00.000', '2015-09-22 11:00:00.000'); }); it('should allow printing raw timestamp of data', async () => { - await PageObjects.visualBuilder.enterMarkdown('{{ count.data.raw.[0].[0] }}'); - const text = await PageObjects.visualBuilder.getMarkdownText(); - expect(text).to.be('1442901600000'); + await retry.try(async () => { + await PageObjects.visualBuilder.enterMarkdown('{{ count.data.raw.[0].[0] }}'); + const text = await PageObjects.visualBuilder.getMarkdownText(); + expect(text).to.be('1442901600000'); + }); }); it('should allow printing raw value of data', async () => { @@ -196,7 +203,7 @@ export default function ({ getService, getPageObjects }) { before(async () => { await PageObjects.visualBuilder.resetPage(); await PageObjects.visualBuilder.clickTable(); - await PageObjects.header.setAbsoluteRange('2015-09-22 06:00:00.000', '2015-09-22 11:00:00.000'); + await PageObjects.timePicker.setAbsoluteRange('2015-09-22 06:00:00.000', '2015-09-22 11:00:00.000'); log.debug('clicked on Table'); }); @@ -233,8 +240,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualBuilder.clickMetricPanelOptions(); const fromTime = '2018-10-22 00:00:00.000'; const toTime = '2018-10-28 23:59:59.999'; - log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.visualBuilder.setIndexPatternValue('kibana_sample_data_flights'); await PageObjects.visualBuilder.selectIndexPatternTimeField('timestamp'); const newValue = await PageObjects.visualBuilder.getMetricValue(); diff --git a/test/functional/apps/visualize/_vertical_bar_chart.js b/test/functional/apps/visualize/_vertical_bar_chart.js index 0954f4e5e7f88..b5e7bd122560d 100644 --- a/test/functional/apps/visualize/_vertical_bar_chart.js +++ b/test/functional/apps/visualize/_vertical_bar_chart.js @@ -24,7 +24,7 @@ export default function ({ getService, getPageObjects }) { const retry = getService('retry'); const inspector = getService('inspector'); const filterBar = getService('filterBar'); - const PageObjects = getPageObjects(['common', 'visualize', 'header']); + const PageObjects = getPageObjects(['common', 'visualize', 'header', 'timePicker']); describe('vertical bar chart', function () { const fromTime = '2015-09-19 06:31:44.000'; @@ -37,8 +37,7 @@ export default function ({ getService, getPageObjects }) { log.debug('clickVerticalBarChart'); await PageObjects.visualize.clickVerticalBarChart(); await PageObjects.visualize.clickNewSearch(); - log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); log.debug('Bucket = X-Axis'); await PageObjects.visualize.clickBucket('X-Axis'); log.debug('Aggregation = Date Histogram'); @@ -113,7 +112,7 @@ export default function ({ getService, getPageObjects }) { const fromTime = '2015-09-20 06:31:44.000'; const toTime = '2015-09-22 18:31:44.000'; - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); let expectedChartValues = [ 82, 218, 341, 440, 480, 517, 522, 446, 403, 321, 258, 172, 95, 55, 38, 24, 3, 4, diff --git a/test/functional/page_objects/dashboard_page.js b/test/functional/page_objects/dashboard_page.js index 902f016f13ee8..d8516d7325990 100644 --- a/test/functional/page_objects/dashboard_page.js +++ b/test/functional/page_objects/dashboard_page.js @@ -35,7 +35,7 @@ export function DashboardPageProvider({ getService, getPageObjects }) { const testSubjects = getService('testSubjects'); const dashboardAddPanel = getService('dashboardAddPanel'); const renderable = getService('renderable'); - const PageObjects = getPageObjects(['common', 'header', 'settings', 'visualize']); + const PageObjects = getPageObjects(['common', 'header', 'settings', 'visualize', 'timePicker']); const defaultFindTimeout = config.get('timeouts.find'); @@ -495,19 +495,19 @@ export function DashboardPageProvider({ getService, getPageObjects }) { async setTimepickerInHistoricalDataRange() { const fromTime = '2015-09-19 06:31:44.000'; const toTime = '2015-09-23 18:31:44.000'; - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); } async setTimepickerInDataRange() { const fromTime = '2018-01-01 00:00:00.000'; const toTime = '2018-04-13 00:00:00.000'; - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); } async setTimepickerInLogstashDataRange() { const fromTime = '2018-04-09 00:00:00.000'; const toTime = '2018-04-13 00:00:00.000'; - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); } async setSaveAsNewCheckBox(checked) { diff --git a/test/functional/page_objects/discover_page.js b/test/functional/page_objects/discover_page.js index bc2bc7cd0d7f3..1124258f3f37d 100644 --- a/test/functional/page_objects/discover_page.js +++ b/test/functional/page_objects/discover_page.js @@ -218,15 +218,8 @@ export function DiscoverPageProvider({ getService, getPageObjects }) { return await testSubjects.exists('discoverNoResults'); } - async getNoResultsTimepicker() { - return await testSubjects.find('discoverNoResultsTimefilter'); - } - - hasNoResultsTimepicker() { - return this - .getNoResultsTimepicker() - .then(() => true) - .catch(() => false); + async hasNoResultsTimepicker() { + return await testSubjects.exists('discoverNoResultsTimefilter'); } async clickFieldListItem(field) { diff --git a/test/functional/page_objects/header_page.js b/test/functional/page_objects/header_page.js index 47f9dc231fce1..b3dd6f17b45c3 100644 --- a/test/functional/page_objects/header_page.js +++ b/test/functional/page_objects/header_page.js @@ -65,145 +65,6 @@ export function HeaderPageProvider({ getService, getPageObjects }) { await this.awaitGlobalLoadingIndicatorHidden(); } - async clickTimepicker() { - await testSubjects.click('globalTimepickerButton'); - } - - async clickQuickButton() { - await retry.try(async () => { - await testSubjects.click('timepicker-quick-button'); - }); - } - - async isTimepickerOpen() { - return await testSubjects.exists('timePicker'); - } - - async isAbsoluteSectionShowing() { - log.debug('isAbsoluteSectionShowing'); - return await find.existsByCssSelector('input[ng-model=\'absolute.from\']'); - } - - async showAbsoluteSection() { - log.debug('showAbsoluteSection'); - const isAbsoluteSectionShowing = await this.isAbsoluteSectionShowing(); - if (!isAbsoluteSectionShowing) { - await retry.try(async () => { - await testSubjects.click('timepicker-absolute-button'); - // Check to make sure one of the elements on the absolute section is showing. - await this.getFromTime(); - }); - } - } - - async getFromTime() { - log.debug('getFromTime'); - return await retry.try(async () => { - await this.ensureTimePickerIsOpen(); - await this.showAbsoluteSection(); - const element = await find.byCssSelector('input[ng-model=\'absolute.from\']'); - return await element.getProperty('value'); - }); - } - - async getToTime() { - log.debug('getToTime'); - return await retry.try(async () => { - await this.ensureTimePickerIsOpen(); - await this.showAbsoluteSection(); - const element = await find.byCssSelector('input[ng-model=\'absolute.to\']'); - return await element.getProperty('value'); - }); - } - - async setFromTime(timeString) { - log.debug(`setFromTime: ${timeString}`); - await retry.try(async () => { - await this.ensureTimePickerIsOpen(); - await this.showAbsoluteSection(); - await find.setValue('input[ng-model=\'absolute.from\']', timeString); - }); - } - - async setToTime(timeString) { - log.debug(`setToTime: ${timeString}`); - await retry.try(async () => { - await this.ensureTimePickerIsOpen(); - await this.showAbsoluteSection(); - await find.setValue('input[ng-model=\'absolute.to\']', timeString); - }); - } - - async clickGoButton() { - log.debug('clickGoButton'); - await retry.try(async () => { - await testSubjects.click('timepickerGoButton'); - await this.waitUntilLoadingHasFinished(); - }); - } - - async ensureTimePickerIsOpen() { - log.debug('ensureTimePickerIsOpen'); - const isOpen = await this.isTimepickerOpen(); - if (!isOpen) { - await retry.try(async () => { - await this.clickTimepicker(); - const isOpen = await this.isTimepickerOpen(); - if (!isOpen) throw new Error('Time picker still not open, try again.'); - }); - } - } - - async setAbsoluteRange(fromTime, toTime) { - log.debug(`Setting absolute range to ${fromTime} to ${toTime}`); - await this.ensureTimePickerIsOpen(); - log.debug('--Clicking Absolute button'); - await this.showAbsoluteSection(); - log.debug('--Setting From Time : ' + fromTime); - await this.setFromTime(fromTime); - log.debug('--Setting To Time : ' + toTime); - await this.setToTime(toTime); - await this.clickGoButton(); - await this.awaitGlobalLoadingIndicatorHidden(); - } - - async setQuickTime(quickTime) { - await this.ensureTimePickerIsOpen(); - log.debug('--Clicking Quick button'); - await this.clickQuickButton(); - await find.clickByLinkText(quickTime); - } - - async getAutoRefreshState() { - return testSubjects.getAttribute('globalTimepickerAutoRefreshButton', 'data-test-subj-state'); - } - - async getRefreshConfig() { - const refreshState = await testSubjects.getAttribute('globalTimepickerAutoRefreshButton', 'data-test-subj-state'); - const refreshConfig = await testSubjects.getVisibleText('globalRefreshButton'); - return `${refreshState} ${refreshConfig}`; - } - - // check if the auto refresh state is active and to pause it - async pauseAutoRefresh() { - let result = false; - if ((await this.getAutoRefreshState()) === 'active') { - await testSubjects.click('globalTimepickerAutoRefreshButton'); - result = true; - } - return result; - } - - // check if the auto refresh state is inactive and to resume it - async resumeAutoRefresh() { - let result = false; - if ((await this.getAutoRefreshState()) === 'inactive') { - await testSubjects.click('globalTimepickerAutoRefreshButton'); - result = true; - } - return result; - } - async getToastMessage(findTimeout = defaultFindTimeout) { const toastMessage = await find.displayedByCssSelector( 'kbn-truncated.kbnToast__message', @@ -249,13 +110,6 @@ export function HeaderPageProvider({ getService, getPageObjects }) { await testSubjects.find('kibanaChrome', defaultFindTimeout * 10); } - async getPrettyDuration() { - return await testSubjects.getVisibleText('globalTimepickerRange'); - } - - async isSharedTimefilterEnabled() { - return await find.existsByCssSelector('[shared-timefilter=true]'); - } } return new HeaderPage(); diff --git a/test/functional/page_objects/time_picker.js b/test/functional/page_objects/time_picker.js index 654f7232b1a8a..04b097890ea42 100644 --- a/test/functional/page_objects/time_picker.js +++ b/test/functional/page_objects/time_picker.js @@ -17,6 +17,8 @@ * under the License. */ +import moment from 'moment'; + export function TimePickerPageProvider({ getService, getPageObjects }) { const log = getService('log'); const retry = getService('retry'); @@ -134,6 +136,35 @@ export function TimePickerPageProvider({ getService, getPageObjects }) { }; } + async getTimeConfigAsAbsoluteTimes() { + await this.showStartEndTimes(); + + // get to time + await testSubjects.click('superDatePickerendDatePopoverButton'); + await testSubjects.click('superDatePickerAbsoluteTab'); + const end = await testSubjects.getAttribute('superDatePickerAbsoluteDateInput', 'value'); + + // get from time + await testSubjects.click('superDatePickerstartDatePopoverButton'); + await testSubjects.click('superDatePickerAbsoluteTab'); + const start = await testSubjects.getAttribute('superDatePickerAbsoluteDateInput', 'value'); + + return { + start, + end + }; + } + + async getTimeDurationInHours() { + const DEFAULT_DATE_FORMAT = 'MMM D, YYYY @ HH:mm:ss.SSS'; + const { start, end } = await this.getTimeConfigAsAbsoluteTimes(); + + const startMoment = moment(start, DEFAULT_DATE_FORMAT); + const endMoment = moment(end, DEFAULT_DATE_FORMAT); + + return moment.duration(moment(endMoment) - moment(startMoment)).asHours(); + } + async pauseAutoRefresh() { log.debug('pauseAutoRefresh'); const refreshConfig = await this.getRefreshConfig(true); diff --git a/test/functional/page_objects/visual_builder_page.js b/test/functional/page_objects/visual_builder_page.js index ed7d0e3ca311d..5dca134b3539f 100644 --- a/test/functional/page_objects/visual_builder_page.js +++ b/test/functional/page_objects/visual_builder_page.js @@ -24,7 +24,7 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }) { const browser = getService('browser'); const testSubjects = getService('testSubjects'); const comboBox = getService('comboBox'); - const PageObjects = getPageObjects(['common', 'header', 'visualize']); + const PageObjects = getPageObjects(['common', 'header', 'visualize', 'timePicker']); class VisualBuilderPage { @@ -36,8 +36,7 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }) { log.debug('clickVisualBuilderChart'); await PageObjects.visualize.clickVisualBuilder(); log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); - await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); } async clickMetric() { diff --git a/test/functional/page_objects/visualize_page.js b/test/functional/page_objects/visualize_page.js index b98e8413805c8..be372d74a9b19 100644 --- a/test/functional/page_objects/visualize_page.js +++ b/test/functional/page_objects/visualize_page.js @@ -231,18 +231,6 @@ export function VisualizePageProvider({ getService, getPageObjects }) { return await find.byCssSelector('div.vgaVis__controls'); } - async setFromTime(timeString) { - const input = await find.byCssSelector('input[ng-model="absolute.from"]', defaultFindTimeout * 2); - await input.clearValue(); - await input.type(timeString); - } - - async setToTime(timeString) { - const input = await find.byCssSelector('input[ng-model="absolute.to"]', defaultFindTimeout * 2); - await input.clearValue(); - await input.type(timeString); - } - async addInputControl() { await testSubjects.click('inputControlEditorAddBtn'); await PageObjects.header.waitUntilLoadingHasFinished(); diff --git a/test/functional/services/combo_box.js b/test/functional/services/combo_box.js index a4f7c0e97709c..e3fda8863f014 100644 --- a/test/functional/services/combo_box.js +++ b/test/functional/services/combo_box.js @@ -35,6 +35,7 @@ export function ComboBoxProvider({ getService }) { async setElement(comboBoxElement, value) { log.debug(`comboBox.setElement, value: ${value}`); await this._filterOptionsList(comboBoxElement, value); + await this.openOptionsList(comboBoxElement); await find.clickByCssSelector('.euiComboBoxOption'); await this.closeOptionsList(comboBoxElement); } @@ -49,6 +50,7 @@ export function ComboBoxProvider({ getService }) { async _filterOptionsList(comboBoxElement, filterValue) { const input = await comboBoxElement.findByTagName('input'); await input.clearValue(); + await this._waitForOptionsListLoading(comboBoxElement); await input.type(filterValue); await this._waitForOptionsListLoading(comboBoxElement); } @@ -119,8 +121,16 @@ export function ComboBoxProvider({ getService }) { async closeOptionsList(comboBoxElement) { const isOptionsListOpen = await testSubjects.exists('comboBoxOptionsList'); if (isOptionsListOpen) { - const closeBtn = await comboBoxElement.findByCssSelector('[data-test-subj="comboBoxToggleListButton"]'); - await closeBtn.click(); + const toggleBtn = await comboBoxElement.findByCssSelector('[data-test-subj="comboBoxToggleListButton"]'); + await toggleBtn.click(); + } + } + + async openOptionsList(comboBoxElement) { + const isOptionsListOpen = await testSubjects.exists('comboBoxOptionsList'); + if (!isOptionsListOpen) { + const toggleBtn = await comboBoxElement.findByCssSelector('[data-test-subj="comboBoxToggleListButton"]'); + await toggleBtn.click(); } } diff --git a/x-pack/plugins/maps/public/shared/layers/vector_layer.js b/x-pack/plugins/maps/public/shared/layers/vector_layer.js index 59ae867b43ced..f8f019956f6a1 100644 --- a/x-pack/plugins/maps/public/shared/layers/vector_layer.js +++ b/x-pack/plugins/maps/public/shared/layers/vector_layer.js @@ -68,7 +68,7 @@ export class VectorLayer extends AbstractLayer { } isJoinable() { - return !this._source.isFilterByMapBounds(); + return true; } getJoins() { diff --git a/x-pack/test/functional/apps/dashboard_mode/dashboard_view_mode.js b/x-pack/test/functional/apps/dashboard_mode/dashboard_view_mode.js index b1739bdf4fb02..e06f7bc84979b 100644 --- a/x-pack/test/functional/apps/dashboard_mode/dashboard_view_mode.js +++ b/x-pack/test/functional/apps/dashboard_mode/dashboard_view_mode.js @@ -174,7 +174,7 @@ export default function ({ getService, getPageObjects }) { }); it('shows the timepicker', async () => { - const timePickerExists = await testSubjects.exists('globalTimepickerButton'); + const timePickerExists = await testSubjects.exists('superDatePickerApplyTimeButton'); expect(timePickerExists).to.be(true); }); diff --git a/x-pack/test/functional/apps/monitoring/_get_lifecycle_methods.js b/x-pack/test/functional/apps/monitoring/_get_lifecycle_methods.js index 252eb6e34bacf..cba22994f6f2b 100644 --- a/x-pack/test/functional/apps/monitoring/_get_lifecycle_methods.js +++ b/x-pack/test/functional/apps/monitoring/_get_lifecycle_methods.js @@ -6,7 +6,7 @@ export const getLifecycleMethods = (getService, getPageObjects) => { const esArchiver = getService('esArchiver'); - const PageObjects = getPageObjects(['monitoring', 'header']); + const PageObjects = getPageObjects(['monitoring', 'timePicker']); const noData = getService('monitoringNoData'); let _archive; @@ -30,9 +30,9 @@ export const getLifecycleMethods = (getService, getPageObjects) => { // pause autorefresh in the time filter because we don't wait any ticks, // and we don't want ES to log a warning when data gets wiped out - await PageObjects.header.pauseAutoRefresh(); + await PageObjects.timePicker.pauseAutoRefresh(); - await PageObjects.header.setAbsoluteRange(from, to); + await PageObjects.timePicker.setAbsoluteRange(from, to); }, tearDown() { diff --git a/x-pack/test/functional/apps/monitoring/beats/beat_detail.js b/x-pack/test/functional/apps/monitoring/beats/beat_detail.js index 2eab9f6354836..5ca033549f937 100644 --- a/x-pack/test/functional/apps/monitoring/beats/beat_detail.js +++ b/x-pack/test/functional/apps/monitoring/beats/beat_detail.js @@ -17,8 +17,8 @@ export default function ({ getService, getPageObjects }) { before(async () => { await setup('monitoring/beats', { - from: '2017-12-19 17:14:09', - to: '2017-12-19 18:15:09', + from: '2017-12-19 17:14:09.000', + to: '2017-12-19 18:15:09.000', }); // go to beats detail diff --git a/x-pack/test/functional/apps/monitoring/beats/cluster.js b/x-pack/test/functional/apps/monitoring/beats/cluster.js index 90482b432ca0d..949feef987851 100644 --- a/x-pack/test/functional/apps/monitoring/beats/cluster.js +++ b/x-pack/test/functional/apps/monitoring/beats/cluster.js @@ -15,8 +15,8 @@ export default function ({ getService, getPageObjects }) { before(async () => { await setup('monitoring/beats', { - from: '2017-12-19 17:14:09', - to: '2017-12-19 18:15:09', + from: '2017-12-19 17:14:09.000', + to: '2017-12-19 18:15:09.000', }); }); diff --git a/x-pack/test/functional/apps/monitoring/beats/listing.js b/x-pack/test/functional/apps/monitoring/beats/listing.js index f9f4a20f5ebc0..0a0148aee69c6 100644 --- a/x-pack/test/functional/apps/monitoring/beats/listing.js +++ b/x-pack/test/functional/apps/monitoring/beats/listing.js @@ -17,8 +17,8 @@ export default function ({ getService, getPageObjects }) { before(async () => { await setup('monitoring/beats', { - from: '2017-12-19 17:14:09', - to: '2017-12-19 18:15:09', + from: '2017-12-19 17:14:09.000', + to: '2017-12-19 18:15:09.000', }); // go to beats listing diff --git a/x-pack/test/functional/apps/monitoring/beats/overview.js b/x-pack/test/functional/apps/monitoring/beats/overview.js index f24c9e4270947..049ffc963c4f9 100644 --- a/x-pack/test/functional/apps/monitoring/beats/overview.js +++ b/x-pack/test/functional/apps/monitoring/beats/overview.js @@ -17,8 +17,8 @@ export default function ({ getService, getPageObjects }) { before(async () => { await setup('monitoring/beats', { - from: '2017-12-19 17:14:09', - to: '2017-12-19 18:15:09', + from: '2017-12-19 17:14:09.000', + to: '2017-12-19 18:15:09.000', }); // go to beats overview diff --git a/x-pack/test/functional/apps/monitoring/cluster/list.js b/x-pack/test/functional/apps/monitoring/cluster/list.js index 0be843c6c86c6..eae7882a2748c 100644 --- a/x-pack/test/functional/apps/monitoring/cluster/list.js +++ b/x-pack/test/functional/apps/monitoring/cluster/list.js @@ -21,8 +21,8 @@ export default function ({ getService, getPageObjects }) { before(async () => { await setup('monitoring/multicluster', { - from: '2017-08-15 21:00:00', - to: '2017-08-16 00:00:00', + from: '2017-08-15 21:00:00.000', + to: '2017-08-16 00:00:00.000', }); await clusterList.assertDefaults(); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/shards.js b/x-pack/test/functional/apps/monitoring/elasticsearch/shards.js index ea5fd1ad22730..dd106082d033a 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/shards.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/shards.js @@ -19,8 +19,8 @@ export default function ({ getService, getPageObjects }) { before(async () => { await setup('monitoring/singlecluster-three-nodes-shard-relocation', { - from: '2017-10-05 19:34:48', - to: '2017-10-05 20:35:12', + from: '2017-10-05 19:34:48.000', + to: '2017-10-05 20:35:12.000', }); }); diff --git a/x-pack/test/functional/apps/monitoring/logstash/pipelines.js b/x-pack/test/functional/apps/monitoring/logstash/pipelines.js index 0bca058467fa2..613a3d87efe7c 100644 --- a/x-pack/test/functional/apps/monitoring/logstash/pipelines.js +++ b/x-pack/test/functional/apps/monitoring/logstash/pipelines.js @@ -17,8 +17,8 @@ export default function ({ getService, getPageObjects }) { before(async () => { await setup('monitoring/logstash-pipelines', { - from: '2018-01-22 9:10:00.000', - to: '2018-01-22 9:41:00.000', + from: '2018-01-22 09:10:00.000', + to: '2018-01-22 09:41:00.000', }); // go to pipelines listing diff --git a/x-pack/test/functional/apps/security/rbac_phase1.js b/x-pack/test/functional/apps/security/rbac_phase1.js index bf8fb2efcb067..021a2df495562 100644 --- a/x-pack/test/functional/apps/security/rbac_phase1.js +++ b/x-pack/test/functional/apps/security/rbac_phase1.js @@ -8,7 +8,7 @@ import expect from 'expect.js'; import { indexBy } from 'lodash'; export default function ({ getService, getPageObjects }) { - const PageObjects = getPageObjects(['security', 'settings', 'common', 'visualize', 'header']); + const PageObjects = getPageObjects(['security', 'settings', 'common', 'visualize', 'timePicker']); const log = getService('log'); const esArchiver = getService('esArchiver'); const browser = getService('browser'); @@ -97,7 +97,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.clickVerticalBarChart(); await PageObjects.visualize.clickNewSearch(); log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.visualize.waitForVisualization(); await PageObjects.visualize.saveVisualizationExpectSuccess(vizName1); await PageObjects.security.logout(); @@ -116,7 +116,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.clickVerticalBarChart(); await PageObjects.visualize.clickNewSearch(); log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.visualize.waitForVisualization(); await PageObjects.visualize.saveVisualizationExpectFail(vizName1); await PageObjects.security.logout(); diff --git a/x-pack/test/functional/page_objects/reporting_page.js b/x-pack/test/functional/page_objects/reporting_page.js index 7cda7331fe717..356d23480ed64 100644 --- a/x-pack/test/functional/page_objects/reporting_page.js +++ b/x-pack/test/functional/page_objects/reporting_page.js @@ -15,7 +15,7 @@ export function ReportingPageProvider({ getService, getPageObjects }) { const esArchiver = getService('esArchiver'); const browser = getService('browser'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['common', 'security', 'header', 'settings', 'share']); + const PageObjects = getPageObjects(['common', 'security', 'settings', 'share', 'timePicker']); class ReportingPage { async initTests() { @@ -164,14 +164,14 @@ export function ReportingPageProvider({ getService, getPageObjects }) { log.debug('Reporting:setTimepickerInDataRange'); const fromTime = '2015-09-19 06:31:44.000'; const toTime = '2015-09-23 18:31:44.000'; - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); } async setTimepickerInNoDataRange() { log.debug('Reporting:setTimepickerInNoDataRange'); const fromTime = '1999-09-19 06:31:44.000'; const toTime = '1999-09-23 18:31:44.000'; - await PageObjects.header.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); } }