From 9339dbc54f1570acc564fe58df10a7fe68d02f89 Mon Sep 17 00:00:00 2001 From: mfrances Date: Thu, 15 Apr 2021 09:50:55 -0400 Subject: [PATCH] all non-role adds and saves working --- .../ldap/mappers/LdapMapperDetails.tsx | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/user-federation/ldap/mappers/LdapMapperDetails.tsx b/src/user-federation/ldap/mappers/LdapMapperDetails.tsx index 269b6861b8..c29444dc11 100644 --- a/src/user-federation/ldap/mappers/LdapMapperDetails.tsx +++ b/src/user-federation/ldap/mappers/LdapMapperDetails.tsx @@ -39,11 +39,9 @@ export const LdapMapperDetails = () => { const [mapping, setMapping] = useState(); const adminClient = useAdminClient(); - const { mapperId } = useParams<{ mapperId: string }>(); + const { id, mapperId } = useParams<{ id: string; mapperId: string }>(); const history = useHistory(); - const { realm } = useRealm(); - const id = mapperId; const { t } = useTranslation("user-federation"); const helpText = useTranslation("user-federation-help").t; const { addAlert } = useAlerts(); @@ -54,13 +52,10 @@ export const LdapMapperDetails = () => { (async () => { if (mapperId !== "new") { if (mapperId) { - const fetchedMapper = await adminClient.components.findOne({ id }); + const fetchedMapper = await adminClient.components.findOne({ + id: mapperId, + }); if (fetchedMapper) { - // TODO: remove after adding all mapper types - console.log("LdapMapperDetails: id used in findOne(id) call::"); - console.log(id); - console.log("fetchedMapper is:"); - console.log(fetchedMapper); setMapping(fetchedMapper); setupForm(fetchedMapper); } @@ -87,24 +82,24 @@ export const LdapMapperDetails = () => { const map = { ...mapper, config }; try { - if (id) { - if (id === "new") { + if (mapperId) { + if (mapperId === "new") { await adminClient.components.create(map); history.push( `/${realm}/user-federation/ldap/${mapper!.parentId}/mappers` ); } else { - await adminClient.components.update({ id }, map); + await adminClient.components.update({ id: mapperId }, map); } } setupForm(map as ComponentRepresentation); addAlert( - t(id === "new" ? "createSuccess" : "saveSuccess"), + t(mapperId === "new" ? "createSuccess" : "saveSuccess"), AlertVariant.success ); } catch (error) { addAlert( - `${t(id === "new" ? "createError" : "saveError")} '${error}'`, + `${t(mapperId === "new" ? "createError" : "saveError")} '${error}'`, AlertVariant.danger ); } @@ -160,7 +155,7 @@ export const LdapMapperDetails = () => { />