[SECURITY_SOLUTION] Fix URL params being carried across to URL routes for which they do not apply (#80726)

* Fix URL params issue on Admin section
* Fix route location state being dropped during updates to other route properties
This commit is contained in:
Paul Tavares 2020-10-22 07:27:36 -04:00 committed by GitHub
parent 6472caae1d
commit a91fbae424
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 3 deletions

View file

@ -278,6 +278,7 @@ export const replaceStateInLocation = <T>({
replaceStateKeyInQueryString(urlStateKey, urlStateToReplace)(getQueryStringFromLocation(search))
);
if (history) {
newLocation.state = history.location.state;
history.replace(newLocation);
}
return newLocation.search;

View file

@ -11,6 +11,7 @@ import deepEqual from 'fast-deep-equal';
import { SpyRouteProps } from './types';
import { useRouteSpy } from './use_route_spy';
import { SecurityPageName } from '../../../../common/constants';
export const SpyRouteComponent = memo<
SpyRouteProps & { location: H.Location; pageName: string | undefined }
@ -50,6 +51,7 @@ export const SpyRouteComponent = memo<
pathName: pathname,
state,
tabName,
...(pageName === SecurityPageName.administration ? { search: search ?? '' } : {}),
},
});
setIsInitializing(false);

View file

@ -45,9 +45,7 @@ export const TrustedAppsPage = memo(() => {
return <BackToExternalAppButton {...routeState} />;
}
return null;
// FIXME: Route state is being deleted by some parent component
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}, [routeState]);
const addButton = (
<EuiButton