Skip to content

Commit

Permalink
Fix new navigation url state
Browse files Browse the repository at this point in the history
  • Loading branch information
machadoum committed May 19, 2022
1 parent 541e1fa commit bd5978d
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const useUrlStateHooks = ({
const { pathname: browserPathName } = useLocation();
const prevProps = usePrevious({ pathName, pageName, urlState, search });
const isGroupedNavEnabled = useIsGroupedNavigationEnabled();
const linkInfo = getLinkInfo(pageName as SecurityPageName);

const { setInitialStateFromUrl, updateTimeline, updateTimelineIsLoading } =
useSetInitialStateFromUrl();
Expand All @@ -74,9 +75,10 @@ export const useUrlStateHooks = ({
(type: UrlStateType) => {
const urlStateUpdatesToStore: UrlStateToRedux[] = [];
const urlStateUpdatesToLocation: ReplaceStateInLocation[] = [];
const skipUrlState = isGroupedNavEnabled ? linkInfo?.skipUrlState : isAdministration(type);

// Delete all query strings from URL when the page is security/administration (Manage menu group)
if (isAdministration(type)) {
if (skipUrlState) {
ALL_URL_STATE_KEYS.forEach((urlKey: KeyUrlState) => {
urlStateUpdatesToLocation.push({
urlStateToReplace: '',
Expand Down Expand Up @@ -150,6 +152,8 @@ export const useUrlStateHooks = ({
setInitialStateFromUrl,
urlState,
isFirstPageLoad,
isGroupedNavEnabled,
linkInfo?.skipUrlState,
]
);

Expand All @@ -163,8 +167,9 @@ export const useUrlStateHooks = ({
if (browserPathName !== pathName) return;

const type: UrlStateType = getUrlType(pageName);
const skipUrlState = isGroupedNavEnabled ? linkInfo?.skipUrlState : isAdministration(type);

if (!deepEqual(urlState, prevProps.urlState) && !isFirstPageLoad && !isAdministration(type)) {
if (!deepEqual(urlState, prevProps.urlState) && !isFirstPageLoad && !skipUrlState) {
const urlStateUpdatesToLocation: ReplaceStateInLocation[] = ALL_URL_STATE_KEYS.map(
(urlKey: KeyUrlState) => ({
urlStateToReplace: getUrlStateKeyValue(urlState, urlKey),
Expand All @@ -190,15 +195,17 @@ export const useUrlStateHooks = ({
browserPathName,
handleInitialize,
search,
isGroupedNavEnabled,
linkInfo?.skipUrlState,
]);

useEffect(() => {
if (!isGroupedNavEnabled) {
document.title = `${getTitle(pageName, navTabs)} - Kibana`;
} else {
document.title = `${getLinkInfo(pageName as SecurityPageName)?.title ?? ''} - Kibana`;
document.title = `${linkInfo?.title ?? ''} - Kibana`;
}
}, [pageName, navTabs, isGroupedNavEnabled]);
}, [pageName, navTabs, isGroupedNavEnabled, linkInfo]);

useEffect(() => {
queryTimelineByIdOnUrlChange({
Expand Down

0 comments on commit bd5978d

Please sign in to comment.