mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Keep timeframe when editing a map from a dashboard (#135374)
* Keep timeframe when editing a map from a dashboard * [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
a34db6986b
commit
a48c7d9f0a
3 changed files with 20 additions and 2 deletions
|
@ -262,6 +262,7 @@ export class MapApp extends React.Component<Props, State> {
|
|||
filters: [..._.get(globalState, 'filters', []), ...appFilters, ...savedObjectFilters],
|
||||
query,
|
||||
time: getInitialTimeFilters({
|
||||
hasSaveAndReturnConfig: this.props.savedMap.hasSaveAndReturnConfig(),
|
||||
serializedMapState,
|
||||
globalState,
|
||||
}),
|
||||
|
|
|
@ -10,13 +10,15 @@ import { getUiSettings } from '../../../kibana_services';
|
|||
import { SerializedMapState } from './types';
|
||||
|
||||
export function getInitialTimeFilters({
|
||||
hasSaveAndReturnConfig,
|
||||
serializedMapState,
|
||||
globalState,
|
||||
}: {
|
||||
hasSaveAndReturnConfig: boolean;
|
||||
serializedMapState?: SerializedMapState;
|
||||
globalState: GlobalQueryStateFromUrl;
|
||||
}) {
|
||||
if (serializedMapState?.timeFilters) {
|
||||
if (!hasSaveAndReturnConfig && serializedMapState?.timeFilters) {
|
||||
return serializedMapState.timeFilters;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,14 @@
|
|||
import expect from '@kbn/expect';
|
||||
|
||||
export default function ({ getPageObjects, getService }) {
|
||||
const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'maps', 'visualize']);
|
||||
const PageObjects = getPageObjects([
|
||||
'common',
|
||||
'dashboard',
|
||||
'header',
|
||||
'maps',
|
||||
'timePicker',
|
||||
'visualize',
|
||||
]);
|
||||
const dashboardAddPanel = getService('dashboardAddPanel');
|
||||
const dashboardPanelActions = getService('dashboardPanelActions');
|
||||
const testSubjects = getService('testSubjects');
|
||||
|
@ -75,6 +82,14 @@ export default function ({ getPageObjects, getService }) {
|
|||
});
|
||||
|
||||
describe('save and return', () => {
|
||||
it('should use dashboard instead of time stored in map state', async () => {
|
||||
// join example map's time is "last 17 minutes"
|
||||
// ensure map has dashboard time
|
||||
const timeConfig = await PageObjects.timePicker.getTimeConfig();
|
||||
expect(timeConfig.start).to.equal('Sep 20, 2015 @ 00:00:00.000');
|
||||
expect(timeConfig.end).to.equal('Sep 20, 2015 @ 01:00:00.000');
|
||||
});
|
||||
|
||||
it('should return to dashboard', async () => {
|
||||
await PageObjects.maps.clickSaveAndReturnButton();
|
||||
await PageObjects.dashboard.waitForRenderComplete();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue