all creates working except two roles
This commit is contained in:
parent
a50cf33138
commit
501cb98edc
2 changed files with 44 additions and 32 deletions
|
@ -80,25 +80,20 @@ export const LdapMapperDetails = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const save = async (mapper: ComponentRepresentation) => {
|
const save = async (mapper: ComponentRepresentation) => {
|
||||||
const config = convertFormValuesToObject(mapper.config);
|
let config = {};
|
||||||
const map = { ...mapping, config };
|
if (mapper.config !== undefined) {
|
||||||
|
config = convertFormValuesToObject(mapper.config);
|
||||||
|
}
|
||||||
|
const map = { ...mapper, config };
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (id) {
|
if (id) {
|
||||||
if (id === "new") {
|
if (id === "new") {
|
||||||
await adminClient.components.create(mapper);
|
await adminClient.components.create(map);
|
||||||
history.push(
|
history.push(
|
||||||
`/${realm}/user-federation/ldap/${mapper!.parentId}/mappers`
|
`/${realm}/user-federation/ldap/${mapper!.parentId}/mappers`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// TODO remove after debugging each mapper type
|
|
||||||
console.log(`On save - mapping is:`);
|
|
||||||
console.log(`${JSON.stringify(mapping)}`);
|
|
||||||
console.log(`id is:`);
|
|
||||||
console.log(`${id}`);
|
|
||||||
console.log(`mapper is:`);
|
|
||||||
console.log(`${JSON.stringify(mapper)}`);
|
|
||||||
console.log(`map is:`);
|
|
||||||
console.log(`${JSON.stringify(map)}`);
|
|
||||||
await adminClient.components.update({ id }, map);
|
await adminClient.components.update({ id }, map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +112,7 @@ export const LdapMapperDetails = () => {
|
||||||
|
|
||||||
const mapperType = useWatch({
|
const mapperType = useWatch({
|
||||||
control: form.control,
|
control: form.control,
|
||||||
name: "choose-mapper-type",
|
name: "providerId",
|
||||||
});
|
});
|
||||||
|
|
||||||
const isNew = mapperId === "new";
|
const isNew = mapperId === "new";
|
||||||
|
@ -163,6 +158,24 @@ export const LdapMapperDetails = () => {
|
||||||
name="name"
|
name="name"
|
||||||
ref={form.register}
|
ref={form.register}
|
||||||
/>
|
/>
|
||||||
|
<TextInput
|
||||||
|
hidden
|
||||||
|
defaultValue="aa508e29-b5e7-49d0-89ce-f3e65c5e8165"
|
||||||
|
type="text"
|
||||||
|
id="kc-ldap-parentId"
|
||||||
|
data-testid="ldap-parentId"
|
||||||
|
name="parentId"
|
||||||
|
ref={form.register}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
hidden
|
||||||
|
defaultValue="org.keycloak.storage.ldap.mappers.LDAPStorageMapper"
|
||||||
|
type="text"
|
||||||
|
id="kc-ldap-provider-type"
|
||||||
|
data-testid="ldap-provider-type"
|
||||||
|
name="providerType"
|
||||||
|
ref={form.register}
|
||||||
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
{!isNew ? (
|
{!isNew ? (
|
||||||
<FormGroup
|
<FormGroup
|
||||||
|
@ -194,19 +207,19 @@ export const LdapMapperDetails = () => {
|
||||||
<HelpItem
|
<HelpItem
|
||||||
helpText={helpText("mapperTypeHelp")}
|
helpText={helpText("mapperTypeHelp")}
|
||||||
forLabel={t("common:mapperType")}
|
forLabel={t("common:mapperType")}
|
||||||
forID="kc-choose-mapper-type"
|
forID="kc-providerId"
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
fieldId="kc-choose-mapper-type"
|
fieldId="kc-providerId"
|
||||||
isRequired
|
isRequired
|
||||||
>
|
>
|
||||||
<Controller
|
<Controller
|
||||||
name="choose-mapper-type"
|
name="providerId"
|
||||||
defaultValue=" "
|
defaultValue=" "
|
||||||
control={form.control}
|
control={form.control}
|
||||||
render={({ onChange, value }) => (
|
render={({ onChange, value }) => (
|
||||||
<Select
|
<Select
|
||||||
toggleId="kc-choose-mapper-type"
|
toggleId="kc-providerId"
|
||||||
required
|
required
|
||||||
onToggle={() =>
|
onToggle={() =>
|
||||||
setIsMapperDropdownOpen(!isMapperDropdownOpen)
|
setIsMapperDropdownOpen(!isMapperDropdownOpen)
|
||||||
|
@ -218,7 +231,6 @@ export const LdapMapperDetails = () => {
|
||||||
}}
|
}}
|
||||||
selections={value}
|
selections={value}
|
||||||
variant={SelectVariant.single}
|
variant={SelectVariant.single}
|
||||||
// data-testid="choose-mapper-type"
|
|
||||||
>
|
>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
key={0}
|
key={0}
|
||||||
|
@ -226,7 +238,7 @@ export const LdapMapperDetails = () => {
|
||||||
/>
|
/>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
key={1}
|
key={1}
|
||||||
value="msda-lds-user-account-control-mapper"
|
value="msad-lds-user-account-control-mapper"
|
||||||
/>
|
/>
|
||||||
<SelectOption key={2} value="group-ldap-mapper" />
|
<SelectOption key={2} value="group-ldap-mapper" />
|
||||||
<SelectOption key={3} value="user-attribute-ldap-mapper" />
|
<SelectOption key={3} value="user-attribute-ldap-mapper" />
|
||||||
|
@ -294,52 +306,52 @@ export const LdapMapperDetails = () => {
|
||||||
)
|
)
|
||||||
: ""}
|
: ""}
|
||||||
{/* When creating new mappers, load forms based on dropdown selection */}
|
{/* When creating new mappers, load forms based on dropdown selection */}
|
||||||
{mapperType
|
{isNew && mapperType
|
||||||
? mapperType === "certificate-ldap-mapper" && (
|
? mapperType === "certificate-ldap-mapper" && (
|
||||||
<LdapMapperUserAttribute form={form} mapperType={mapperType} />
|
<LdapMapperUserAttribute form={form} mapperType={mapperType} />
|
||||||
)
|
)
|
||||||
: ""}
|
: ""}
|
||||||
{mapperType
|
{isNew && mapperType
|
||||||
? mapperType === "user-attribute-ldap-mapper" && (
|
? mapperType === "user-attribute-ldap-mapper" && (
|
||||||
<LdapMapperUserAttribute form={form} mapperType={mapperType} />
|
<LdapMapperUserAttribute form={form} mapperType={mapperType} />
|
||||||
)
|
)
|
||||||
: ""}
|
: ""}
|
||||||
{mapperType
|
{isNew && mapperType
|
||||||
? mapperType === "msad-user-account-control-mapper" && (
|
? mapperType === "msad-user-account-control-mapper" && (
|
||||||
<LdapMapperMsadUserAccount form={form} />
|
<LdapMapperMsadUserAccount form={form} />
|
||||||
)
|
)
|
||||||
: ""}
|
: ""}
|
||||||
{mapperType
|
{isNew && mapperType
|
||||||
? mapperType === "full-name-ldap-mapper" && (
|
? mapperType === "full-name-ldap-mapper" && (
|
||||||
<LdapMapperFullNameAttribute form={form} />
|
<LdapMapperFullNameAttribute form={form} />
|
||||||
)
|
)
|
||||||
: ""}
|
: ""}
|
||||||
{mapperType
|
{isNew && mapperType
|
||||||
? mapperType === "hardcoded-ldap-role-mapper" && (
|
? mapperType === "hardcoded-ldap-role-mapper" && (
|
||||||
<LdapMapperHardcodedLdapRole form={form} />
|
<LdapMapperHardcodedLdapRole form={form} />
|
||||||
)
|
)
|
||||||
: ""}
|
: ""}
|
||||||
{mapperType
|
{isNew && mapperType
|
||||||
? mapperType === "hardcoded-ldap-group-mapper" && (
|
? mapperType === "hardcoded-ldap-group-mapper" && (
|
||||||
<LdapMapperHardcodedLdapGroup form={form} />
|
<LdapMapperHardcodedLdapGroup form={form} />
|
||||||
)
|
)
|
||||||
: ""}
|
: ""}
|
||||||
{mapperType
|
{isNew && mapperType
|
||||||
? mapperType === "hardcoded-ldap-attribute-mapper" && (
|
? mapperType === "hardcoded-ldap-attribute-mapper" && (
|
||||||
<LdapMapperHardcodedLdapAttribute form={form} />
|
<LdapMapperHardcodedLdapAttribute form={form} />
|
||||||
)
|
)
|
||||||
: ""}
|
: ""}
|
||||||
{mapperType
|
{isNew && mapperType
|
||||||
? mapperType === "hardcoded-attribute-mapper" && (
|
? mapperType === "hardcoded-attribute-mapper" && (
|
||||||
<LdapMapperHardcodedAttribute form={form} />
|
<LdapMapperHardcodedAttribute form={form} />
|
||||||
)
|
)
|
||||||
: ""}
|
: ""}
|
||||||
{mapperType
|
{isNew && mapperType
|
||||||
? mapperType === "role-ldap-mapper" && (
|
? mapperType === "role-ldap-mapper" && (
|
||||||
<LdapMapperRoleGroup form={form} type={mapperType} />
|
<LdapMapperRoleGroup form={form} type={mapperType} />
|
||||||
)
|
)
|
||||||
: ""}
|
: ""}
|
||||||
{mapperType
|
{isNew && mapperType
|
||||||
? mapperType === "group-ldap-mapper" && (
|
? mapperType === "group-ldap-mapper" && (
|
||||||
<LdapMapperRoleGroup form={form} type={mapperType} />
|
<LdapMapperRoleGroup form={form} type={mapperType} />
|
||||||
)
|
)
|
||||||
|
|
|
@ -221,7 +221,7 @@ export const LdapMapperRoleGroup = ({
|
||||||
>
|
>
|
||||||
<Controller
|
<Controller
|
||||||
name="config.membership-attribute-type[0]"
|
name="config.membership-attribute-type[0]"
|
||||||
defaultValue=""
|
defaultValue="DN"
|
||||||
control={form.control}
|
control={form.control}
|
||||||
render={({ onChange, value }) => (
|
render={({ onChange, value }) => (
|
||||||
<Select
|
<Select
|
||||||
|
@ -306,7 +306,7 @@ export const LdapMapperRoleGroup = ({
|
||||||
>
|
>
|
||||||
<Controller
|
<Controller
|
||||||
name="config.mode[0]"
|
name="config.mode[0]"
|
||||||
defaultValue=""
|
defaultValue="READ_ONLY"
|
||||||
control={form.control}
|
control={form.control}
|
||||||
render={({ onChange, value }) => (
|
render={({ onChange, value }) => (
|
||||||
<Select
|
<Select
|
||||||
|
@ -362,7 +362,7 @@ export const LdapMapperRoleGroup = ({
|
||||||
? "config.user-roles-retrieve-strategy[0]"
|
? "config.user-roles-retrieve-strategy[0]"
|
||||||
: "config.user-groups-retrieve-strategy[0]"
|
: "config.user-groups-retrieve-strategy[0]"
|
||||||
}
|
}
|
||||||
defaultValue=""
|
defaultValue="LOAD_ROLES_BY_MEMBER_ATTRIBUTE"
|
||||||
control={form.control}
|
control={form.control}
|
||||||
render={({ onChange, value }) => (
|
render={({ onChange, value }) => (
|
||||||
<Select
|
<Select
|
||||||
|
|
Loading…
Reference in a new issue