all mappers saving except two roles

This commit is contained in:
mfrances 2021-04-08 12:33:59 -04:00
parent dcbb2b90bf
commit a50cf33138
6 changed files with 28 additions and 22 deletions

View file

@ -81,15 +81,17 @@ export const LdapMapperDetails = () => {
const save = async (mapper: ComponentRepresentation) => {
const config = convertFormValuesToObject(mapper.config);
const map = {...mapping, config };
const map = { ...mapping, config };
try {
if (id) {
if (id === "new") {
await adminClient.components.create(mapper);
history.push(`/${realm}/user-federation/ldap/${mapper!.parentId}/mappers`);
history.push(
`/${realm}/user-federation/ldap/${mapper!.parentId}/mappers`
);
} else {
// TODO remove after debugging each mapper type
console.log(`On save - mapping is:`)
console.log(`On save - mapping is:`);
console.log(`${JSON.stringify(mapping)}`);
console.log(`id is:`);
console.log(`${id}`);
@ -246,7 +248,7 @@ export const LdapMapperDetails = () => {
{/* When loading existing mappers, load forms based on providerId aka mapper type */}
{mapping
? (mapping.providerId! === "certificate-ldap-mapper" ||
mapping.providerId! === "user-attribute-ldap-mapper") && (
mapping.providerId! === "user-attribute-ldap-mapper") && (
<LdapMapperUserAttribute
form={form}
mapperType={mapping?.providerId}
@ -287,7 +289,7 @@ export const LdapMapperDetails = () => {
: ""}
{mapping
? (mapping.providerId! === "role-ldap-mapper" ||
mapping.providerId! === "group-ldap-mapper") && (
mapping.providerId! === "group-ldap-mapper") && (
<LdapMapperRoleGroup form={form} type={mapping.providerId} />
)
: ""}

View file

@ -33,7 +33,7 @@ export const LdapMapperFullNameAttribute = ({
type="text"
id="kc-full-name-attribute"
data-testid="full-name-attribute"
name="config.ldap-full-name-attribute"
name="config.ldap-full-name-attribute[0]"
ref={form.register}
/>
</FormGroup>

View file

@ -33,7 +33,7 @@ export const LdapMapperHardcodedLdapAttribute = ({
type="text"
id="kc-ldap-attribute-name"
data-testid="ldap-attribute-name"
name="config.ldap-attribute-name"
name="config.ldap-attribute-name[0]"
ref={form.register}
/>
</FormGroup>
@ -54,7 +54,7 @@ export const LdapMapperHardcodedLdapAttribute = ({
type="text"
id="kc-ldap-attribute-value"
data-testid="ldap-attribute-value"
name="config.ldap-attribute-value"
name="config.ldap-attribute-value[0]"
ref={form.register}
/>
</FormGroup>

View file

@ -33,7 +33,7 @@ export const LdapMapperHardcodedLdapGroup = ({
type="text"
id="kc-group"
data-testid="group"
name="config.group"
name="config.group[0]"
ref={form.register}
/>
</FormGroup>

View file

@ -33,7 +33,7 @@ export const LdapMapperHardcodedLdapRole = ({
type="text"
id="kc-role"
data-testid="role"
name="config.role"
name="config.role[0]"
ref={form.register}
/>
</FormGroup>

View file

@ -61,7 +61,7 @@ export const LdapMapperRoleGroup = ({
type="text"
id="kc-ldap-dn"
data-testid="ldap-dn"
name={isRole ? "config.roles-dn" : "config.groups-dn"}
name={isRole ? "config.roles-dn[0]" : "config.groups-dn[0]"}
ref={form.register}
/>
</FormGroup>
@ -77,7 +77,7 @@ export const LdapMapperRoleGroup = ({
: helpText("groupNameLdapAttributeHelp")
}
forLabel={
isRole ? t("roleNameLdapAttribute") : t("roleNameLdapAttribute")
isRole ? t("roleNameLdapAttribute") : t("groupNameLdapAttribute")
}
forID="kc-name-attribute"
/>
@ -92,8 +92,8 @@ export const LdapMapperRoleGroup = ({
data-testid="name-attribute"
name={
isRole
? "config.role-name-ldap-attribute"
: "config.group-name-ldap-attribute"
? "config.role-name-ldap-attribute[0]"
: "config.group-name-ldap-attribute[0]"
}
ref={form.register}
/>
@ -121,8 +121,8 @@ export const LdapMapperRoleGroup = ({
data-testid="object-classes"
name={
isRole
? "config.role-object-classes"
: "config.group-object-classes"
? "config.role-object-classes[0]"
: "config.group-object-classes[0]"
}
ref={form.register}
/>
@ -204,7 +204,7 @@ export const LdapMapperRoleGroup = ({
type="text"
id="kc-membership-ldap-attribute"
data-testid="membership-ldap-attribute"
name="config.membership-ldap-attribute"
name="config.membership-ldap-attribute[0]"
ref={form.register}
/>
</FormGroup>
@ -264,7 +264,7 @@ export const LdapMapperRoleGroup = ({
type="text"
id="kc-membership-user-ldap-attribute"
data-testid="membership-user-ldap-attribute"
name="config.membership-user-ldap-attribute"
name="config.membership-user-ldap-attribute[0]"
ref={form.register}
/>
</FormGroup>
@ -285,7 +285,11 @@ export const LdapMapperRoleGroup = ({
type="text"
id="kc-ldap-filter"
data-testid="ldap-filter"
name="config.ldap-filter"
name={
isRole
? "config.roles-ldap-filter[0]"
: "config.groups-ldap-filter[0]"
}
ref={form.register}
/>
</FormGroup>
@ -410,7 +414,7 @@ export const LdapMapperRoleGroup = ({
type="text"
id="kc-member-of-attribute"
data-testid="member-of-attribute"
name="config.memberof-ldap-attribute"
name="config.memberof-ldap-attribute[0]"
ref={form.register}
/>
</FormGroup>
@ -504,7 +508,7 @@ export const LdapMapperRoleGroup = ({
type="text"
id="kc-mapped-attributes"
data-testid="mapped-attributes"
name="config.mapped-group-attributes"
name="config.mapped-group-attributes[0]"
ref={form.register}
/>
</FormGroup>
@ -553,7 +557,7 @@ export const LdapMapperRoleGroup = ({
type="text"
id="kc-path"
data-testid="path"
name="config.groups-path"
name="config.groups-path[0]"
ref={form.register}
/>
</FormGroup>