diff --git a/src/route-config.ts b/src/route-config.ts
index 30b4960a3b..936c6e919a 100644
--- a/src/route-config.ts
+++ b/src/route-config.ts
@@ -226,6 +226,12 @@ export const routes: RoutesFn = (t: TFunction) => [
breadcrumb: null,
access: "view-realm",
},
+ {
+ path: "/:realm/user-federation/ldap/new",
+ component: UserFederationLdapSettings,
+ breadcrumb: t("common:settings"),
+ access: "view-realm",
+ },
{
path: "/:realm/user-federation/ldap/:id/:tab?",
component: UserFederationLdapSettings,
@@ -238,12 +244,6 @@ export const routes: RoutesFn = (t: TFunction) => [
breadcrumb: t("common:mappingDetails"),
access: "view-realm",
},
- {
- path: "/:realm/user-federation/ldap/new",
- component: UserFederationLdapSettings,
- breadcrumb: t("common:settings"),
- access: "view-realm",
- },
{
path: "/:realm/",
component: DashboardSection,
diff --git a/src/user-federation/ldap/mappers/LdapMapperFullNameAttribute.tsx b/src/user-federation/ldap/mappers/LdapMapperFullNameAttribute.tsx
index 458a0f2dee..356eab95de 100644
--- a/src/user-federation/ldap/mappers/LdapMapperFullNameAttribute.tsx
+++ b/src/user-federation/ldap/mappers/LdapMapperFullNameAttribute.tsx
@@ -2,9 +2,7 @@ import { FormGroup, Switch, TextInput } from "@patternfly/react-core";
import React from "react";
import { HelpItem } from "../../../components/help-enabler/HelpItem";
import { Controller, UseFormMethods } from "react-hook-form";
-import { FormAccess } from "../../../components/form-access/FormAccess";
import { useTranslation } from "react-i18next";
-import { LdapMapperGeneral } from "./shared/LdapMapperGeneral";
export type LdapMapperFullNameAttributeProps = {
form: UseFormMethods;
@@ -18,87 +16,83 @@ export const LdapMapperFullNameAttribute = ({
return (
<>
-
-
-
-
- }
- fieldId="kc-full-name-attribute"
- isRequired
- >
-
-
-
+
+
+
+ }
+ fieldId="kc-read-only"
+ hasNoPaddingTop
+ >
+ (
+ onChange([`${value}`])}
+ isChecked={value[0] === "true"}
+ label={t("common:on")}
+ labelOff={t("common:off")}
/>
- }
- fieldId="kc-read-only"
- hasNoPaddingTop
- >
- (
- onChange([`${value}`])}
- isChecked={value[0] === "true"}
- label={t("common:on")}
- labelOff={t("common:off")}
- />
- )}
- >
-
-
+
+
+ }
+ fieldId="kc-read-only"
+ hasNoPaddingTop
+ >
+ (
+ onChange([`${value}`])}
+ isChecked={value[0] === "true"}
+ label={t("common:on")}
+ labelOff={t("common:off")}
/>
- }
- fieldId="kc-read-only"
- hasNoPaddingTop
- >
- (
- onChange([`${value}`])}
- isChecked={value[0] === "true"}
- label={t("common:on")}
- labelOff={t("common:off")}
- />
- )}
- >
-
-
+ )}
+ >
+
>
);
};
diff --git a/src/user-federation/ldap/mappers/LdapMapperHardcodedAttribute.tsx b/src/user-federation/ldap/mappers/LdapMapperHardcodedAttribute.tsx
index e71c13adfd..52a65008f3 100644
--- a/src/user-federation/ldap/mappers/LdapMapperHardcodedAttribute.tsx
+++ b/src/user-federation/ldap/mappers/LdapMapperHardcodedAttribute.tsx
@@ -2,9 +2,7 @@ import { FormGroup, TextInput } from "@patternfly/react-core";
import React from "react";
import { HelpItem } from "../../../components/help-enabler/HelpItem";
import { UseFormMethods } from "react-hook-form";
-import { FormAccess } from "../../../components/form-access/FormAccess";
import { useTranslation } from "react-i18next";
-import { LdapMapperGeneral } from "./shared/LdapMapperGeneral";
export type LdapMapperHardcodedAttributeProps = {
form: UseFormMethods;
@@ -18,51 +16,48 @@ export const LdapMapperHardcodedAttribute = ({
return (
<>
-
-
-
- }
- fieldId="kc-user-model-attribute"
- isRequired
- >
-
-
-
- }
- fieldId="kc-attribute-value"
+ }
+ fieldId="kc-user-model-attribute"
+ isRequired
+ >
+
-
+
+
-
-
+ }
+ fieldId="kc-attribute-value"
+ isRequired
+ >
+
+
>
);
};
diff --git a/src/user-federation/ldap/mappers/LdapMapperHardcodedLdapAttribute.tsx b/src/user-federation/ldap/mappers/LdapMapperHardcodedLdapAttribute.tsx
index e1b786592e..af23e34e28 100644
--- a/src/user-federation/ldap/mappers/LdapMapperHardcodedLdapAttribute.tsx
+++ b/src/user-federation/ldap/mappers/LdapMapperHardcodedLdapAttribute.tsx
@@ -2,9 +2,7 @@ import { FormGroup, TextInput } from "@patternfly/react-core";
import React from "react";
import { HelpItem } from "../../../components/help-enabler/HelpItem";
import { UseFormMethods } from "react-hook-form";
-import { FormAccess } from "../../../components/form-access/FormAccess";
import { useTranslation } from "react-i18next";
-import { LdapMapperGeneral } from "./shared/LdapMapperGeneral";
export type LdapMapperHardcodedLdapAttributeProps = {
form: UseFormMethods;
@@ -18,52 +16,48 @@ export const LdapMapperHardcodedLdapAttribute = ({
return (
<>
-
-
-
-
- }
- fieldId="kc-ldap-attribute-name"
- isRequired
- >
-
-
-
- }
- fieldId="kc-ldap-attribute-value"
+ }
+ fieldId="kc-ldap-attribute-name"
+ isRequired
+ >
+
-
+
+
-
-
+ }
+ fieldId="kc-ldap-attribute-value"
+ isRequired
+ >
+
+
>
);
};
diff --git a/src/user-federation/ldap/mappers/LdapMapperHardcodedLdapGroup.tsx b/src/user-federation/ldap/mappers/LdapMapperHardcodedLdapGroup.tsx
index f6c3b3893e..15f3b76539 100644
--- a/src/user-federation/ldap/mappers/LdapMapperHardcodedLdapGroup.tsx
+++ b/src/user-federation/ldap/mappers/LdapMapperHardcodedLdapGroup.tsx
@@ -2,9 +2,7 @@ import { FormGroup, TextInput } from "@patternfly/react-core";
import React from "react";
import { HelpItem } from "../../../components/help-enabler/HelpItem";
import { UseFormMethods } from "react-hook-form";
-import { FormAccess } from "../../../components/form-access/FormAccess";
import { useTranslation } from "react-i18next";
-import { LdapMapperGeneral } from "./shared/LdapMapperGeneral";
export type LdapMapperHardcodedLdapGroupProps = {
form: UseFormMethods;
@@ -18,30 +16,27 @@ export const LdapMapperHardcodedLdapGroup = ({
return (
<>
-
-
-
- }
- fieldId="kc-group"
- isRequired
- >
-
-
-
+ }
+ fieldId="kc-group"
+ isRequired
+ >
+
+
>
);
};
diff --git a/src/user-federation/ldap/mappers/LdapMapperHardcodedLdapRole.tsx b/src/user-federation/ldap/mappers/LdapMapperHardcodedLdapRole.tsx
index 9bcf71d85c..e3999bc6c2 100644
--- a/src/user-federation/ldap/mappers/LdapMapperHardcodedLdapRole.tsx
+++ b/src/user-federation/ldap/mappers/LdapMapperHardcodedLdapRole.tsx
@@ -2,9 +2,7 @@ import { FormGroup, TextInput } from "@patternfly/react-core";
import React from "react";
import { HelpItem } from "../../../components/help-enabler/HelpItem";
import { UseFormMethods } from "react-hook-form";
-import { FormAccess } from "../../../components/form-access/FormAccess";
import { useTranslation } from "react-i18next";
-import { LdapMapperGeneral } from "./shared/LdapMapperGeneral";
export type LdapMapperHardcodedLdapRoleProps = {
form: UseFormMethods;
@@ -18,30 +16,27 @@ export const LdapMapperHardcodedLdapRole = ({
return (
<>
-
-
-
- }
- fieldId="kc-role"
- isRequired
- >
-
-
-
+ }
+ fieldId="kc-role"
+ isRequired
+ >
+
+
>
);
};
diff --git a/src/user-federation/ldap/mappers/LdapMapperList.tsx b/src/user-federation/ldap/mappers/LdapMapperList.tsx
index c2b9a1a09d..0ab2202aa0 100644
--- a/src/user-federation/ldap/mappers/LdapMapperList.tsx
+++ b/src/user-federation/ldap/mappers/LdapMapperList.tsx
@@ -10,20 +10,17 @@ import {
useAdminClient,
asyncStateFetch,
} from "../../../context/auth/AdminClient";
-import { Link, useParams, useRouteMatch } from "react-router-dom";
+import { Link, useHistory, useParams, useRouteMatch } from "react-router-dom";
export const LdapMapperList = () => {
const [mappers, setMappers] = useState();
-
+ const history = useHistory();
const { t } = useTranslation("user-federation");
const adminClient = useAdminClient();
const { addAlert } = useAlerts();
-
const { url } = useRouteMatch();
-
const handleError = useErrorHandler();
const [key, setKey] = useState(0);
-
const { id } = useParams<{ id: string }>();
useEffect(() => {
@@ -95,13 +92,7 @@ export const LdapMapperList = () => {
diff --git a/src/user-federation/ldap/mappers/LdapMapperMsadLdsUserAccount.tsx b/src/user-federation/ldap/mappers/LdapMapperMsadLdsUserAccount.tsx
deleted file mode 100644
index b1ad0a2c82..0000000000
--- a/src/user-federation/ldap/mappers/LdapMapperMsadLdsUserAccount.tsx
+++ /dev/null
@@ -1,20 +0,0 @@
-import React from "react";
-import { UseFormMethods } from "react-hook-form";
-import { FormAccess } from "../../../components/form-access/FormAccess";
-import { LdapMapperGeneral } from "./shared/LdapMapperGeneral";
-
-export type LdapMapperMsadLdsUserAccountProps = {
- form: UseFormMethods;
-};
-
-export const LdapMapperMsadLdsUserAccount = ({
- form,
-}: LdapMapperMsadLdsUserAccountProps) => {
- return (
- <>
-
-
-
- >
- );
-};
diff --git a/src/user-federation/ldap/mappers/LdapMapperMsadUserAccount.tsx b/src/user-federation/ldap/mappers/LdapMapperMsadUserAccount.tsx
index de4d9e3d26..d13b9d2a07 100644
--- a/src/user-federation/ldap/mappers/LdapMapperMsadUserAccount.tsx
+++ b/src/user-federation/ldap/mappers/LdapMapperMsadUserAccount.tsx
@@ -2,9 +2,7 @@ import { FormGroup, Switch } from "@patternfly/react-core";
import React from "react";
import { HelpItem } from "../../../components/help-enabler/HelpItem";
import { Controller, UseFormMethods } from "react-hook-form";
-import { FormAccess } from "../../../components/form-access/FormAccess";
import { useTranslation } from "react-i18next";
-import { LdapMapperGeneral } from "./shared/LdapMapperGeneral";
export type LdapMapperMsadUserAccountProps = {
form: UseFormMethods;
@@ -18,37 +16,34 @@ export const LdapMapperMsadUserAccount = ({
return (
<>
-
-
-
+ }
+ fieldId="kc-der-formatted"
+ hasNoPaddingTop
+ >
+ (
+ onChange([`${value}`])}
+ isChecked={value[0] === "true"}
+ label={t("common:on")}
+ labelOff={t("common:off")}
/>
- }
- fieldId="kc-der-formatted"
- hasNoPaddingTop
- >
- (
- onChange([`${value}`])}
- isChecked={value[0] === "true"}
- label={t("common:on")}
- labelOff={t("common:off")}
- />
- )}
- >
-
-
+ )}
+ >
+
>
);
};
diff --git a/src/user-federation/ldap/mappers/LdapMapperRoleGroup.tsx b/src/user-federation/ldap/mappers/LdapMapperRoleGroup.tsx
index 9899bfd9ae..f8e437a74f 100644
--- a/src/user-federation/ldap/mappers/LdapMapperRoleGroup.tsx
+++ b/src/user-federation/ldap/mappers/LdapMapperRoleGroup.tsx
@@ -9,9 +9,7 @@ import {
import React, { useState } from "react";
import { HelpItem } from "../../../components/help-enabler/HelpItem";
import { Controller, UseFormMethods } from "react-hook-form";
-import { FormAccess } from "../../../components/form-access/FormAccess";
import { useTranslation } from "react-i18next";
-import { LdapMapperGeneral } from "./shared/LdapMapperGeneral";
export type LdapMapperRoleGroupProps = {
form: UseFormMethods;
@@ -42,530 +40,525 @@ export const LdapMapperRoleGroup = ({
return (
<>
-
-
-
- }
- fieldId="kc-ldap-dn"
- isRequired
- >
-
-
-
- }
- fieldId="kc-name-attribute"
- isRequired
- >
-
-
-
- }
- fieldId="kc-object-classes"
+ }
+ fieldId="kc-ldap-dn"
+ isRequired
+ >
+
-
+
+
-
- {!isRole && (
- <>
-
- }
- fieldId="kc-preserve-inheritance"
- hasNoPaddingTop
- >
- (
- onChange([`${value}`])}
- isChecked={value[0] === "true"}
- label={t("common:on")}
- labelOff={t("common:off")}
- />
- )}
- >
-
-
- }
- fieldId="kc-ignore-missing"
- hasNoPaddingTop
- >
- (
- onChange([`${value}`])}
- isChecked={value[0] === "true"}
- label={t("common:on")}
- labelOff={t("common:off")}
- />
- )}
- >
-
- >
- )}
-
- }
- fieldId="kc-membership-ldap-attribute"
+ }
+ fieldId="kc-name-attribute"
+ isRequired
+ >
+
-
-
-
- }
- fieldId="kc-membership-attribute-type"
- >
- (
-
- )}
- >
-
-
- }
- fieldId="kc-membership-user-ldap-attribute"
- isRequired
- >
-
-
-
- }
- fieldId="kc-ldap-filter"
- isRequired
- >
-
-
-
- }
- fieldId="kc-mode"
- >
- (
-
- )}
- >
-
-
- }
- fieldId="kc-user-retrieve-strategy"
- >
-
+
+ (
-
- )}
- >
-
-
- }
- fieldId="kc-member-of-attribute"
- isRequired
- >
-
-
- {isRole && (
- <>
-
- }
- fieldId="kc-use-realm-roles"
- hasNoPaddingTop
- >
- (
- onChange([`${value}`])}
- isChecked={value[0] === "true"}
- label={t("common:on")}
- labelOff={t("common:off")}
- />
- )}
- >
-
-
- }
- fieldId="kc-client-id"
- >
- (
-
- )}
- >
-
- >
- )}
- {!isRole && (
- <>
-
- }
- fieldId="kc-mapped-attributes"
- isRequired
- >
-
+
+
+ {!isRole && (
+ <>
+
-
-
+ (
+ onChange([`${value}`])}
+ isChecked={value[0] === "true"}
+ label={t("common:on")}
+ labelOff={t("common:off")}
/>
- }
- fieldId="kc-drop-nonexisting"
- hasNoPaddingTop
- >
- (
- onChange([`${value}`])}
- isChecked={value[0] === "true"}
- label={t("common:on")}
- labelOff={t("common:off")}
- />
- )}
- >
-
-
- }
- fieldId="kc-path"
- isRequired
- >
-
+
+
-
- >
- )}
-
+ }
+ fieldId="kc-ignore-missing"
+ hasNoPaddingTop
+ >
+ (
+ onChange([`${value}`])}
+ isChecked={value[0] === "true"}
+ label={t("common:on")}
+ labelOff={t("common:off")}
+ />
+ )}
+ >
+
+ >
+ )}
+
+ }
+ fieldId="kc-membership-ldap-attribute"
+ isRequired
+ >
+
+
+
+ }
+ fieldId="kc-membership-attribute-type"
+ >
+ (
+
+ )}
+ >
+
+
+ }
+ fieldId="kc-membership-user-ldap-attribute"
+ isRequired
+ >
+
+
+
+ }
+ fieldId="kc-ldap-filter"
+ isRequired
+ >
+
+
+
+ }
+ fieldId="kc-mode"
+ >
+ (
+
+ )}
+ >
+
+
+ }
+ fieldId="kc-user-retrieve-strategy"
+ >
+ (
+
+ )}
+ >
+
+
+ }
+ fieldId="kc-member-of-attribute"
+ isRequired
+ >
+
+
+ {isRole && (
+ <>
+
+ }
+ fieldId="kc-use-realm-roles"
+ hasNoPaddingTop
+ >
+ (
+ onChange([`${value}`])}
+ isChecked={value[0] === "true"}
+ label={t("common:on")}
+ labelOff={t("common:off")}
+ />
+ )}
+ >
+
+
+ }
+ fieldId="kc-client-id"
+ >
+ (
+
+ )}
+ >
+
+ >
+ )}
+ {!isRole && (
+ <>
+
+ }
+ fieldId="kc-mapped-attributes"
+ isRequired
+ >
+
+
+
+ }
+ fieldId="kc-drop-nonexisting"
+ hasNoPaddingTop
+ >
+ (
+ onChange([`${value}`])}
+ isChecked={value[0] === "true"}
+ label={t("common:on")}
+ labelOff={t("common:off")}
+ />
+ )}
+ >
+
+
+ }
+ fieldId="kc-path"
+ isRequired
+ >
+
+
+ >
+ )}
>
);
};
diff --git a/src/user-federation/ldap/mappers/LdapMapperUserAttribute.tsx b/src/user-federation/ldap/mappers/LdapMapperUserAttribute.tsx
index 31f11198d1..4e7307afb6 100644
--- a/src/user-federation/ldap/mappers/LdapMapperUserAttribute.tsx
+++ b/src/user-federation/ldap/mappers/LdapMapperUserAttribute.tsx
@@ -2,9 +2,7 @@ import { FormGroup, Switch, TextInput } from "@patternfly/react-core";
import React from "react";
import { HelpItem } from "../../../components/help-enabler/HelpItem";
import { Controller, UseFormMethods } from "react-hook-form";
-import { FormAccess } from "../../../components/form-access/FormAccess";
import { useTranslation } from "react-i18next";
-import { LdapMapperGeneral } from "./shared/LdapMapperGeneral";
export type LdapMapperUserAttributeProps = {
form: UseFormMethods;
@@ -20,197 +18,194 @@ export const LdapMapperUserAttribute = ({
return (
<>
-
-
-
- }
- fieldId="kc-user-model-attribute"
- isRequired
- >
-
-
-
- }
- fieldId="kc-ldap-attribute"
+ }
+ fieldId="kc-user-model-attribute"
+ isRequired
+ >
+
-
+
+
-
-
+
+
+
+ }
+ fieldId="kc-read-only"
+ hasNoPaddingTop
+ >
+ (
+ onChange([`${value}`])}
+ isChecked={value[0] === "true"}
+ label={t("common:on")}
+ labelOff={t("common:off")}
/>
- }
- fieldId="kc-read-only"
- hasNoPaddingTop
- >
- (
- onChange([`${value}`])}
- isChecked={value[0] === "true"}
- label={t("common:on")}
- labelOff={t("common:off")}
- />
- )}
- >
-
-
+
+
+ }
+ fieldId="kc-always-read-value"
+ hasNoPaddingTop
+ >
+ (
+ onChange([`${value}`])}
+ isChecked={value[0] === "true"}
+ label={t("common:on")}
+ labelOff={t("common:off")}
/>
- }
- fieldId="kc-always-read-value"
- hasNoPaddingTop
- >
- (
- onChange([`${value}`])}
- isChecked={value[0] === "true"}
- label={t("common:on")}
- labelOff={t("common:off")}
- />
- )}
- >
-
-
+
+
+ }
+ fieldId="kc-is-mandatory"
+ hasNoPaddingTop
+ >
+ (
+ onChange([`${value}`])}
+ isChecked={value[0] === "true"}
+ label={t("common:on")}
+ labelOff={t("common:off")}
/>
- }
- fieldId="kc-is-mandatory"
- hasNoPaddingTop
- >
- (
- onChange([`${value}`])}
- isChecked={value[0] === "true"}
- label={t("common:on")}
- labelOff={t("common:off")}
- />
- )}
- >
-
-
+
+
+ }
+ fieldId="kc-is-binary"
+ hasNoPaddingTop
+ >
+ (
+ onChange([`${value}`])}
+ isChecked={value[0] === "true"}
+ label={t("common:on")}
+ labelOff={t("common:off")}
/>
- }
- fieldId="kc-is-binary"
- hasNoPaddingTop
- >
- (
- onChange([`${value}`])}
- isChecked={value[0] === "true"}
- label={t("common:on")}
- labelOff={t("common:off")}
+ )}
+ >
+
+ {mapperType === "certificate-ldap-mapper" ? (
+ <>
+
- )}
- >
-
- {mapperType === "certificate-ldap-mapper" ? (
- <>
-
+ (
+ onChange([`${value}`])}
+ isChecked={value[0] === "true"}
+ label={t("common:on")}
+ labelOff={t("common:off")}
/>
- }
- fieldId="kc-der-formatted"
- hasNoPaddingTop
- >
- (
- onChange([`${value}`])}
- isChecked={value[0] === "true"}
- label={t("common:on")}
- labelOff={t("common:off")}
- />
- )}
- >
-
- >
- ) : (
- <>>
- )}
-
+ )}
+ >
+
+ >
+ ) : (
+ <>>
+ )}
>
);
};
diff --git a/src/user-federation/ldap/mappers/LdapMappingDetails.tsx b/src/user-federation/ldap/mappers/LdapMappingDetails.tsx
index 8f6e6d1d72..178d16bed7 100644
--- a/src/user-federation/ldap/mappers/LdapMappingDetails.tsx
+++ b/src/user-federation/ldap/mappers/LdapMappingDetails.tsx
@@ -4,20 +4,26 @@ import {
AlertVariant,
Button,
Form,
+ FormGroup,
PageSection,
+ Select,
+ SelectOption,
+ SelectVariant,
+ TextInput,
} from "@patternfly/react-core";
import { convertToFormValues } from "../../../util";
import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation";
import { useAdminClient } from "../../../context/auth/AdminClient";
import { ViewHeader } from "../../../components/view-header/ViewHeader";
import { useHistory, useParams } from "react-router-dom";
-import { useForm } from "react-hook-form";
+import { Controller, useForm, useWatch } from "react-hook-form";
import { useAlerts } from "../../../components/alert/Alerts";
import { useTranslation } from "react-i18next";
+import { HelpItem } from "../../../components/help-enabler/HelpItem";
+import { FormAccess } from "../../../components/form-access/FormAccess";
import { LdapMapperUserAttribute } from "./LdapMapperUserAttribute";
import { LdapMapperMsadUserAccount } from "./LdapMapperMsadUserAccount";
-import { LdapMapperMsadLdsUserAccount } from "./LdapMapperMsadLdsUserAccount";
import { LdapMapperFullNameAttribute } from "./LdapMapperFullNameAttribute";
import { LdapMapperHardcodedLdapRole } from "./LdapMapperHardcodedLdapRole";
@@ -26,7 +32,6 @@ import { LdapMapperHardcodedLdapAttribute } from "./LdapMapperHardcodedLdapAttri
import { LdapMapperHardcodedAttribute } from "./LdapMapperHardcodedAttribute";
import { LdapMapperRoleGroup } from "./LdapMapperRoleGroup";
-
import { useRealm } from "../../../context/realm-context/RealmContext";
export const LdapMappingDetails = () => {
@@ -40,20 +45,25 @@ export const LdapMappingDetails = () => {
const { realm } = useRealm();
const id = mapperId;
const { t } = useTranslation("user-federation");
+ const helpText = useTranslation("user-federation-help").t;
const { addAlert } = useAlerts();
+ const [isMapperDropdownOpen, setIsMapperDropdownOpen] = useState(false);
+
useEffect(() => {
(async () => {
- if (mapperId) {
- const fetchedMapper = await adminClient.components.findOne({ id });
- if (fetchedMapper) {
- // TODO: remove after adding all mapper types
- console.log("LdapMappingDetails: id used in findOne(id) call::");
- console.log(id);
- console.log("LdapMappingDetails: data returned from findOne(id):");
- console.log(fetchedMapper);
- setMapper(fetchedMapper);
- setupForm(fetchedMapper);
+ if (mapperId !== "new") {
+ if (mapperId) {
+ const fetchedMapper = await adminClient.components.findOne({ id });
+ if (fetchedMapper) {
+ // TODO: remove after adding all mapper types
+ console.log("LdapMappingDetails: id used in findOne(id) call::");
+ console.log(id);
+ console.log("LdapMappingDetails: data returned from findOne(id):");
+ console.log(fetchedMapper);
+ setMapper(fetchedMapper);
+ setupForm(fetchedMapper);
+ }
}
}
})();
@@ -78,63 +88,240 @@ export const LdapMappingDetails = () => {
),
AlertVariant.success
);
- history.push(`/${realm}/user-federation`);
+ history.push(`/${realm}/user-federation/ldap/${mapper!.parentId}/mappers`);
};
+ const mapperType = useWatch({
+ control: form.control,
+ name: "choose-mapper-type",
+ });
+
+ const isNew = mapperId === "new";
+
return (
<>
-
+
- {mapper
- ? (mapper.providerId! === "certificate-ldap-mapper" ||
- mapper.providerId! === "user-attribute-ldap-mapper") && (
-
+ {!isNew && (
+
+
- )
- : ""}
- {mapper
- ? mapper.providerId! === "msad-user-account-control-mapper" && (
-
- )
- : ""}
- {mapper
- ? mapper.providerId! === "msad-lds-user-account-control-mapper" && (
-
- )
- : ""}
- {mapper
- ? mapper.providerId! === "full-name-ldap-mapper" && (
-
- )
- : ""}
- {mapper
- ? mapper.providerId! === "hardcoded-ldap-role-mapper" && (
-
- )
- : ""}
- {mapper
- ? mapper.providerId! === "hardcoded-ldap-group-mapper" && (
-
- )
- : ""}
- {mapper
- ? mapper.providerId! === "hardcoded-ldap-attribute-mapper" && (
-
- )
- : ""}
- {mapper
- ? mapper.providerId! === "hardcoded-attribute-mapper" && (
-
- )
- : ""}
- {mapper
- ? (mapper.providerId! === "role-ldap-mapper" ||
- mapper.providerId! === "group-ldap-mapper") && (
-
- )
- : ""}
+
+ )}
+
+ }
+ fieldId="kc-ldap-mapper-name"
+ isRequired
+ >
+
+
+ {!isNew ? (
+
+ }
+ fieldId="kc-ldap-mapper-type"
+ isRequired
+ >
+
+
+ ) : (
+
+ }
+ fieldId="kc-choose-mapper-type"
+ isRequired
+ >
+ (
+
+ )}
+ >
+
+ )}
+ {/* When loading existing mappers, load forms based on providerId aka mapper type */}
+ {mapper
+ ? (mapper.providerId! === "certificate-ldap-mapper" ||
+ mapper.providerId! === "user-attribute-ldap-mapper") && (
+
+ )
+ : ""}
+ {mapper
+ ? mapper.providerId! === "msad-user-account-control-mapper" && (
+
+ )
+ : ""}
+ {/* msad-lds-user-account-control-mapper does not need a component
+ because it is just id, name, and mapper type*/}
+ {mapper
+ ? mapper.providerId! === "full-name-ldap-mapper" && (
+
+ )
+ : ""}
+ {mapper
+ ? mapper.providerId! === "hardcoded-ldap-role-mapper" && (
+
+ )
+ : ""}
+ {mapper
+ ? mapper.providerId! === "hardcoded-ldap-group-mapper" && (
+
+ )
+ : ""}
+ {mapper
+ ? mapper.providerId! === "hardcoded-ldap-attribute-mapper" && (
+
+ )
+ : ""}
+ {mapper
+ ? mapper.providerId! === "hardcoded-attribute-mapper" && (
+
+ )
+ : ""}
+ {mapper
+ ? (mapper.providerId! === "role-ldap-mapper" ||
+ mapper.providerId! === "group-ldap-mapper") && (
+
+ )
+ : ""}
+ {/* When creating new mappers, load forms based on dropdown selection */}
+ {mapperType
+ ? mapperType === "certificate-ldap-mapper" && (
+
+ )
+ : ""}
+ {mapperType
+ ? mapperType === "user-attribute-ldap-mapper" && (
+
+ )
+ : ""}
+ {mapperType
+ ? mapperType === "msad-user-account-control-mapper" && (
+
+ )
+ : ""}
+ {mapperType
+ ? mapperType === "full-name-ldap-mapper" && (
+
+ )
+ : ""}
+ {mapperType
+ ? mapperType === "hardcoded-ldap-role-mapper" && (
+
+ )
+ : ""}
+ {mapperType
+ ? mapperType === "hardcoded-ldap-group-mapper" && (
+
+ )
+ : ""}
+ {mapperType
+ ? mapperType === "hardcoded-ldap-attribute-mapper" && (
+
+ )
+ : ""}
+ {mapperType
+ ? mapperType === "hardcoded-attribute-mapper" && (
+
+ )
+ : ""}
+ {mapperType
+ ? mapperType === "role-ldap-mapper" && (
+
+ )
+ : ""}
+ {mapperType
+ ? mapperType === "group-ldap-mapper" && (
+
+ )
+ : ""}
+
+