Remove picked validators from list (#2405)
This commit is contained in:
parent
36cf7022f5
commit
2d1baed0e9
2 changed files with 10 additions and 12 deletions
|
@ -10,7 +10,7 @@ import {
|
|||
Tr,
|
||||
} from "@patternfly/react-table";
|
||||
import { AddValidatorRoleDialog } from "./AddValidatorRoleDialog";
|
||||
import { Validator, validators } from "./Validators";
|
||||
import { Validator, validators as allValidator } from "./Validators";
|
||||
import useToggle from "../../../utils/useToggle";
|
||||
|
||||
export type AddValidatorDialogProps = {
|
||||
|
@ -24,13 +24,19 @@ export const AddValidatorDialog = ({
|
|||
}: AddValidatorDialogProps) => {
|
||||
const { t } = useTranslation("realm-settings");
|
||||
const [selectedValidator, setSelectedValidator] = useState<Validator>();
|
||||
const [validators, setValidators] = useState(allValidator);
|
||||
const [addValidatorRoleModalOpen, toggleModal] = useToggle();
|
||||
|
||||
return (
|
||||
<>
|
||||
{addValidatorRoleModalOpen && (
|
||||
<AddValidatorRoleDialog
|
||||
onConfirm={(newValidator) => onConfirm(newValidator)}
|
||||
onConfirm={(newValidator) => {
|
||||
onConfirm(newValidator);
|
||||
setValidators(
|
||||
validators.filter(({ name }) => name !== newValidator.name)
|
||||
);
|
||||
}}
|
||||
open={addValidatorRoleModalOpen}
|
||||
toggleDialog={toggleModal}
|
||||
selected={selectedValidator!}
|
||||
|
|
|
@ -23,16 +23,8 @@ export const AddValidatorRoleDialog = ({
|
|||
const { handleSubmit } = form;
|
||||
const selectedRoleValidator = selected;
|
||||
|
||||
const save = () => {
|
||||
const formValues = form.getValues();
|
||||
formValues.name = selectedRoleValidator.name;
|
||||
|
||||
const newValidator = {
|
||||
name: formValues.name,
|
||||
config: formValues.config ?? [],
|
||||
};
|
||||
|
||||
onConfirm(newValidator);
|
||||
const save = (newValidator: Validator) => {
|
||||
onConfirm({ ...newValidator, name: selected.name });
|
||||
toggleDialog();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue