diff --git a/security-admin/src/main/webapp/react-webapp/src/components/CommonComponents.jsx b/security-admin/src/main/webapp/react-webapp/src/components/CommonComponents.jsx index 053ced0e21..52d84ca558 100644 --- a/security-admin/src/main/webapp/react-webapp/src/components/CommonComponents.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/components/CommonComponents.jsx @@ -20,10 +20,18 @@ import { isEmpty, isObject, lastIndexOf } from "lodash"; import moment from "moment-timezone"; import React, { Component, useEffect, useMemo, useState } from "react"; -import { Alert, Badge, Button, OverlayTrigger, Popover } from "react-bootstrap"; +import { + Alert, + Badge, + Button, + OverlayTrigger, + Popover, + Modal +} from "react-bootstrap"; import { Field } from "react-final-form"; import { useLocation } from "react-router-dom"; import blockLoading from "Images/blockLoading.gif"; +import { components as selectComponents } from "react-select"; export const Loader = () => { return ( @@ -87,12 +95,12 @@ export class MoreLess extends Component { return ( <>
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 0f9f66b589..10caa969ab 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 @@ -24,7 +24,8 @@ import { PathAssociateWithModule, QueryParams, RangerPolicyType, - ServiceType + ServiceType, + policyConditionDisplayLabel } from "Utils/XAEnums"; import { filter, @@ -1585,3 +1586,53 @@ export const currentTimeZone = (timeZoneDate) => { .replace(/^.*GMT.*\(/, "") .replace(/\)$/, ""); }; + +// Common function to get display label for policy condition +export const getPolicyConditionDisplayLbl = (lbl) => { + return has(policyConditionDisplayLabel, lbl) + ? policyConditionDisplayLabel[lbl] + : lbl; +}; + +// Common function to safeguard JSON parsing +export const safeJsonParse = (value, fallback) => { + try { + return JSON.parse(value); + } catch (error) { + console.error("JSON Parsing Error:", error); + return fallback; + } +}; + +//CommonFunction to get display label for policy permission item +export const getPolicyPermissionItemDisplayLbl = ( + serviceDef, + policyType, + accessType +) => { + let accessTypeDefVal = []; + const accesTypeKeys = map(accessType, (item) => { + return isObject(item) ? item.type : item; + }); + if (RangerPolicyType.RANGER_MASKING_POLICY_TYPE.value == policyType) { + accessTypeDefVal = serviceDef.dataMaskDef.accessTypes; + } else if ( + RangerPolicyType.RANGER_ROW_FILTER_POLICY_TYPE.value == policyType + ) { + accessTypeDefVal = serviceDef.rowFilterDef.accessTypes; + } else { + accessTypeDefVal = serviceDef.accessTypes; + } + if (serviceDef.name == "tag") { + return map(sortBy(accesTypeKeys), (val) => ({ label: val })); + } else { + if (accessType.length == accessTypeDefVal.length) { + return sortBy(accessTypeDefVal, "label"); + } else { + const accessTypeDisplayLblObj = filter(accessTypeDefVal, (item) => + includes(accesTypeKeys, { type: item.name }) + ); + return sortBy(accessTypeDisplayLblObj, "label"); + } + } +}; diff --git a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/Admin/AdminLogs/PolicyViewDetails.jsx b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/Admin/AdminLogs/PolicyViewDetails.jsx index 2c96e1559b..e683303a1b 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/Admin/AdminLogs/PolicyViewDetails.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/Admin/AdminLogs/PolicyViewDetails.jsx @@ -24,7 +24,12 @@ import { RangerPolicyType, DefStatus } from "Utils/XAEnums"; import dateFormat from "dateformat"; import { toast } from "react-toastify"; import { cloneDeep, find, isEmpty, map, sortBy } from "lodash"; -import { getResourcesDefVal, serverError } from "Utils/XAUtils"; +import { + getResourcesDefVal, + serverError, + getPolicyConditionDisplayLbl, + getPolicyPermissionItemDisplayLbl +} from "Utils/XAUtils"; import { ModalLoader } from "Components/CommonComponents"; import { getServiceDef } from "Utils/appState"; @@ -377,7 +382,7 @@ export function PolicyViewDetails(props) {
Allow Conditions :
+Allow Rules :
Exclude from Allow Conditions :
+Exclude from Allow Rules :
Masking Conditions :
+Masking Rules :
|
- |
{isArray(
values?.conditions[keyName]
) ? (
- |
|
- |