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,
|
Tr,
|
||||||
} from "@patternfly/react-table";
|
} from "@patternfly/react-table";
|
||||||
import { AddValidatorRoleDialog } from "./AddValidatorRoleDialog";
|
import { AddValidatorRoleDialog } from "./AddValidatorRoleDialog";
|
||||||
import { Validator, validators } from "./Validators";
|
import { Validator, validators as allValidator } from "./Validators";
|
||||||
import useToggle from "../../../utils/useToggle";
|
import useToggle from "../../../utils/useToggle";
|
||||||
|
|
||||||
export type AddValidatorDialogProps = {
|
export type AddValidatorDialogProps = {
|
||||||
|
@ -24,13 +24,19 @@ export const AddValidatorDialog = ({
|
||||||
}: AddValidatorDialogProps) => {
|
}: AddValidatorDialogProps) => {
|
||||||
const { t } = useTranslation("realm-settings");
|
const { t } = useTranslation("realm-settings");
|
||||||
const [selectedValidator, setSelectedValidator] = useState<Validator>();
|
const [selectedValidator, setSelectedValidator] = useState<Validator>();
|
||||||
|
const [validators, setValidators] = useState(allValidator);
|
||||||
const [addValidatorRoleModalOpen, toggleModal] = useToggle();
|
const [addValidatorRoleModalOpen, toggleModal] = useToggle();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{addValidatorRoleModalOpen && (
|
{addValidatorRoleModalOpen && (
|
||||||
<AddValidatorRoleDialog
|
<AddValidatorRoleDialog
|
||||||
onConfirm={(newValidator) => onConfirm(newValidator)}
|
onConfirm={(newValidator) => {
|
||||||
|
onConfirm(newValidator);
|
||||||
|
setValidators(
|
||||||
|
validators.filter(({ name }) => name !== newValidator.name)
|
||||||
|
);
|
||||||
|
}}
|
||||||
open={addValidatorRoleModalOpen}
|
open={addValidatorRoleModalOpen}
|
||||||
toggleDialog={toggleModal}
|
toggleDialog={toggleModal}
|
||||||
selected={selectedValidator!}
|
selected={selectedValidator!}
|
||||||
|
|
|
@ -23,16 +23,8 @@ export const AddValidatorRoleDialog = ({
|
||||||
const { handleSubmit } = form;
|
const { handleSubmit } = form;
|
||||||
const selectedRoleValidator = selected;
|
const selectedRoleValidator = selected;
|
||||||
|
|
||||||
const save = () => {
|
const save = (newValidator: Validator) => {
|
||||||
const formValues = form.getValues();
|
onConfirm({ ...newValidator, name: selected.name });
|
||||||
formValues.name = selectedRoleValidator.name;
|
|
||||||
|
|
||||||
const newValidator = {
|
|
||||||
name: formValues.name,
|
|
||||||
config: formValues.config ?? [],
|
|
||||||
};
|
|
||||||
|
|
||||||
onConfirm(newValidator);
|
|
||||||
toggleDialog();
|
toggleDialog();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue