all non-role adds and saves working
This commit is contained in:
parent
775dd5c00b
commit
9339dbc54f
1 changed files with 11 additions and 16 deletions
|
@ -39,11 +39,9 @@ export const LdapMapperDetails = () => {
|
||||||
const [mapping, setMapping] = useState<ComponentRepresentation>();
|
const [mapping, setMapping] = useState<ComponentRepresentation>();
|
||||||
|
|
||||||
const adminClient = useAdminClient();
|
const adminClient = useAdminClient();
|
||||||
const { mapperId } = useParams<{ mapperId: string }>();
|
const { id, mapperId } = useParams<{ id: string; mapperId: string }>();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
const id = mapperId;
|
|
||||||
const { t } = useTranslation("user-federation");
|
const { t } = useTranslation("user-federation");
|
||||||
const helpText = useTranslation("user-federation-help").t;
|
const helpText = useTranslation("user-federation-help").t;
|
||||||
const { addAlert } = useAlerts();
|
const { addAlert } = useAlerts();
|
||||||
|
@ -54,13 +52,10 @@ export const LdapMapperDetails = () => {
|
||||||
(async () => {
|
(async () => {
|
||||||
if (mapperId !== "new") {
|
if (mapperId !== "new") {
|
||||||
if (mapperId) {
|
if (mapperId) {
|
||||||
const fetchedMapper = await adminClient.components.findOne({ id });
|
const fetchedMapper = await adminClient.components.findOne({
|
||||||
|
id: mapperId,
|
||||||
|
});
|
||||||
if (fetchedMapper) {
|
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);
|
setMapping(fetchedMapper);
|
||||||
setupForm(fetchedMapper);
|
setupForm(fetchedMapper);
|
||||||
}
|
}
|
||||||
|
@ -87,24 +82,24 @@ export const LdapMapperDetails = () => {
|
||||||
const map = { ...mapper, config };
|
const map = { ...mapper, config };
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (id) {
|
if (mapperId) {
|
||||||
if (id === "new") {
|
if (mapperId === "new") {
|
||||||
await adminClient.components.create(map);
|
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 {
|
||||||
await adminClient.components.update({ id }, map);
|
await adminClient.components.update({ id: mapperId }, map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setupForm(map as ComponentRepresentation);
|
setupForm(map as ComponentRepresentation);
|
||||||
addAlert(
|
addAlert(
|
||||||
t(id === "new" ? "createSuccess" : "saveSuccess"),
|
t(mapperId === "new" ? "createSuccess" : "saveSuccess"),
|
||||||
AlertVariant.success
|
AlertVariant.success
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
addAlert(
|
addAlert(
|
||||||
`${t(id === "new" ? "createError" : "saveError")} '${error}'`,
|
`${t(mapperId === "new" ? "createError" : "saveError")} '${error}'`,
|
||||||
AlertVariant.danger
|
AlertVariant.danger
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -160,7 +155,7 @@ export const LdapMapperDetails = () => {
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
hidden
|
hidden
|
||||||
defaultValue="aa508e29-b5e7-49d0-89ce-f3e65c5e8165"
|
defaultValue={isNew ? id : mapping ? mapping.parentId : ""}
|
||||||
type="text"
|
type="text"
|
||||||
id="kc-ldap-parentId"
|
id="kc-ldap-parentId"
|
||||||
data-testid="ldap-parentId"
|
data-testid="ldap-parentId"
|
||||||
|
@ -358,7 +353,7 @@ export const LdapMapperDetails = () => {
|
||||||
: ""}
|
: ""}
|
||||||
</FormAccess>
|
</FormAccess>
|
||||||
|
|
||||||
<Form onSubmit={form.handleSubmit(save)}>
|
<Form onSubmit={form.handleSubmit(() => save(form.getValues()))}>
|
||||||
<ActionGroup>
|
<ActionGroup>
|
||||||
<Button
|
<Button
|
||||||
isDisabled={!form.formState.isDirty}
|
isDisabled={!form.formState.isDirty}
|
||||||
|
|
Loading…
Reference in a new issue