This is an automated email from the ASF dual-hosted git repository. dhavalshah9131 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ranger.git
The following commit(s) were added to refs/heads/master by this push: new 32e0f05c7 RANGER-4360 : Error page 'Go back' button not redirecting to the right page 32e0f05c7 is described below commit 32e0f05c7d62de87509ef30c3692ed9d2b725e28 Author: Dhaval Rajpara <dhavalrajpara1...@gmail.com> AuthorDate: Thu Nov 9 15:26:25 2023 +0530 RANGER-4360 : Error page 'Go back' button not redirecting to the right page --- .../main/webapp/react-webapp/src/utils/XAUtils.js | 16 +++++++++++++++- .../main/webapp/react-webapp/src/utils/fetchAPI.js | 6 +++--- .../react-webapp/src/views/AuditEvent/AccessLogs.jsx | 8 ++++---- .../react-webapp/src/views/AuditEvent/AdminLogs.jsx | 6 +++--- .../src/views/AuditEvent/AuditLayout.jsx | 2 +- .../src/views/AuditEvent/LoginSessionsLogs.jsx | 4 ++-- .../src/views/AuditEvent/PluginStatusLogs.jsx | 4 ++-- .../react-webapp/src/views/AuditEvent/PluginsLog.jsx | 4 ++-- .../react-webapp/src/views/AuditEvent/UserSync.jsx | 6 +++--- .../react-webapp/src/views/Encryption/KeyManager.jsx | 4 ++-- .../main/webapp/react-webapp/src/views/ErrorPage.jsx | 11 ++++++++--- .../src/main/webapp/react-webapp/src/views/Home.jsx | 2 +- .../main/webapp/react-webapp/src/views/Layout.jsx | 11 ++++++++--- .../src/views/PermissionsModule/Permissions.jsx | 4 ++-- .../src/views/PolicyListing/AddUpdatePolicyForm.jsx | 5 ++--- .../src/views/PolicyListing/PolicyListing.jsx | 4 ++-- .../src/views/PolicyListing/PolicyListingTabView.jsx | 20 ++++++++------------ .../src/views/Reports/UserAccessLayout.jsx | 12 +++--------- .../src/views/SecurityZone/SecurityZoneForm.jsx | 2 +- .../src/views/SecurityZone/ZoneListing.jsx | 14 +++++++++----- .../src/views/ServiceManager/ServiceDefinitions.jsx | 3 +-- .../src/views/ServiceManager/ServiceForm.jsx | 2 +- .../react-webapp/src/views/SideBar/SideBar.jsx | 3 ++- .../UserGroupRoleListing/UserGroupRoleListing.jsx | 2 +- .../groups_details/GroupListing.jsx | 4 ++-- .../role_details/RoleListing.jsx | 4 ++-- .../users_details/UserListing.jsx | 4 ++-- 27 files changed, 92 insertions(+), 75 deletions(-) diff --git a/security-admin/src/main/webapp/react-webapp/src/utils/XAUtils.js b/security-admin/src/main/webapp/react-webapp/src/utils/XAUtils.js index 93629855c..ebf1b3fc2 100644 --- a/security-admin/src/main/webapp/react-webapp/src/utils/XAUtils.js +++ b/security-admin/src/main/webapp/react-webapp/src/utils/XAUtils.js @@ -1428,7 +1428,7 @@ export const requestDataTitle = (serviceType) => { export const policyConditionUpdatedJSON = (policyCond) => { let newPolicyConditionJSON = [...policyCond]; - newPolicyConditionJSON.filter(function (key, val) { + newPolicyConditionJSON.filter(function (key) { if (!key?.uiHint || key?.uiHint == "") { if ( key.evaluatorOptions && @@ -1458,3 +1458,17 @@ export const getResourcesDefVal = (serviceDef, policyType) => { } return resources; }; + +// Get defult landing page + +export const getLandingPageURl = () => { + if (hasAccessToTab("Resource Based Policies")) { + return "/policymanager/resource"; + } else { + if (hasAccessToTab("Tag Based Policies")) { + return "/policymanager/tag"; + } else { + return "/userprofile"; + } + } +}; diff --git a/security-admin/src/main/webapp/react-webapp/src/utils/fetchAPI.js b/security-admin/src/main/webapp/react-webapp/src/utils/fetchAPI.js index fbdd91737..9234057f4 100644 --- a/security-admin/src/main/webapp/react-webapp/src/utils/fetchAPI.js +++ b/security-admin/src/main/webapp/react-webapp/src/utils/fetchAPI.js @@ -97,13 +97,13 @@ async function fetchApi(axiosConfig = {}, otherConf = {}) { (error?.response?.data?.messageList?.[0]?.name == "DATA_NOT_FOUND" || error?.response?.data?.messageList?.[0]?.name == "INVALID_INPUT_DATA") ) { - navigateTo.navigate("/dataNotFound", { replace: true }); + navigateTo.navigate("/dataNotFound"); } if (error?.response?.status === 404) { - navigateTo.navigate("/pageNotFound", { replace: true }); + navigateTo.navigate("/pageNotFound"); } if (error?.response?.status === 403) { - navigateTo.navigate("/forbidden", { replace: true }); + navigateTo.navigate("/forbidden"); } throw error; } diff --git a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AccessLogs.jsx b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AccessLogs.jsx index c189c0a1b..7ec8503e7 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AccessLogs.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AccessLogs.jsx @@ -124,7 +124,7 @@ function Access() { if (localStorage?.excludeServiceUser) { searchParam["excludeServiceUser"] = checked; } - setSearchParams(searchParam); + setSearchParams(searchParam, { replace: true }); setSearchFilterParams(searchFilterParam); setDefaultSearchFilterParams(defaultSearchFilterParam); localStorage.setItem("bigData", JSON.stringify(searchParam)); @@ -146,7 +146,7 @@ function Access() { } searchParam["excludeServiceUser"] = localStorage?.excludeServiceUser; } - setSearchParams(searchParam); + setSearchParams(searchParam, { replace: true }); if ( JSON.stringify(searchFilterParams) !== JSON.stringify(searchFilterParam) ) { @@ -229,7 +229,7 @@ function Access() { "excludeServiceUser", JSON.stringify(chkVal?.target?.checked) ); - setSearchParams(currentParams); + setSearchParams(currentParams, { replace: true }); setAccessLogs([]); setChecked(chkVal?.target?.checked); setLoader(true); @@ -733,7 +733,7 @@ function Access() { searchParam["excludeServiceUser"] = checked; setSearchFilterParams(searchFilterParam); - setSearchParams(searchParam); + setSearchParams(searchParam, { replace: true }); localStorage.setItem("bigData", JSON.stringify(searchParam)); if (typeof resetPage?.page === "function") { diff --git a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AdminLogs.jsx b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AdminLogs.jsx index 6575dae24..348839596 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AdminLogs.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AdminLogs.jsx @@ -63,7 +63,7 @@ function Admin() { const updateSessionId = (id) => { navigate(`/reports/audit/admin?sessionId=${id}`); - setSearchParams({ sessionId: id }); + setSearchParams({ sessionId: id }, { replace: true }); setContentLoader(true); }; @@ -79,7 +79,7 @@ function Admin() { fetchSearchFilterParams("admin", searchParams, searchFilterOptions); // Updating the states for search params, search filter, default search filter and localStorage - setSearchParams(searchParam); + setSearchParams(searchParam, { replace: true }); if ( JSON.stringify(searchFilterParams) !== JSON.stringify(searchFilterParam) ) { @@ -356,7 +356,7 @@ function Admin() { ); setSearchFilterParams(searchFilterParam); - setSearchParams(searchParam); + setSearchParams(searchParam, { replace: true }); localStorage.setItem("admin", JSON.stringify(searchParam)); if (typeof resetPage?.page === "function") { diff --git a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AuditLayout.jsx b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AuditLayout.jsx index 0537496f3..097279428 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AuditLayout.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AuditLayout.jsx @@ -35,7 +35,7 @@ class AuditLayout extends Component { tabChange = (tabName) => { this.setState({ activeKey: tabName }); - this.props.navigate(`/reports/audit/${tabName}`, { replace: true }); + this.props.navigate(`/reports/audit/${tabName}`); }; componentDidUpdate(nextProps, prevState) { diff --git a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/LoginSessionsLogs.jsx b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/LoginSessionsLogs.jsx index 28d2bdb3e..37aa0e01e 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/LoginSessionsLogs.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/LoginSessionsLogs.jsx @@ -69,7 +69,7 @@ function Login_Sessions() { ); // Updating the states for search params, search filter, default search filter and localStorage - setSearchParams(searchParam); + setSearchParams(searchParam, { replace: true }); if ( JSON.stringify(searchFilterParams) !== JSON.stringify(searchFilterParam) ) { @@ -293,7 +293,7 @@ function Login_Sessions() { ); setSearchFilterParams(searchFilterParam); - setSearchParams(searchParam); + setSearchParams(searchParam, { replace: true }); localStorage.setItem("loginSession", JSON.stringify(searchParam)); if (typeof resetPage?.page === "function") { diff --git a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/PluginStatusLogs.jsx b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/PluginStatusLogs.jsx index cf4727514..07ac391d9 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/PluginStatusLogs.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/PluginStatusLogs.jsx @@ -71,7 +71,7 @@ function Plugin_Status() { ); // Updating the states for search params, search filter, default search filter and localStorage - setSearchParams(searchParam); + setSearchParams(searchParam, { replace: true }); if ( JSON.stringify(searchFilterParams) !== JSON.stringify(searchFilterParam) ) { @@ -470,7 +470,7 @@ function Plugin_Status() { ); setSearchFilterParams(searchFilterParam); - setSearchParams(searchParam); + setSearchParams(searchParam, { replace: true }); localStorage.setItem("pluginStatus", JSON.stringify(searchParam)); if (typeof resetPage?.page === "function") { diff --git a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/PluginsLog.jsx b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/PluginsLog.jsx index 55caa90bd..53e50791b 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/PluginsLog.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/PluginsLog.jsx @@ -62,7 +62,7 @@ function Plugins() { fetchSearchFilterParams("agent", searchParams, searchFilterOptions); // Updating the states for search params, search filter, default search filter and localStorage - setSearchParams(searchParam); + setSearchParams(searchParam, { replace: true }); if ( JSON.stringify(searchFilterParams) !== JSON.stringify(searchFilterParam) ) { @@ -248,7 +248,7 @@ function Plugins() { ); setSearchFilterParams(searchFilterParam); - setSearchParams(searchParam); + setSearchParams(searchParam, { replace: true }); localStorage.setItem("agent", JSON.stringify(searchParam)); if (typeof resetPage?.page === "function") { diff --git a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/UserSync.jsx b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/UserSync.jsx index 0abe30017..f114c0c92 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/UserSync.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/UserSync.jsx @@ -72,7 +72,7 @@ function User_Sync() { } // Updating the states for search params, search filter, default search filter and localStorage - setSearchParams(searchParam); + setSearchParams(searchParam, { replace: true }); setSearchFilterParams(searchFilterParam); setDefaultSearchFilterParams(defaultSearchFilterParam); localStorage.setItem("userSync", JSON.stringify(searchParam)); @@ -84,7 +84,7 @@ function User_Sync() { fetchSearchFilterParams("userSync", searchParams, searchFilterOptions); // Updating the states for search params, search filter, default search filter and localStorage - setSearchParams(searchParam); + setSearchParams(searchParam, { replace: true }); if ( JSON.stringify(searchFilterParams) !== JSON.stringify(searchFilterParam) ) { @@ -305,7 +305,7 @@ function User_Sync() { ); setSearchFilterParams(searchFilterParam); - setSearchParams(searchParam); + setSearchParams(searchParam, { replace: true }); localStorage.setItem("userSync", JSON.stringify(searchParam)); if (typeof resetPage?.page === "function") { diff --git a/security-admin/src/main/webapp/react-webapp/src/views/Encryption/KeyManager.jsx b/security-admin/src/main/webapp/react-webapp/src/views/Encryption/KeyManager.jsx index 98ea88280..2b8c6d4fc 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/Encryption/KeyManager.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/Encryption/KeyManager.jsx @@ -201,7 +201,7 @@ const KeyManager = () => { } // Updating the states for search params, search filter and default search filter - setSearchParams({ ...currentParams, ...searchParam }); + setSearchParams({ ...currentParams, ...searchParam }, { replace: true }); if ( (!isEmpty(searchFilterParams) || !isEmpty(searchFilterParam)) && JSON.stringify(searchFilterParams) !== JSON.stringify(searchFilterParam) @@ -558,7 +558,7 @@ const KeyManager = () => { ); setSearchFilterParams(searchFilterParam); - setSearchParams(searchParam); + setSearchParams(searchParam, { replace: true }); }; return ( diff --git a/security-admin/src/main/webapp/react-webapp/src/views/ErrorPage.jsx b/security-admin/src/main/webapp/react-webapp/src/views/ErrorPage.jsx index 9e99e5077..a19374485 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/ErrorPage.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/ErrorPage.jsx @@ -18,14 +18,17 @@ */ import React, { useState, useEffect } from "react"; -import { useNavigate } from "react-router-dom"; +import { useNavigate, useLocation } from "react-router-dom"; import errorIcon from "Images/error-404-icon.png"; import { Button } from "react-bootstrap"; +import { getLandingPageURl } from "../utils/XAUtils"; export const ErrorPage = (props) => { const [errorCode, setErrorCode] = useState(null); const [errorInfo, setErrorInfo] = useState(null); let navigate = useNavigate(); + let currentURLObj = useLocation(); + let customURL = ["/dataNotFound", "/pageNotFound", "/forbidden"]; useEffect(() => { if (props.errorCode == "401") { @@ -86,14 +89,16 @@ export const ErrorPage = (props) => { <Button size="sm" onClick={() => - props.errorCode == "checkSSOTrue" ? navigate(-1) : navigate(-2) + customURL.indexOf(currentURLObj.pathname) >= 0 + ? navigate(-2) + : navigate(-1) } className="mr-1" > <i className="fa-fw fa fa-long-arrow-left"></i> Go back </Button> {props.errorCode !== "checkSSOTrue" && ( - <Button href="#/policymanager/resource" size="sm"> + <Button size="sm" onClick={() => navigate(getLandingPageURl())}> Home </Button> )} diff --git a/security-admin/src/main/webapp/react-webapp/src/views/Home.jsx b/security-admin/src/main/webapp/react-webapp/src/views/Home.jsx index 3dee1d086..67f71ec79 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/Home.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/Home.jsx @@ -35,7 +35,7 @@ class Home extends Component { } tabChange = (tabName) => { - this.props.navigate(`/policymanager/${tabName}`, { replace: true }); + this.props.navigate(`/policymanager/${tabName}`); }; componentDidUpdate(nextProps, prevState) { diff --git a/security-admin/src/main/webapp/react-webapp/src/views/Layout.jsx b/security-admin/src/main/webapp/react-webapp/src/views/Layout.jsx index 49edc2861..dc3c21ff8 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/Layout.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/Layout.jsx @@ -27,14 +27,19 @@ import { matchRoutes } from "react-router-dom"; import ErrorPage from "./ErrorPage"; -import { hasAccessToPath, checkKnoxSSO, navigateTo } from "Utils/XAUtils"; +import { + hasAccessToPath, + checkKnoxSSO, + navigateTo, + getLandingPageURl +} from "Utils/XAUtils"; import { useIdleTimer } from "react-idle-timer"; import { getUserProfile } from "Utils/appState"; import SideBar from "./SideBar/SideBar"; import { Loader } from "../components/CommonComponents"; import { Suspense } from "react"; import { PathAssociateWithModule } from "../utils/XAEnums"; -import { flatMap, includes, values } from "lodash"; +import { flatMap, values } from "lodash"; const Layout = () => { let location = useLocation(); @@ -133,7 +138,7 @@ const Layout = () => { window.location.pathname != "/dataNotFound" && window.location.pathname != "/pageNotFound" && window.location.pathname != "/forbidden" && ( - <Navigate to="/policymanager/resource" replace={true} /> + <Navigate to={getLandingPageURl()} replace={true} /> )} <div id="content" className="content-body"> <div id="ranger-content"> diff --git a/security-admin/src/main/webapp/react-webapp/src/views/PermissionsModule/Permissions.jsx b/security-admin/src/main/webapp/react-webapp/src/views/PermissionsModule/Permissions.jsx index 730d40103..73c22bc0d 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/PermissionsModule/Permissions.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/PermissionsModule/Permissions.jsx @@ -76,7 +76,7 @@ function Permissions() { } // Updating the states for search params, search filter and default search filter - setSearchParams({ ...currentParams, ...searchParam }); + setSearchParams({ ...currentParams, ...searchParam }, { replace: true }); if ( JSON.stringify(searchFilterParams) !== JSON.stringify(searchFilterParam) ) { @@ -217,7 +217,7 @@ function Permissions() { ); setSearchFilterParams(searchFilterParam); - setSearchParams(searchParam); + setSearchParams(searchParam, { replace: true }); }; return ( diff --git a/security-admin/src/main/webapp/react-webapp/src/views/PolicyListing/AddUpdatePolicyForm.jsx b/security-admin/src/main/webapp/react-webapp/src/views/PolicyListing/AddUpdatePolicyForm.jsx index 90595f1b8..dafbc7371 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/PolicyListing/AddUpdatePolicyForm.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/PolicyListing/AddUpdatePolicyForm.jsx @@ -138,7 +138,7 @@ export default function AddUpdatePolicyForm() { useEffect(() => { fetchInitialData(); - }, []); + }, [serviceId, policyType, policyId]); const showDeleteModal = () => { setShowDelete(true); @@ -239,8 +239,7 @@ export default function AddUpdatePolicyForm() { Object.keys(serviceCompData.rowFilterDef).length != 0 ) serviceDefPolicyType++; - if (+policyType > serviceDefPolicyType) - navigate("/pageNotFound", { replace: true }); + if (+policyType > serviceDefPolicyType) navigate("/pageNotFound"); } let policyData = null; if (policyId) { diff --git a/security-admin/src/main/webapp/react-webapp/src/views/PolicyListing/PolicyListing.jsx b/security-admin/src/main/webapp/react-webapp/src/views/PolicyListing/PolicyListing.jsx index c1752c252..253395806 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/PolicyListing/PolicyListing.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/PolicyListing/PolicyListing.jsx @@ -145,7 +145,7 @@ function PolicyListing(props) { } // Updating the states for search params, search filter and default search filter - setSearchParams({ ...currentParams, ...searchParam }); + setSearchParams({ ...currentParams, ...searchParam }, { replace: true }); if ( JSON.stringify(searchFilterParams) !== JSON.stringify(searchFilterParam) ) { @@ -715,7 +715,7 @@ function PolicyListing(props) { ); setSearchFilterParams(searchFilterParam); - setSearchParams(searchParam); + setSearchParams(searchParam, { replace: true }); if (typeof resetPage?.page === "function") { resetPage.page(0); diff --git a/security-admin/src/main/webapp/react-webapp/src/views/PolicyListing/PolicyListingTabView.jsx b/security-admin/src/main/webapp/react-webapp/src/views/PolicyListing/PolicyListingTabView.jsx index 44d9f1da9..7c6b1c19b 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/PolicyListing/PolicyListingTabView.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/PolicyListing/PolicyListingTabView.jsx @@ -72,7 +72,11 @@ export const PolicyListingTabView = () => { useEffect(() => { fetchServiceDetails(); - }, [params?.serviceId, JSON.parse(localStorageZoneDetails)?.value]); + }, [ + params?.serviceId, + params?.policyType, + JSON.parse(localStorageZoneDetails)?.value + ]); const fetchServiceDetails = async () => { document @@ -166,10 +170,7 @@ export const PolicyListingTabView = () => { } }); navigate( - `/service/${selectedServiceData?.id}/policies/${RangerPolicyType.RANGER_ACCESS_POLICY_TYPE.value}`, - { - replace: true - } + `/service/${selectedServiceData?.id}/policies/${RangerPolicyType.RANGER_ACCESS_POLICY_TYPE.value}` ); localStorage.removeItem("zoneDetails"); } @@ -198,10 +199,7 @@ export const PolicyListingTabView = () => { localStorage.removeItem("zoneDetails"); } navigate( - `/service/${params.serviceId}/policies/${RangerPolicyType.RANGER_ACCESS_POLICY_TYPE.value}`, - { - replace: true - } + `/service/${params.serviceId}/policies/${RangerPolicyType.RANGER_ACCESS_POLICY_TYPE.value}` ); }; @@ -223,9 +221,7 @@ export const PolicyListingTabView = () => { }; const tabChange = (tabName) => { - navigate(`/service/${params?.serviceId}/policies/${tabName}`, { - replace: true - }); + navigate(`/service/${params?.serviceId}/policies/${tabName}`); }; return ( diff --git a/security-admin/src/main/webapp/react-webapp/src/views/Reports/UserAccessLayout.jsx b/security-admin/src/main/webapp/react-webapp/src/views/Reports/UserAccessLayout.jsx index e3d09c51e..0d25d6aeb 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/Reports/UserAccessLayout.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/Reports/UserAccessLayout.jsx @@ -248,9 +248,7 @@ function UserAccessLayout() { } } - navigate(`/reports/userAccess?${urlSearchParams}`, { - replace: true - }); + navigate(`/reports/userAccess?${urlSearchParams}`); setFilterServiceDefs(serviceDefsList); setSearchParamsObj(searchFields); @@ -412,17 +410,13 @@ function UserAccessLayout() { if (!has(Object.fromEntries(searchParams), "policyType")) { searchParams.set("policyType", "0"); searchFields.policyType = "0"; - navigate(`${location.pathname}?${searchParams}`, { - replace: true - }); + navigate(`${location.pathname}?${searchParams}`); setSearchParamsObj(searchFields); } if (has(searchFields, "serviceType")) { let filterServiceType = searchFields.serviceType.split(","); searchParams.set("serviceType", uniq(filterServiceType).join(",")); - navigate(`${location.pathname}?${searchParams}`, { - replace: true - }); + navigate(`${location.pathname}?${searchParams}`); } } }; diff --git a/security-admin/src/main/webapp/react-webapp/src/views/SecurityZone/SecurityZoneForm.jsx b/security-admin/src/main/webapp/react-webapp/src/views/SecurityZone/SecurityZoneForm.jsx index d97dcf041..7eb67544d 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/SecurityZone/SecurityZoneForm.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/SecurityZone/SecurityZoneForm.jsx @@ -90,7 +90,7 @@ const SecurityZoneForm = () => { useEffect(() => { fetchInitalData(); - }, []); + }, [params.zoneId]); const validate = (values) => { const errors = {}; diff --git a/security-admin/src/main/webapp/react-webapp/src/views/SecurityZone/ZoneListing.jsx b/security-admin/src/main/webapp/react-webapp/src/views/SecurityZone/ZoneListing.jsx index e672611dd..e9c7ec8ae 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/SecurityZone/ZoneListing.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/SecurityZone/ZoneListing.jsx @@ -50,6 +50,12 @@ class ZoneListing extends Component { this.fetchData(); } + componentDidUpdate(prevState) { + if (this.props.params.zoneId != prevState.params.zoneId) { + this.fetchData(); + } + } + fetchData = async () => { let servicesResp; let zoneList = [], @@ -103,7 +109,7 @@ class ZoneListing extends Component { let selectedZone = this.state.zones.find((obj) => zoneid === obj.id); if (selectedZone) { this.setState({ selectedZone: selectedZone }); - this.props.navigate(`/zones/zone/${zoneid}`, { replace: true }); + this.props.navigate(`/zones/zone/${zoneid}`); } }; @@ -144,11 +150,9 @@ class ZoneListing extends Component { }); if (getSelectedZone && getSelectedZone !== undefined) { - this.props.navigate(`/zones/zone/${getSelectedZone.id}`, { - replace: true - }); + this.props.navigate(`/zones/zone/${getSelectedZone.id}`); } else { - this.props.navigate(`/zones/zone/list`, { replace: true }); + this.props.navigate(`/zones/zone/list`); } toast.success("Successfully deleted the zone"); } catch (error) { diff --git a/security-admin/src/main/webapp/react-webapp/src/views/ServiceManager/ServiceDefinitions.jsx b/security-admin/src/main/webapp/react-webapp/src/views/ServiceManager/ServiceDefinitions.jsx index 0b2f46bec..8c222d080 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/ServiceManager/ServiceDefinitions.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/ServiceManager/ServiceDefinitions.jsx @@ -182,8 +182,7 @@ class ServiceDefinitions extends Component { zonesResp && this.props.navigate( - `${this.props.location.pathname}?securityZone=${e.label}`, - { replace: true } + `${this.props.location.pathname}?securityZone=${e.label}` ); let zoneServiceNames = map(zonesResp.data, "name"); diff --git a/security-admin/src/main/webapp/react-webapp/src/views/ServiceManager/ServiceForm.jsx b/security-admin/src/main/webapp/react-webapp/src/views/ServiceManager/ServiceForm.jsx index 2df0c4d63..47763fb9d 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/ServiceManager/ServiceForm.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/ServiceManager/ServiceForm.jsx @@ -103,7 +103,7 @@ class ServiceForm extends Component { }); if (servicedefs == undefined) { - return navigateTo.navigate("/pageNotFound", { replace: true }); + return navigateTo.navigate("/pageNotFound"); } this.fetchServiceDef(); } diff --git a/security-admin/src/main/webapp/react-webapp/src/views/SideBar/SideBar.jsx b/security-admin/src/main/webapp/react-webapp/src/views/SideBar/SideBar.jsx index e0ad55d59..4d87b63f3 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/SideBar/SideBar.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/SideBar/SideBar.jsx @@ -51,6 +51,7 @@ import ResourceTagContent from "./ResourceTagContent"; import { PathAssociateWithModule } from "../../utils/XAEnums"; import { getServiceDef } from "../../utils/appState"; import { SideBarBody } from "./SideBarBody"; +import { getLandingPageURl } from "../../utils/XAUtils"; function reducer(state, action) { switch (action.type) { @@ -242,7 +243,7 @@ export const SideBar = () => { <div className="sidebar-header"> <NavLink id="rangerIcon" - to="/policymanager/resource" + to={getLandingPageURl()} onClick={() => { setActive(null); setDrawer(false); diff --git a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/UserGroupRoleListing.jsx b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/UserGroupRoleListing.jsx index bd829636e..2301f10d5 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/UserGroupRoleListing.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/UserGroupRoleListing.jsx @@ -32,7 +32,7 @@ class UserGroupRoleListing extends Component { } tabChange = (tabName) => { this.setState({ activeKey: tabName }); - this.props.navigate(`/users/${tabName}`, { replace: true }); + this.props.navigate(`/users/${tabName}`); }; componentDidUpdate(nextProps, prevState) { let activeTabVal = this.activeTab(); diff --git a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/groups_details/GroupListing.jsx b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/groups_details/GroupListing.jsx index 332a3940d..97d0194a1 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/groups_details/GroupListing.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/groups_details/GroupListing.jsx @@ -129,7 +129,7 @@ function Groups() { } // Updating the states for search params, search filter and default search filter - setSearchParams({ ...currentParams, ...searchParam }); + setSearchParams({ ...currentParams, ...searchParam }, { replace: true }); if ( JSON.stringify(searchFilterParams) !== JSON.stringify(searchFilterParam) ) { @@ -540,7 +540,7 @@ function Groups() { ); setSearchFilterParams(searchFilterParam); - setSearchParams(searchParam); + setSearchParams(searchParam, { replace: true }); if (typeof resetPage?.page === "function") { resetPage.page(0); diff --git a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/role_details/RoleListing.jsx b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/role_details/RoleListing.jsx index 8caecf058..f01398aa4 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/role_details/RoleListing.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/role_details/RoleListing.jsx @@ -110,7 +110,7 @@ function Roles() { } // Updating the states for search params, search filter and default search filter - setSearchParams({ ...currentParams, ...searchParam }); + setSearchParams({ ...currentParams, ...searchParam }, { replace: true }); if ( JSON.stringify(searchFilterParams) !== JSON.stringify(searchFilterParam) ) { @@ -335,7 +335,7 @@ function Roles() { searchFilterOptions ); setSearchFilterParams(searchFilterParam); - setSearchParams(searchParam); + setSearchParams(searchParam, { replace: true }); if (typeof resetPage?.page === "function") { resetPage.page(0); diff --git a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserListing.jsx b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserListing.jsx index dee4b196d..82506ff8a 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserListing.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserListing.jsx @@ -130,7 +130,7 @@ function Users() { } // Updating the states for search params, search filter and default search filter - setSearchParams({ ...currentParams, ...searchParam }); + setSearchParams({ ...currentParams, ...searchParam }, { replace: true }); if ( JSON.stringify(searchFilterParams) !== JSON.stringify(searchFilterParam) ) { @@ -605,7 +605,7 @@ function Users() { ); setSearchFilterParams(searchFilterParam); - setSearchParams(searchParam); + setSearchParams(searchParam, { replace: true }); if (typeof resetPage?.page === "function") { resetPage.page(0);