mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
fix merge conflicts (#21546)
This commit is contained in:
parent
3ed0076f00
commit
1e7d3f7bca
4 changed files with 49 additions and 26 deletions
|
@ -174,7 +174,7 @@ function convertISO8601(stringTime) {
|
|||
// and require it to be executed to properly function.
|
||||
// This function is exposed for applications that do not use uiRoutes like APM
|
||||
// Kibana issue https://github.com/elastic/kibana/issues/19110 tracks the removal of this dependency on uiRouter
|
||||
export const registerTimefilterWithGlobalState = _.once((globalState) => {
|
||||
export const registerTimefilterWithGlobalState = _.once((globalState, $rootScope) => {
|
||||
const uiSettings = chrome.getUiSettingsClient();
|
||||
const timeDefaults = uiSettings.get('timepicker:timeDefaults');
|
||||
const refreshIntervalDefaults = uiSettings.get('timepicker:refreshIntervalDefaults');
|
||||
|
@ -195,9 +195,19 @@ export const registerTimefilterWithGlobalState = _.once((globalState) => {
|
|||
timefilter.setTime(newTime);
|
||||
timefilter.setRefreshInterval(newRefreshInterval);
|
||||
});
|
||||
|
||||
const updateGlobalStateWithTime = () => {
|
||||
globalState.time = timefilter.getTime();
|
||||
globalState.refreshInterval = timefilter.getRefreshInterval();
|
||||
globalState.save();
|
||||
};
|
||||
|
||||
$rootScope.$listenAndDigestAsync(timefilter, 'refreshIntervalUpdate', updateGlobalStateWithTime);
|
||||
|
||||
$rootScope.$listenAndDigestAsync(timefilter, 'timeUpdate', updateGlobalStateWithTime);
|
||||
});
|
||||
|
||||
uiRoutes
|
||||
.addSetupWork((globalState) => {
|
||||
return registerTimefilterWithGlobalState(globalState);
|
||||
.addSetupWork((globalState, $rootScope) => {
|
||||
return registerTimefilterWithGlobalState(globalState, $rootScope);
|
||||
});
|
||||
|
|
|
@ -30,19 +30,12 @@ uiModules
|
|||
.directive('kbnGlobalTimepicker', (globalState, config) => {
|
||||
const getConfig = (...args) => config.get(...args);
|
||||
|
||||
const updateGlobalStateWithTime = ($scope) => {
|
||||
globalState.refreshInterval = timefilter.getRefreshInterval();
|
||||
globalState.time = timefilter.getTime();
|
||||
globalState.save();
|
||||
setTimefilterValues($scope);
|
||||
};
|
||||
|
||||
const listenForUpdates = ($scope) => {
|
||||
$scope.$listenAndDigestAsync(timefilter, 'refreshIntervalUpdate', () => {
|
||||
updateGlobalStateWithTime($scope);
|
||||
setTimefilterValues($scope);
|
||||
});
|
||||
$scope.$listenAndDigestAsync(timefilter, 'timeUpdate', () => {
|
||||
updateGlobalStateWithTime($scope);
|
||||
setTimefilterValues($scope);
|
||||
});
|
||||
$scope.$listenAndDigestAsync(timefilter, 'enabledUpdated', () => {
|
||||
setTimefilterValues($scope);
|
||||
|
@ -70,7 +63,8 @@ uiModules
|
|||
require: '^kbnTopNav',
|
||||
link: ($scope, element, attributes, kbnTopNav) => {
|
||||
listenForUpdates($scope);
|
||||
updateGlobalStateWithTime($scope);
|
||||
|
||||
setTimefilterValues($scope);
|
||||
|
||||
$scope.toggleRefresh = () => {
|
||||
timefilter.toggleRefresh();
|
||||
|
|
|
@ -24,8 +24,9 @@ const dashboardName = 'Dashboard Test Time';
|
|||
const fromTime = '2015-09-19 06:31:44.000';
|
||||
const toTime = '2015-09-23 18:31:44.000';
|
||||
|
||||
export default function ({ getPageObjects }) {
|
||||
export default function ({ getPageObjects, getService }) {
|
||||
const PageObjects = getPageObjects(['dashboard', 'header']);
|
||||
const remote = getService('remote');
|
||||
|
||||
describe('dashboard time', () => {
|
||||
before(async function () {
|
||||
|
@ -91,21 +92,39 @@ export default function ({ getPageObjects }) {
|
|||
expect(fromTimeNext).to.equal(fromTime);
|
||||
expect(toTimeNext).to.equal(toTime);
|
||||
});
|
||||
|
||||
// If time is stored with a dashboard, it's supposed to override the current time settings when opened.
|
||||
// However, if the URL also contains time in the global state, then the global state
|
||||
// time should take precedence.
|
||||
it('should be overwritten by global state', async function () {
|
||||
const currentUrl = await remote.getCurrentUrl();
|
||||
const kibanaBaseUrl = currentUrl.substring(0, currentUrl.indexOf('#'));
|
||||
const id = await PageObjects.dashboard.getDashboardIdFromCurrentUrl();
|
||||
|
||||
await PageObjects.dashboard.gotoDashboardLandingPage();
|
||||
|
||||
const urlWithGlobalTime = `${kibanaBaseUrl}#/dashboard/${id}?_g=(time:(from:now-1h,mode:quick,to:now))`;
|
||||
await remote.get(urlWithGlobalTime, false);
|
||||
const prettyPrint = await PageObjects.header.getPrettyDuration();
|
||||
expect(prettyPrint).to.equal('Last 1 hour');
|
||||
});
|
||||
});
|
||||
|
||||
// If the user has time stored with a dashboard, it's supposed to override the current time settings
|
||||
// when it's opened. However, if the user then changes the time, navigates to visualize, then navigates
|
||||
// back to dashboard, the overridden time should be preserved. The time is *only* reset on open, not
|
||||
// during navigation or page refreshes.
|
||||
// describe('time changes', function () {
|
||||
// it('preserved during navigation', async function () {
|
||||
// await PageObjects.header.setQuickTime('Today');
|
||||
// await PageObjects.header.clickVisualize();
|
||||
// await PageObjects.header.clickDashboard();
|
||||
//
|
||||
// const prettyPrint = await PageObjects.header.getPrettyDuration();
|
||||
// expect(prettyPrint).to.equal('Today');
|
||||
// });
|
||||
// });
|
||||
describe('time changes', function () {
|
||||
it('preserved during navigation', async function () {
|
||||
await PageObjects.dashboard.loadSavedDashboard(dashboardName);
|
||||
|
||||
await PageObjects.header.setQuickTime('Today');
|
||||
await PageObjects.header.clickVisualize();
|
||||
await PageObjects.header.clickDashboard();
|
||||
|
||||
const prettyPrint = await PageObjects.header.getPrettyDuration();
|
||||
expect(prettyPrint).to.equal('Today');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ export function initTimepicker(history, dispatch) {
|
|||
|
||||
uiModules
|
||||
.get('app/apm', [])
|
||||
.controller('TimePickerController', ($scope, globalState) => {
|
||||
.controller('TimePickerController', ($scope, globalState, $rootScope) => {
|
||||
// Add APM feedback menu
|
||||
// TODO: move this somewhere else
|
||||
$scope.topNavMenu = [];
|
||||
|
@ -59,7 +59,7 @@ export function initTimepicker(history, dispatch) {
|
|||
);
|
||||
|
||||
// ensure that timepicker updates when global state changes
|
||||
registerTimefilterWithGlobalState(globalState);
|
||||
registerTimefilterWithGlobalState(globalState, $rootScope);
|
||||
|
||||
timefilter.enableTimeRangeSelector();
|
||||
timefilter.enableAutoRefreshSelector();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue