Fix validation of user profile attributes (#4139)
This commit is contained in:
parent
e914ac6ea2
commit
e15ac55570
3 changed files with 10 additions and 12 deletions
|
@ -20,11 +20,12 @@ import { AddValidatorRoleDialog } from "./AddValidatorRoleDialog";
|
|||
import useToggle from "../../../utils/useToggle";
|
||||
import { useServerInfo } from "../../../context/server-info/ServerInfoProvider";
|
||||
import ComponentTypeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/componentTypeRepresentation";
|
||||
import ComponentRepresentation from "libs/keycloak-admin-client/lib/defs/componentRepresentation";
|
||||
|
||||
export type AddValidatorDialogProps = {
|
||||
selectedValidators: IndexedValidations[];
|
||||
toggleDialog: () => void;
|
||||
onConfirm: (newValidator: ComponentTypeRepresentation) => void;
|
||||
onConfirm: (newValidator: ComponentRepresentation) => void;
|
||||
};
|
||||
|
||||
export const AddValidatorDialog = ({
|
||||
|
@ -74,7 +75,7 @@ export const AddValidatorDialog = ({
|
|||
</Tr>
|
||||
</Thead>
|
||||
<Tbody>
|
||||
{allValidator.map((validator) => (
|
||||
{validators.map((validator) => (
|
||||
<Tr
|
||||
key={validator.id}
|
||||
onRowClick={() => {
|
||||
|
|
|
@ -4,11 +4,12 @@ import { Button, Form, Modal, ModalVariant } from "@patternfly/react-core";
|
|||
|
||||
import type ComponentTypeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/componentTypeRepresentation";
|
||||
import { DynamicComponents } from "../../../components/dynamic/DynamicComponents";
|
||||
import ComponentRepresentation from "libs/keycloak-admin-client/lib/defs/componentRepresentation";
|
||||
|
||||
export type AddValidatorRoleDialogProps = {
|
||||
open: boolean;
|
||||
toggleDialog: () => void;
|
||||
onConfirm: (newValidator: ComponentTypeRepresentation) => void;
|
||||
onConfirm: (newValidator: ComponentRepresentation) => void;
|
||||
selected: ComponentTypeRepresentation;
|
||||
};
|
||||
|
||||
|
|
|
@ -28,9 +28,7 @@ import "../../realm-settings-section.css";
|
|||
export const AttributeValidations = () => {
|
||||
const { t } = useTranslation("realm-settings");
|
||||
const [addValidatorModalOpen, toggleModal] = useToggle();
|
||||
const [validatorToDelete, setValidatorToDelete] = useState<{
|
||||
name: string;
|
||||
}>();
|
||||
const [validatorToDelete, setValidatorToDelete] = useState<string>();
|
||||
const { setValue, control, register } = useFormContext();
|
||||
|
||||
const validators = useWatch<IndexedValidations[]>({
|
||||
|
@ -46,13 +44,13 @@ export const AttributeValidations = () => {
|
|||
const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({
|
||||
titleKey: t("deleteValidatorConfirmTitle"),
|
||||
messageKey: t("deleteValidatorConfirmMsg", {
|
||||
validatorName: validatorToDelete?.name!,
|
||||
validatorName: validatorToDelete,
|
||||
}),
|
||||
continueButtonLabel: "common:delete",
|
||||
continueButtonVariant: ButtonVariant.danger,
|
||||
onConfirm: async () => {
|
||||
const updatedValidators = validators.filter(
|
||||
(validator) => validator.key !== validatorToDelete?.name
|
||||
(validator) => validator.key !== validatorToDelete
|
||||
);
|
||||
|
||||
setValue("validations", [...updatedValidators]);
|
||||
|
@ -67,7 +65,7 @@ export const AttributeValidations = () => {
|
|||
onConfirm={(newValidator) => {
|
||||
setValue("validations", [
|
||||
...validators,
|
||||
{ key: newValidator.id, value: newValidator.properties },
|
||||
{ key: newValidator.id, value: newValidator.config },
|
||||
]);
|
||||
}}
|
||||
toggleDialog={toggleModal}
|
||||
|
@ -111,9 +109,7 @@ export const AttributeValidations = () => {
|
|||
data-testid="deleteValidator"
|
||||
onClick={() => {
|
||||
toggleDeleteDialog();
|
||||
setValidatorToDelete({
|
||||
name: validator.key,
|
||||
});
|
||||
setValidatorToDelete(validator.key);
|
||||
}}
|
||||
>
|
||||
{t("common:delete")}
|
||||
|
|
Loading…
Reference in a new issue