Skip to content

Commit

Permalink
[Security Solution][Endpoint] Clean up resolver query params on compo…
Browse files Browse the repository at this point in the history
…nent dismount (#72902) (#73157)
  • Loading branch information
kqualters-elastic authored Jul 24, 2020
1 parent 4bc149e commit 4ff42a3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions x-pack/plugins/security_solution/public/resolver/view/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import React, { useContext } from 'react';
import { useSelector } from 'react-redux';
import { useEffectOnce } from 'react-use';
import { EuiLoadingSpinner } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import * as selectors from '../store/selectors';
Expand All @@ -19,6 +20,7 @@ import { ProcessEventDot } from './process_event_dot';
import { useCamera } from './use_camera';
import { SymbolDefinitions, useResolverTheme } from './assets';
import { useStateSyncingActions } from './use_state_syncing_actions';
import { useResolverQueryParams } from './use_resolver_query_params';
import { StyledMapContainer, StyledPanel, GraphContainer } from './styles';
import { entityId } from '../../../common/endpoint/models/event';
import { SideEffectContext } from './side_effect_context';
Expand Down Expand Up @@ -66,6 +68,10 @@ export const ResolverMap = React.memo(function ({
const hasError = useSelector(selectors.hasError);
const activeDescendantId = useSelector(selectors.ariaActiveDescendant);
const { colorMap } = useResolverTheme();
const { cleanUpQueryParams } = useResolverQueryParams();
useEffectOnce(() => {
return () => cleanUpQueryParams();
});

return (
<StyledMapContainer className={className} backgroundColor={colorMap.resolverBackground}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,19 @@ export function useResolverQueryParams() {
};
}, [urlSearch, uniqueCrumbIdKey, uniqueCrumbEventKey]);

const cleanUpQueryParams = () => {
const crumbsToPass = {
...querystring.parse(urlSearch.slice(1)),
};
delete crumbsToPass[uniqueCrumbIdKey];
delete crumbsToPass[uniqueCrumbEventKey];
const relativeURL = { search: querystring.stringify(crumbsToPass) };
history.replace(relativeURL);
};

return {
pushToQueryParams,
queryParams,
cleanUpQueryParams,
};
}

0 comments on commit 4ff42a3

Please sign in to comment.