Skip to content

Commit

Permalink
Revert "Review feedback. Clean up state"
Browse files Browse the repository at this point in the history
This reverts commit 729ce10.
  • Loading branch information
Aaron Caldwell committed Jun 18, 2020
1 parent 0e18579 commit 78880a8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
8 changes: 1 addition & 7 deletions x-pack/plugins/maps/public/routing/routes/maps_app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -32,8 +28,6 @@ function mapStateToProps(state = {}) {
isFullScreen: getIsFullScreen(state),
nextIndexPatternIds: getQueryableUniqueIndexPatternIds(state),
flyoutDisplay: getFlyoutDisplay(state),
refreshConfig: getRefreshConfig(state),
filters: getFilters(state),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class MapsAppView extends React.Component {
this.state = {
indexPatterns: [],
prevIndexPatternIds: [],
filters: [],
initialized: false,
isVisible: true,
savedQuery: null,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand All @@ -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
);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 ? (
<MapsTopNavMenu
Expand Down Expand Up @@ -449,7 +456,7 @@ export class MapsAppView extends React.Component {
}

render() {
const { initialized } = this.state;
const { filters, initialized } = this.state;

return initialized ? (
<div id="maps-plugin" className={this.props.isFullScreen ? 'mapFullScreen' : ''}>
Expand All @@ -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]);
}}
/>
</div>
Expand Down

0 comments on commit 78880a8

Please sign in to comment.