added deleting validator (#2278)

Co-authored-by: Agnieszka Gancarczyk <agancarc@redhat.com>
This commit is contained in:
agagancarczyk 2022-03-17 11:05:10 +00:00 committed by GitHub
parent 330dd33803
commit 84d501c145
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View file

@ -142,7 +142,16 @@ export default function NewAttributeSettings() {
: profileConfig.scopeRequired,
};
const validations = profileConfig.validations;
const validations = profileConfig.validations?.reduce(
(prevValidations: any, currentValidations: any) => {
prevValidations[currentValidations.name] =
currentValidations.config.length === 0
? {}
: currentValidations.config;
return prevValidations;
},
{}
);
const annotations = (profileConfig.annotations! as KeyValueType[]).reduce(
(obj, item) => Object.assign(obj, { [item.key]: item.value }),

View file

@ -50,7 +50,10 @@ export const AttributeValidations = () => {
continueButtonLabel: "common:delete",
continueButtonVariant: ButtonVariant.danger,
onConfirm: async () => {
console.log("TODO");
const updatedValidators = validators.filter(
(validator) => validator.name !== validatorToDelete?.name
);
setValue("validations", [...updatedValidators]);
},
});
@ -104,7 +107,6 @@ export const AttributeValidations = () => {
key="validator"
variant="link"
data-testid="deleteValidator"
isDisabled={true}
onClick={() => {
toggleDeleteDialog();
setValidatorToDelete({