From 95ecc9ff40710404b926f57e0caacce71184f702 Mon Sep 17 00:00:00 2001 From: mfrances Date: Wed, 31 Mar 2021 10:24:00 -0400 Subject: [PATCH] adding role mapper --- .../ldap/mappers/LdapMapperRoleGroup.tsx | 392 ++++++++++++++++++ .../ldap/mappers/LdapMappingDetails.tsx | 8 + 2 files changed, 400 insertions(+) create mode 100644 src/user-federation/ldap/mappers/LdapMapperRoleGroup.tsx diff --git a/src/user-federation/ldap/mappers/LdapMapperRoleGroup.tsx b/src/user-federation/ldap/mappers/LdapMapperRoleGroup.tsx new file mode 100644 index 0000000000..ba59227cee --- /dev/null +++ b/src/user-federation/ldap/mappers/LdapMapperRoleGroup.tsx @@ -0,0 +1,392 @@ +import { + FormGroup, + Select, + SelectOption, + SelectVariant, + Switch, + TextInput, +} from "@patternfly/react-core"; +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; +}; + +export const LdapMapperRoleGroup = ({ form }: LdapMapperRoleGroupProps) => { + const { t } = useTranslation("user-federation"); + const helpText = useTranslation("user-federation-help").t; + + const [isMbAttTypeDropdownOpen, setIsMbAttTypeDropdownOpen] = useState(false); + const [isModeDropdownOpen, setIsModeDropdownOpen] = useState(false); + const [ + isRetrieveStratDropdownOpen, + setIsRetrieveStratDropdownOpen, + ] = useState(false); + const [isClientIdDropdownOpen, setIsClientIdDropdownOpen] = useState(false); + + return ( + <> + + + + + } + fieldId="kc-roles-dn" + isRequired + > + + + + + } + fieldId="kc-role-name-attribute" + isRequired + > + + + + + } + fieldId="kc-role-object-classes" + isRequired + > + + + + + } + 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-roles-retrieve-strategy" + > + ( + + )} + > + + + + } + fieldId="kc-member-of-attribute" + isRequired + > + + + + + } + fieldId="kc-user-realm-roles" + hasNoPaddingTop + > + ( + onChange([`${value}`])} + isChecked={value[0] === "true"} + label={t("common:on")} + labelOff={t("common:off")} + /> + )} + > + + + + } + fieldId="kc-client-id" + > + ( + + )} + > + + + + ); +}; diff --git a/src/user-federation/ldap/mappers/LdapMappingDetails.tsx b/src/user-federation/ldap/mappers/LdapMappingDetails.tsx index d485f12aa9..76ca4ab590 100644 --- a/src/user-federation/ldap/mappers/LdapMappingDetails.tsx +++ b/src/user-federation/ldap/mappers/LdapMappingDetails.tsx @@ -25,11 +25,14 @@ import { LdapMapperHardcodedLdapGroup } from "./LdapMapperHardcodedLdapGroup"; import { LdapMapperHardcodedLdapAttribute } from "./LdapMapperHardcodedLdapAttribute"; import { LdapMapperHardcodedAttribute } from "./LdapMapperHardcodedAttribute"; +import { LdapMapperRoleGroup } from "./LdapMapperRoleGroup"; + import { useRealm } from "../../../context/realm-context/RealmContext"; export const LdapMappingDetails = () => { const form = useForm(); const [mapper, setMapper] = useState(); + const adminClient = useAdminClient(); const { mapperId } = useParams<{ mapperId: string }>(); const history = useHistory(); @@ -126,6 +129,11 @@ export const LdapMappingDetails = () => { ) : ""} + {mapper + ? mapper.providerId! === "role-ldap-mapper" && ( + + ) + : ""}