added deleting validator (#2278)
Co-authored-by: Agnieszka Gancarczyk <agancarc@redhat.com>
This commit is contained in:
parent
330dd33803
commit
84d501c145
2 changed files with 14 additions and 3 deletions
|
@ -142,7 +142,16 @@ export default function NewAttributeSettings() {
|
||||||
: profileConfig.scopeRequired,
|
: 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(
|
const annotations = (profileConfig.annotations! as KeyValueType[]).reduce(
|
||||||
(obj, item) => Object.assign(obj, { [item.key]: item.value }),
|
(obj, item) => Object.assign(obj, { [item.key]: item.value }),
|
||||||
|
|
|
@ -50,7 +50,10 @@ export const AttributeValidations = () => {
|
||||||
continueButtonLabel: "common:delete",
|
continueButtonLabel: "common:delete",
|
||||||
continueButtonVariant: ButtonVariant.danger,
|
continueButtonVariant: ButtonVariant.danger,
|
||||||
onConfirm: async () => {
|
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"
|
key="validator"
|
||||||
variant="link"
|
variant="link"
|
||||||
data-testid="deleteValidator"
|
data-testid="deleteValidator"
|
||||||
isDisabled={true}
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
toggleDeleteDialog();
|
toggleDeleteDialog();
|
||||||
setValidatorToDelete({
|
setValidatorToDelete({
|
||||||
|
|
Loading…
Reference in a new issue