diff --git a/x-pack/plugins/maps/public/routing/routes/maps_app/index.js b/x-pack/plugins/maps/public/routing/routes/maps_app/index.js index 6b47ac6e0352af..2f3409057a24cd 100644 --- a/x-pack/plugins/maps/public/routing/routes/maps_app/index.js +++ b/x-pack/plugins/maps/public/routing/routes/maps_app/index.js @@ -7,11 +7,7 @@ import { connect } from 'react-redux'; import { MapsAppView } from './maps_app_view'; import { getFlyoutDisplay, getIsFullScreen } from '../../../selectors/ui_selectors'; -import { - getFilters, - getQueryableUniqueIndexPatternIds, - getRefreshConfig, -} from '../../../selectors/map_selectors'; +import { getQueryableUniqueIndexPatternIds } from '../../../selectors/map_selectors'; import { replaceLayerList, setGotoWithCenter, @@ -32,8 +28,6 @@ function mapStateToProps(state = {}) { isFullScreen: getIsFullScreen(state), nextIndexPatternIds: getQueryableUniqueIndexPatternIds(state), flyoutDisplay: getFlyoutDisplay(state), - refreshConfig: getRefreshConfig(state), - filters: getFilters(state), }; } diff --git a/x-pack/plugins/maps/public/routing/routes/maps_app/maps_app_view.js b/x-pack/plugins/maps/public/routing/routes/maps_app/maps_app_view.js index 3e9776991d864c..5c14e49d3d2880 100644 --- a/x-pack/plugins/maps/public/routing/routes/maps_app/maps_app_view.js +++ b/x-pack/plugins/maps/public/routing/routes/maps_app/maps_app_view.js @@ -46,6 +46,7 @@ export class MapsAppView extends React.Component { this.state = { indexPatterns: [], prevIndexPatternIds: [], + filters: [], initialized: false, isVisible: true, savedQuery: null, @@ -205,8 +206,7 @@ export class MapsAppView extends React.Component { }; _syncAppAndGlobalState = () => { - const { query, time, initialized } = this.state; - const { refreshConfig } = this.props; + const { query, time, refreshConfig, initialized } = this.state; const { filterManager } = getData().query; // appState @@ -235,6 +235,12 @@ export class MapsAppView extends React.Component { const { filterManager } = getData().query; const { dispatchSetQuery } = this.props; const newState = {}; + let newFilters; + if (filters) { + filterManager.setFilters(filters); // Maps and merges filters + newFilters = filterManager.getFilters(); + newState.filters = newFilters; + } if (query) { newState.query = query; } @@ -245,7 +251,7 @@ export class MapsAppView extends React.Component { this._syncAppAndGlobalState(); dispatchSetQuery( refresh, - filters || this.props.filters, + newFilters || this.state.filters, query || this.state.query, time || this.state.time ); @@ -276,7 +282,7 @@ export class MapsAppView extends React.Component { globalState, }), }; - this.setState({ query: newState.query, time: newState.time }); + this.setState(newState); updateGlobalState( { time: newState.time, @@ -316,7 +322,7 @@ export class MapsAppView extends React.Component { }; _onRefreshChange = ({ isPaused, refreshInterval }) => { - const { refreshConfig } = this.props; + const { refreshConfig } = this.state; const newRefreshConfig = { isPaused, interval: isNaN(refreshInterval) ? refreshConfig.interval : refreshInterval, @@ -405,13 +411,14 @@ export class MapsAppView extends React.Component { const { query, time, + refreshConfig, savedQuery, initialLayerListConfig, isVisible, indexPatterns, currentPath, } = this.state; - const { savedMap, refreshConfig } = this.props; + const { savedMap } = this.props; return isVisible ? ( @@ -461,7 +468,7 @@ export class MapsAppView extends React.Component { newFilters.forEach((filter) => { filter.$state = { store: esFilters.FilterStateStore.APP_STATE }; }); - this._updateFiltersAndDispatch([...this.props.filters, ...newFilters]); + this._updateFiltersAndDispatch([...filters, ...newFilters]); }} />