-
+
+ {({ input }) => (
+ trimInputValue(e, input)}
+ />
+ )}
+
-
+
+ {({ input }) => (
+ trimInputValue(e, input)}
+ />
+ )}
+
{
let params = {};
if (inputValue) {
- params["policyLabel"] = inputValue || "";
+ params["policyLabel"] = inputValue.trim() || "";
}
const policyLabelResp = await fetchApi({
url: "plugins/policyLabels",
@@ -299,8 +300,8 @@ export default function AddUpdatePolicyForm() {
});
return policyLabelResp.data.map((name) => ({
- label: name,
- value: name
+ label: name.trim(),
+ value: name.trim()
}));
};
@@ -391,12 +392,12 @@ export default function AddUpdatePolicyForm() {
data.policyName = policyData?.name;
data.isEnabled = policyData?.isEnabled;
data.policyPriority = policyData?.policyPriority == 0 ? false : true;
- data.description = policyData?.description;
+ data.description = policyData?.description?.trim();
data.isAuditEnabled = policyData?.isAuditEnabled;
data.policyLabel =
policyData &&
policyData?.policyLabels?.map((val) => {
- return { label: val, value: val };
+ return { label: val?.trim(), value: val?.trim() };
});
if (policyData?.resources) {
if (!isMultiResources) {
@@ -405,7 +406,7 @@ export default function AddUpdatePolicyForm() {
let setResources = find(serviceCompResourcesDetails, ["name", key]);
data[`resourceName-${setResources?.level}`] = setResources;
data[`value-${setResources?.level}`] = value.values.map((m) => {
- return { label: m, value: m };
+ return { label: m?.trim(), value: m?.trim() };
});
if (setResources?.excludesSupported) {
data[`isExcludesSupport-${setResources?.level}`] =
@@ -450,7 +451,7 @@ export default function AddUpdatePolicyForm() {
setResources;
additionalResourcesObj[`value-${setResources?.level}`] =
value.values.map((m) => {
- return { label: m, value: m };
+ return { label: m?.trim(), value: m?.trim() };
});
if (setResources?.excludesSupported) {
additionalResourcesObj[
@@ -521,7 +522,7 @@ export default function AddUpdatePolicyForm() {
data.conditions[val?.type] = JSON.parse(conditionObj.uiHint)
.isMultiValue
? val?.values
- : val?.values.toString();
+ : val?.values.toString().trim();
}
}
}
@@ -711,9 +712,9 @@ export default function AddUpdatePolicyForm() {
obj.conditions[data?.type] = JSON.parse(conditionObj.uiHint)
.isMultiValue
? data?.values.map((m) => {
- return { value: m, label: m };
+ return { value: m.trim(), label: m.trim() };
})
- : data?.values.toString();
+ : data?.values.toString().trim();
}
}
}
@@ -889,7 +890,7 @@ export default function AddUpdatePolicyForm() {
data["conditions"] = [];
}
- /* For create zoen policy*/
+ /* For create zone policy*/
if (localStorage.getItem("zoneDetails") != null) {
data["zoneName"] = JSON.parse(localStorage.getItem("zoneDetails")).label;
}
@@ -1303,6 +1304,7 @@ export default function AddUpdatePolicyForm() {
: "form-control"
}
data-cy="policyName"
+ onBlur={(e) => trimInputValue(e, input)}
/>
trimInputValue(e, input)}
/>
diff --git a/security-admin/src/main/webapp/react-webapp/src/views/PolicyListing/PolicyConditionsComp.jsx b/security-admin/src/main/webapp/react-webapp/src/views/PolicyListing/PolicyConditionsComp.jsx
index 7c8aba953a..8b2240e2e0 100644
--- a/security-admin/src/main/webapp/react-webapp/src/views/PolicyListing/PolicyConditionsComp.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/views/PolicyListing/PolicyConditionsComp.jsx
@@ -25,7 +25,10 @@ import CreatableSelect from "react-select/creatable";
import { find, isEmpty } from "lodash";
import { InfoIcon } from "Utils/XAUtils";
import { RegexMessage } from "Utils/XAMessages";
-import { selectInputCustomStyles } from "Components/CommonComponents";
+import {
+ selectInputCustomStyles,
+ trimInputValue
+} from "Components/CommonComponents";
const esprima = require("esprima");
export default function PolicyConditionsComp(props) {
@@ -90,7 +93,11 @@ export default function PolicyConditionsComp(props) {
const ipRangeVal = (val) => {
let value = [];
if (!isEmpty(val)) {
- value = val.map((m) => ({ label: m, value: m }));
+ // Trim existing values when displaying
+ value = val.map((m) => ({
+ label: m.trim(),
+ value: m.trim()
+ }));
}
return value;
};
@@ -193,6 +200,9 @@ export default function PolicyConditionsComp(props) {
}
as="textarea"
rows={3}
+ onBlur={(e) =>
+ trimInputValue(e, input)
+ }
/>
{meta.error && (
@@ -227,6 +237,24 @@ export default function PolicyConditionsComp(props) {
value={ipRangeVal(input.value)}
onChange={(e) => handleChange(e, input)}
styles={selectInputCustomStyles}
+ formatCreateLabel={(inputValue) =>
+ `Create "${inputValue.trim()}"`
+ }
+ onCreateOption={(inputValue) => {
+ const trimmedValue = inputValue.trim();
+ if (trimmedValue) {
+ const newOption = {
+ label: trimmedValue,
+ value: trimmedValue
+ };
+ const currentValues = input.value || [];
+ const newValues = [
+ ...currentValues,
+ trimmedValue
+ ];
+ input.onChange(newValues);
+ }
+ }}
/>
)}
/>
diff --git a/security-admin/src/main/webapp/react-webapp/src/views/Resources/ResourceComp.jsx b/security-admin/src/main/webapp/react-webapp/src/views/Resources/ResourceComp.jsx
index 661e8237dd..373d83b8fa 100644
--- a/security-admin/src/main/webapp/react-webapp/src/views/Resources/ResourceComp.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/views/Resources/ResourceComp.jsx
@@ -134,17 +134,17 @@ export default function ResourceComp(props) {
delete formValues[`isRecursiveSupport-${levelKey}`];
}
delete formValues[`value-${grpResourcesKeys[index]}`];
- let CurrentSelectedResourcs = selectedVal.name;
+ let currentSelectedResources = selectedVal.name;
for (let j = index + 1; j < grpResourcesKeys.length; j++) {
let level = grpResourcesKeys[j];
let nextResource = resources.find((m) => {
if (m?.parent) {
- return m.parent === CurrentSelectedResourcs;
+ return m.parent === currentSelectedResources;
}
});
if (nextResource) {
formValues[`resourceName-${level}`] = nextResource;
- CurrentSelectedResourcs = nextResource.name;
+ currentSelectedResources = nextResource.name;
}
}
diff --git a/security-admin/src/main/webapp/react-webapp/src/views/Resources/ResourceSelectComp.jsx b/security-admin/src/main/webapp/react-webapp/src/views/Resources/ResourceSelectComp.jsx
index 128796f559..c99fc21069 100644
--- a/security-admin/src/main/webapp/react-webapp/src/views/Resources/ResourceSelectComp.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/views/Resources/ResourceSelectComp.jsx
@@ -93,7 +93,7 @@ export default function ResourceSelectComp(props) {
toastId.current = toast.error(error.response.data.msgDesc);
} else {
toastId.current = toast.error(
- "Resouce lookup failed for current resource"
+ "Resource lookup failed for current resource"
);
}
}
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 12a3764582..3370059825 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
@@ -48,7 +48,8 @@ import {
Loader,
scrollToError,
selectInputCustomStyles,
- selectInputCustomErrorStyles
+ selectInputCustomErrorStyles,
+ trimInputValue
} from "Components/CommonComponents";
import usePrompt from "Hooks/usePrompt";
import { getServiceDef } from "Utils/appState";
@@ -58,7 +59,7 @@ const noneOptions = {
value: "none"
};
-const PromtDialog = (props) => {
+const PromptDialog = (props) => {
const { isDirtyField, isUnblock } = props;
usePrompt("Are you sure you want to leave", isDirtyField && !isUnblock);
return null;
@@ -75,10 +76,10 @@ const SecurityZoneForm = () => {
const [resourceService, setResourceService] = useState({});
const [resourceServicesOpt, setResourceServicesOpt] = useState([]);
const [loader, setLoader] = useState(true);
- const [modelState, setModalstate] = useState({
+ const [modelState, setModalState] = useState({
showModalResource: false,
data: null,
- inputval: null,
+ inputVal: null,
index: 0
});
const [preventUnBlock, setPreventUnblock] = useState(false);
@@ -93,7 +94,7 @@ const SecurityZoneForm = () => {
const [defaultTagServiceOptions, setDefaultTagServiceOptions] = useState([]);
useEffect(() => {
- fetchInitalData();
+ fetchInitialData();
}, [params.zoneId]);
const validate = (values) => {
@@ -105,12 +106,12 @@ const SecurityZoneForm = () => {
};
} else {
if (
- !RegexValidation.NAME_VALIDATION.regexforNameValidation.test(
+ !RegexValidation.NAME_VALIDATION.regexForNameValidation.test(
values.name
)
) {
errors.name = {
- text: RegexValidation.NAME_VALIDATION.regexforNameValidationMessage
+ text: RegexValidation.NAME_VALIDATION.regexForNameValidationMessage
};
}
}
@@ -122,7 +123,7 @@ const SecurityZoneForm = () => {
) {
errors.adminRoles = {
required: true,
- text: "Please provide atleast one admin user or group or role !"
+ text: "Please provide at least one admin user or group or role !"
};
errors.adminUserGroups = {
required: true,
@@ -156,15 +157,15 @@ const SecurityZoneForm = () => {
};
const handleClose = () => {
- setModalstate({
+ setModalState({
showModalResource: false,
data: null,
- inputval: null,
+ inputVal: null,
index: 0
});
};
- const fetchInitalData = async () => {
+ const fetchInitialData = async () => {
await fetchResourceServices();
await fetchZones();
};
@@ -236,10 +237,10 @@ const SecurityZoneForm = () => {
}
}
- setModalstate({
+ setModalState({
showModalResource: true,
data: {},
- inputval: resourceInput,
+ inputVal: resourceInput,
index: -1
});
@@ -263,10 +264,10 @@ const SecurityZoneForm = () => {
}
}
- setModalstate({
+ setModalState({
showModalResource: true,
data: editData,
- inputval: resourceInput,
+ inputVal: resourceInput,
index: resourceIndex
});
@@ -407,8 +408,8 @@ const SecurityZoneForm = () => {
const EditFormData = () => {
const zoneData = {};
- zoneData.name = zone.name;
- zoneData.description = zone.description;
+ zoneData.name = zone?.name?.trim();
+ zoneData.description = zone?.description?.trim();
zoneData.adminUserGroups = [];
if (zone.adminUserGroups) {
@@ -633,14 +634,14 @@ const SecurityZoneForm = () => {
const handleSave = () => {
if (modelState.index === -1) {
let add = [];
- add = modelState.inputval.input.value;
+ add = modelState.inputVal.input.value;
add.push(modelState.data);
- modelState.inputval.input.onChange(add);
+ modelState.inputVal.input.onChange(add);
handleClose();
} else {
- let edit = modelState.inputval.input.value;
+ let edit = modelState.inputVal.input.value;
edit[modelState.index] = modelState.data;
- modelState.inputval.input.onChange(edit);
+ modelState.inputVal.input.onChange(edit);
handleClose();
}
};
@@ -776,7 +777,7 @@ const SecurityZoneForm = () => {
submitting
}) => (
-
+
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 40d871904f..d8be11ea48 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
@@ -23,7 +23,6 @@ import { Form, Field } from "react-final-form";
import { toast } from "react-toastify";
import arrayMutators from "final-form-arrays";
import { FieldArray } from "react-final-form-arrays";
-import Select from "react-select";
import AsyncSelect from "react-select/async";
import AsyncCreatableSelect from "react-select/async-creatable";
import { RegexValidation, additionalServiceConfigs } from "Utils/XAEnums";
@@ -42,7 +41,8 @@ import {
CustomPopover,
Loader,
scrollToError,
- selectInputCustomStyles
+ selectInputCustomStyles,
+ trimInputValue
} from "Components/CommonComponents";
import {
difference,
@@ -387,8 +387,8 @@ class ServiceForm extends Component {
const serviceJson = {};
serviceJson["name"] = serviceResp?.data?.name;
- serviceJson["displayName"] = serviceResp?.data?.displayName;
- serviceJson["description"] = serviceResp?.data?.description;
+ serviceJson["displayName"] = serviceResp?.data?.displayName?.trim();
+ serviceJson["description"] = serviceResp?.data?.description?.trim();
serviceJson["isEnabled"] = JSON.stringify(serviceResp?.data?.isEnabled);
serviceJson["tagService"] =
@@ -409,7 +409,7 @@ class ServiceForm extends Component {
serviceDefConfigs.map((config) => {
serviceJson["configs"][config.replaceAll(".", "_").replaceAll("-", "_")] =
- serviceResp?.data?.configs?.[config];
+ serviceResp?.data?.configs?.[config]?.trim();
});
const additionalConfigs = intersection(
@@ -435,7 +435,10 @@ class ServiceForm extends Component {
let editCustomConfigs = sortBy(
difference(serviceCustomConfigs, additionalConfigs)?.map((config) => {
- return { name: config, value: serviceResp?.data?.configs[config] };
+ return {
+ name: config?.trim(),
+ value: serviceResp?.data?.configs[config]?.trim()
+ };
}),
"name"
);
@@ -762,6 +765,7 @@ class ServiceForm extends Component {
data-cy={
"configs." + this.configsJson[configParam.name]
}
+ onBlur={(e) => trimInputValue(e, input)}
/>
{configInfo.length === 1 && (
@@ -972,8 +976,8 @@ class ServiceForm extends Component {
: undefined;
validateDisplayName = (value) =>
- !RegexValidation.NAME_VALIDATION.regexforNameValidation.test(value)
- ? RegexValidation.NAME_VALIDATION.regexforNameValidationMessage
+ !RegexValidation.NAME_VALIDATION.regexForNameValidation.test(value)
+ ? RegexValidation.NAME_VALIDATION.regexForNameValidationMessage
: undefined;
composeValidators =
@@ -1209,6 +1213,7 @@ class ServiceForm extends Component {
: "form-control"
}
data-cy="displayName"
+ onBlur={(e) => trimInputValue(e, input)}
/>
{meta.error && meta.touched && (
@@ -1236,6 +1241,7 @@ class ServiceForm extends Component {
: "form-control"
}
data-cy="description"
+ onBlur={(e) => trimInputValue(e, input)}
/>
{meta.error && meta.touched && (
@@ -1334,22 +1340,34 @@ class ServiceForm extends Component {
fields.map((name, index) => (
-
+
+ {({ input }) => (
+
+ trimInputValue(e, input)
+ }
+ />
+ )}
+
-
+
+ {({ input }) => (
+
+ trimInputValue(e, input)
+ }
+ />
+ )}
+
{
+const PromptDialog = (props) => {
const { isDirtyField, isUnblock } = props;
usePrompt("Are you sure you want to leave", isDirtyField && !isUnblock);
return null;
@@ -210,7 +211,7 @@ function GroupForm() {
if (params?.groupID) {
if (Object.keys(groupInfo).length > 0) {
formValueObj.name = groupInfo.name;
- formValueObj.description = groupInfo.description;
+ formValueObj.description = groupInfo?.description?.trim();
}
}
return formValueObj;
@@ -263,7 +264,7 @@ function GroupForm() {
dirty
}) => (