Fix validation of user profile attributes (#4139)

This commit is contained in:
Erik Jan de Wit 2023-01-07 20:14:16 +01:00 committed by GitHub
parent e914ac6ea2
commit e15ac55570
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 12 deletions

View file

@ -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={() => {

View file

@ -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;
};

View file

@ -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")}