Removes the already added validators after closing the dialog (#2435)
This commit is contained in:
parent
45746e7660
commit
4fc64e6915
2 changed files with 10 additions and 1 deletions
|
@ -9,22 +9,30 @@ import {
|
|||
Thead,
|
||||
Tr,
|
||||
} from "@patternfly/react-table";
|
||||
|
||||
import type { KeyValueType } from "../../../components/attribute-form/attribute-convert";
|
||||
import { AddValidatorRoleDialog } from "./AddValidatorRoleDialog";
|
||||
import { Validator, validators as allValidator } from "./Validators";
|
||||
import useToggle from "../../../utils/useToggle";
|
||||
|
||||
export type AddValidatorDialogProps = {
|
||||
selectedValidators: KeyValueType[];
|
||||
toggleDialog: () => void;
|
||||
onConfirm: (newValidator: Validator) => void;
|
||||
};
|
||||
|
||||
export const AddValidatorDialog = ({
|
||||
selectedValidators,
|
||||
toggleDialog,
|
||||
onConfirm,
|
||||
}: AddValidatorDialogProps) => {
|
||||
const { t } = useTranslation("realm-settings");
|
||||
const [selectedValidator, setSelectedValidator] = useState<Validator>();
|
||||
const [validators, setValidators] = useState(allValidator);
|
||||
const [validators, setValidators] = useState(() =>
|
||||
allValidator.filter(
|
||||
({ name }) => !selectedValidators.map(({ key }) => key).includes(name)
|
||||
)
|
||||
);
|
||||
const [addValidatorRoleModalOpen, toggleModal] = useToggle();
|
||||
|
||||
return (
|
||||
|
|
|
@ -66,6 +66,7 @@ export const AttributeValidations = () => {
|
|||
<>
|
||||
{addValidatorModalOpen && (
|
||||
<AddValidatorDialog
|
||||
selectedValidators={validators}
|
||||
onConfirm={(newValidator) => {
|
||||
setValue("validations", [
|
||||
...validators,
|
||||
|
|
Loading…
Reference in a new issue