Allow spaces in policy names (#3482)

This commit is contained in:
Cesar Celis
2024-12-05 12:55:57 -05:00
committed by GitHub
parent 6afd0b16dc
commit 5cf02ffae9
4 changed files with 5 additions and 16 deletions

View File

@@ -52,7 +52,7 @@ const AddPolicyScreen = () => {
setAddLoading(true);
api.policies
.addPolicy({
name: policyName,
name: policyName.trim(),
policy: policyDefinition,
})
.then((res) => {
@@ -79,15 +79,12 @@ const AddPolicyScreen = () => {
};
const validatePolicyname = (policyName: string) => {
if (policyName.indexOf(" ") !== -1) {
return "Policy name cannot contain spaces";
if (policyName.trim() === "") {
return "Policy name cannot be empty";
} else return "";
};
const validSave =
policyName.trim() !== "" &&
policyName.indexOf(" ") === -1 &&
policyDefinition.trim() !== "";
const validSave = policyName.trim() !== "" && policyDefinition.trim() !== "";
useEffect(() => {
dispatch(setHelpName("add_policy"));