Skip to content

Commit

Permalink
RANGER-4010: updated react UI to support multiple resource-sets in po…
Browse files Browse the repository at this point in the history
…licies

Signed-off-by: Madhan Neethiraj <[email protected]>
  • Loading branch information
dhavaljrajpara authored and mneethiraj committed Oct 26, 2023
1 parent 105f6f5 commit d29c2a4
Show file tree
Hide file tree
Showing 14 changed files with 571 additions and 303 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const CheckboxComp = (props) => {
setVal(val);
};

const handleAllChekced = (e) => {
const handleAllChecked = (e) => {
let val = [];
if (e.target.checked) {
val = [...options];
Expand Down Expand Up @@ -92,7 +92,7 @@ const CheckboxComp = (props) => {
checked={isAllChecked()}
type="checkbox"
label={selectAllLabel}
onChange={(e) => handleAllChekced(e)}
onChange={(e) => handleAllChecked(e)}
/>
</Form.Group>
)}
Expand Down Expand Up @@ -126,7 +126,7 @@ const RadioBtnComp = (props) => {
));
};

const InputboxComp = (props) => {
const InputBoxComp = (props) => {
const { value = "", valRef } = props;
const [selectedInputVal, setInputVal] = useState(value);
const handleChange = (e) => {
Expand Down Expand Up @@ -160,7 +160,7 @@ const CustomCondition = (props) => {
return (
<>
{conditionDefVal?.length > 0 &&
conditionDefVal.map((m) => {
conditionDefVal.map((m, index) => {
let uiHintAttb =
m.uiHint != undefined && m.uiHint != "" ? JSON.parse(m.uiHint) : "";
if (uiHintAttb != "") {
Expand Down Expand Up @@ -249,7 +249,7 @@ const CustomCondition = (props) => {
position="right"
message={
<p className="pd-10">
{RegexMessage.MESSAGE.policyconditioninfoicon}
{RegexMessage.MESSAGE.policyConditionInfoIcon}
</p>
}
/>
Expand Down Expand Up @@ -312,7 +312,7 @@ const CustomCondition = (props) => {
);
};

const innitialState = (props) => {
const initialState = (props) => {
const { type, selectProps, value } = props;
let val = value;
if (!val) {
Expand Down Expand Up @@ -369,7 +369,7 @@ const Editable = (props) => {
state: false,
errorMSG: ""
});
const [state, dispatch] = useReducer(reducer, props, innitialState);
const [state, dispatch] = useReducer(reducer, props, initialState);
const { show, value, target } = state;
let isListenerAttached = false;

Expand Down Expand Up @@ -714,7 +714,7 @@ const Editable = (props) => {
) : type === TYPE_RADIO ? (
<RadioBtnComp value={value} options={options} valRef={selectValRef} />
) : type === TYPE_INPUT ? (
<InputboxComp value={value} valRef={selectValRef} />
<InputBoxComp value={value} valRef={selectValRef} />
) : type === TYPE_CUSTOM ? (
<CustomCondition
value={value}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2554,3 +2554,8 @@ li.list-group-item:hover {
.text-word-break {
word-break: break-all;
}
.resource-block {
padding: 0.5rem 0;
border-bottom: 1px solid #dddddd;
margin:1rem 2rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import React from "react";

export const RegexMessage = {
MESSAGE: {
policynameinfoiconmessage:
policyNameInfoIconMessage:
"Please avoid these characters (&, <, >, ', \", `) for policy name.",
userNameValidationMsg: (
<>
Expand Down Expand Up @@ -49,7 +49,7 @@ export const RegexMessage = {
</p>
</>
),
policyconditioninfoicon:
policyConditionInfoIcon:
"1. JavaScript Condition Examples :\
country_code == 'USA', time_range >= 900 time_range <= 1800 etc.\
2. Dragging bottom-right corner of javascript condition editor(Textarea) can resizable",
Expand Down
28 changes: 25 additions & 3 deletions security-admin/src/main/webapp/react-webapp/src/utils/XAUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@

import React, { useState } from "react";
import { getUserProfile } from "Utils/appState";
import { UserRoles, PathAssociateWithModule, QueryParams } from "Utils/XAEnums";
import {
UserRoles,
PathAssociateWithModule,
QueryParams,
RangerPolicyType,
ServiceType
} from "Utils/XAEnums";
import {
filter,
find,
Expand All @@ -34,7 +40,8 @@ import {
isUndefined,
isNull,
some,
has
has,
sortBy
} from "lodash";
import { matchRoutes } from "react-router-dom";
import dateFormat from "dateformat";
Expand All @@ -43,7 +50,6 @@ import CustomBreadcrumb from "../views/CustomBreadcrumb";
import { CustomTooltip } from "../components/CommonComponents";
import InfiniteScroll from "react-infinite-scroll-component";
import { toast } from "react-toastify";
import { RangerPolicyType, ServiceType } from "./XAEnums";
import { policyInfoMessage } from "./XAMessages";
import { fetchApi } from "Utils/fetchAPI";

Expand Down Expand Up @@ -1436,3 +1442,19 @@ export const policyConditionUpdatedJSON = (policyCond) => {
});
return newPolicyConditionJSON;
};

// Get resources with help of policy type

export const getResourcesDefVal = (serviceDef, policyType) => {
let resources = [];
if (RangerPolicyType.RANGER_MASKING_POLICY_TYPE.value == policyType) {
resources = sortBy(serviceDef.dataMaskDef.resources, "itemId");
} else if (
RangerPolicyType.RANGER_ROW_FILTER_POLICY_TYPE.value == policyType
) {
resources = sortBy(serviceDef.rowFilterDef.resources, "itemId");
} else {
resources = sortBy(serviceDef.resources, "itemId");
}
return resources;
};
Loading

0 comments on commit d29c2a4

Please sign in to comment.