RANGER-4532: Optimize policy listing loader after session timeout and Audit Admin session ID modal loader

Signed-off-by: Dineshkumar Yadav <dineshkumar.yadav@outlook.com>
diff --git a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AdminModal.jsx b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AdminModal.jsx
index be77362..37a8cd2 100644
--- a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AdminModal.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AdminModal.jsx
@@ -39,6 +39,7 @@
   const handleShow = async () => {
     let authlogs = [];
     try {
+      setLoader(true);
       const authResp = await fetchApi({
         url: "xusers/authSessions",
         params: {
@@ -47,8 +48,9 @@
       });
       authlogs = authResp.data.vXAuthSessions;
       setAuthSession(authlogs);
-      authlogs ? setLoader(false) : setLoader(true);
+      setLoader(false);
     } catch (error) {
+      setLoader(false);
       console.error(`Error occurred while fetching Admin logs! ${error}`);
     }
   };
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 2533958..e7e38d3 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
@@ -72,7 +72,6 @@
 } from "../../components/CommonComponents";
 
 function PolicyListing(props) {
-  //const { serviceDef, serviceData } = props;
   const { serviceDef, serviceData, serviceZone } = props;
   const { state } = useLocation();
   const [policyListingData, setPolicyData] = useState([]);
@@ -229,7 +228,7 @@
         setLoader(false);
       }
     },
-    [updateTable, searchFilterParams, serviceData]
+    [updateTable, searchFilterParams]
   );
 
   const toggleConfirmModalForDelete = (policyID, policyName) => {
@@ -724,26 +723,25 @@
 
   return (
     <div className="wrap">
-      {(props.serviceData.type == "hdfs" || props.serviceData.type == "yarn") &&
-        show && (
-          <Alert variant="warning" onClose={() => setShow(false)} dismissible>
-            <i className="fa-fw fa fa-info-circle d-inline text-dark"></i>
-            <p className="pd-l-10 d-inline">
-              {`By default, fallback to ${
-                alertMessage[props.serviceData.type].label
-              } ACLs are enabled. If access cannot be
+      {(serviceData.type == "hdfs" || serviceData.type == "yarn") && show && (
+        <Alert variant="warning" onClose={() => setShow(false)} dismissible>
+          <i className="fa-fw fa fa-info-circle d-inline text-dark"></i>
+          <p className="pd-l-10 d-inline">
+            {`By default, fallback to ${
+              alertMessage[serviceData.type].label
+            } ACLs are enabled. If access cannot be
               determined by Ranger policies, authorization will fall back to
               ${
-                alertMessage[props.serviceData.type].label
+                alertMessage[serviceData.type].label
               } ACLs. If this behavior needs to be changed, modify ${
-                alertMessage[props.serviceData.type].label
-              }
+              alertMessage[serviceData.type].label
+            }
               plugin config - ${
-                alertMessage[props.serviceData.type].configs
+                alertMessage[serviceData.type].configs
               }-authorization.`}
-            </p>
-          </Alert>
-        )}
+          </p>
+        </Alert>
+      )}
       {pageLoader ? (
         <Loader />
       ) : (
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 7c6b1c1..b94dc14 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
@@ -31,7 +31,7 @@
 } from "Utils/XAUtils";
 import { Loader } from "Components/CommonComponents";
 import TopNavBar from "../SideBar/TopNavBar";
-import { map, sortBy } from "lodash";
+import { isEmpty, map, sortBy } from "lodash";
 import { RangerPolicyType } from "../../utils/XAEnums";
 import { getServiceDef } from "../../utils/appState";
 
@@ -135,12 +135,12 @@
       serviceData: getServiceData?.data,
       serviceDefData: getServiceDefData
     });
-
-    dispatch({
-      type: "SET_LOADER",
-      loader: false
-    });
-
+    if (!isEmpty(getServiceData) && !isEmpty(getServiceDefData)) {
+      dispatch({
+        type: "SET_LOADER",
+        loader: false
+      });
+    }
     document
       .getElementById("resourceSelectedZone")
       ?.classList?.remove("disabledEvents");
diff --git a/security-admin/src/main/webapp/react-webapp/src/views/SideBar/TopNavBar.jsx b/security-admin/src/main/webapp/react-webapp/src/views/SideBar/TopNavBar.jsx
index 860b1ab..a48a15a 100644
--- a/security-admin/src/main/webapp/react-webapp/src/views/SideBar/TopNavBar.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/views/SideBar/TopNavBar.jsx
@@ -254,7 +254,7 @@
             {isAdminRole && (
               <Dropdown.ItemText>
                 <Link
-                  to={`/service/${serviceDefData.id}/edit/${serviceData?.id}`}
+                  to={`/service/${serviceDefData?.id}/edit/${serviceData?.id}`}
                   onClick={(e) => policyLoader && e.preventDefault()}
                   state={allServicesData[0]?.id}
                   disabled={policyLoader ? true : false}