Add id to the form (#2400)

This commit is contained in:
Erik Jan de Wit 2022-04-07 13:42:29 +02:00 committed by GitHub
parent 0f48da11e7
commit 36cf7022f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 7 deletions

View file

@ -65,7 +65,7 @@ const AddLdapFormContent = ({
]}
>
<LdapSettingsGeneral form={form} vendorEdit={!!id} />
<LdapSettingsConnection form={form} edit={!!id} />
<LdapSettingsConnection form={form} id={id} />
<LdapSettingsSearching form={form} />
<LdapSettingsSynchronization form={form} />
<LdapSettingsKerberosIntegration form={form} />

View file

@ -25,9 +25,9 @@ import { useAlerts } from "../../components/alert/Alerts";
export type LdapSettingsConnectionProps = {
form: UseFormMethods;
id?: string;
showSectionHeading?: boolean;
showSectionDescription?: boolean;
edit?: boolean;
};
const testLdapProperties: Array<keyof TestLdapConnectionRepresentation> = [
@ -50,22 +50,21 @@ const convertFormToSettings = (form: UseFormMethods) => {
settings[key] = Array.isArray(value) ? value[0] : "";
});
settings["componentId"] = get(form.getValues(), "id");
return settings;
};
export const LdapSettingsConnection = ({
form,
id,
showSectionHeading = false,
showSectionDescription = false,
edit = false,
}: LdapSettingsConnectionProps) => {
const { t } = useTranslation("user-federation");
const { t: helpText } = useTranslation("user-federation-help");
const adminClient = useAdminClient();
const { realm } = useRealm();
const { addAlert, addError } = useAlerts();
const edit = !!id;
const testLdap = async (testType: TestTypes) => {
if (!(await form.trigger())) return;
@ -73,7 +72,7 @@ export const LdapSettingsConnection = ({
const settings = convertFormToSettings(form);
await adminClient.realms.testLDAPConnection(
{ realm },
{ ...settings, action: testType }
{ ...settings, action: testType, componentId: id }
);
addAlert(t("testSuccess"), AlertVariant.success);
} catch (error) {

View file

@ -117,7 +117,6 @@ export const LdapSettingsGeneral = ({
helperTextInvalid={form.errors.name?.message}
>
{/* These hidden fields are required so data object written back matches data retrieved */}
<TextInput hidden type="text" id="kc-console-id" name="id" />
<TextInput
hidden
type="text"