ldap saves working
This commit is contained in:
parent
b5f7405fce
commit
733d5f4b6f
8 changed files with 104 additions and 74 deletions
|
@ -47,6 +47,7 @@ const LdapSettingsHeader = ({
|
||||||
toggleRemoveUsersDialog,
|
toggleRemoveUsersDialog,
|
||||||
}: LdapSettingsHeaderProps) => {
|
}: LdapSettingsHeaderProps) => {
|
||||||
const { t } = useTranslation("user-federation");
|
const { t } = useTranslation("user-federation");
|
||||||
|
const { id } = useParams<{ id: string }>();
|
||||||
const [toggleDisableDialog, DisableConfirm] = useConfirmDialog({
|
const [toggleDisableDialog, DisableConfirm] = useConfirmDialog({
|
||||||
titleKey: "user-federation:userFedDisableConfirmTitle",
|
titleKey: "user-federation:userFedDisableConfirmTitle",
|
||||||
messageKey: "user-federation:userFedDisableConfirm",
|
messageKey: "user-federation:userFedDisableConfirm",
|
||||||
|
@ -59,46 +60,53 @@ const LdapSettingsHeader = ({
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DisableConfirm />
|
<DisableConfirm />
|
||||||
<ViewHeader
|
{id === "new" ? (
|
||||||
titleKey="LDAP"
|
<ViewHeader titleKey="LDAP" subKey="" />
|
||||||
subKey=""
|
) : (
|
||||||
dropdownItems={[
|
<ViewHeader
|
||||||
<DropdownItem
|
titleKey="LDAP"
|
||||||
key="sync"
|
subKey=""
|
||||||
onClick={() => console.log("Sync users TBD")}
|
dropdownItems={[
|
||||||
>
|
<DropdownItem
|
||||||
{t("syncChangedUsers")}
|
key="sync"
|
||||||
</DropdownItem>,
|
onClick={() => console.log("Sync users TBD")}
|
||||||
<DropdownItem
|
>
|
||||||
key="syncall"
|
{t("syncChangedUsers")}
|
||||||
onClick={() => console.log("Sync all users TBD")}
|
</DropdownItem>,
|
||||||
>
|
<DropdownItem
|
||||||
{t("syncAllUsers")}
|
key="syncall"
|
||||||
</DropdownItem>,
|
onClick={() => console.log("Sync all users TBD")}
|
||||||
<DropdownItem
|
>
|
||||||
key="unlink"
|
{t("syncAllUsers")}
|
||||||
onClick={() => console.log("Unlink users TBD")}
|
</DropdownItem>,
|
||||||
>
|
<DropdownItem
|
||||||
{t("unlinkUsers")}
|
key="unlink"
|
||||||
</DropdownItem>,
|
onClick={() => console.log("Unlink users TBD")}
|
||||||
<DropdownItem key="remove" onClick={() => toggleRemoveUsersDialog()}>
|
>
|
||||||
{t("removeImported")}
|
{t("unlinkUsers")}
|
||||||
</DropdownItem>,
|
</DropdownItem>,
|
||||||
<DropdownSeparator key="separator" />,
|
<DropdownItem
|
||||||
<DropdownItem key="delete" onClick={() => toggleDeleteDialog()}>
|
key="remove"
|
||||||
{t("deleteProvider")}
|
onClick={() => toggleRemoveUsersDialog()}
|
||||||
</DropdownItem>,
|
>
|
||||||
]}
|
{t("removeImported")}
|
||||||
isEnabled={value === "true"}
|
</DropdownItem>,
|
||||||
onToggle={(value) => {
|
<DropdownSeparator key="separator" />,
|
||||||
if (!value) {
|
<DropdownItem key="delete" onClick={() => toggleDeleteDialog()}>
|
||||||
toggleDisableDialog();
|
{t("deleteProvider")}
|
||||||
} else {
|
</DropdownItem>,
|
||||||
onChange("" + value);
|
]}
|
||||||
save();
|
isEnabled={value === "true"}
|
||||||
}
|
onToggle={(value) => {
|
||||||
}}
|
if (!value) {
|
||||||
/>
|
toggleDisableDialog();
|
||||||
|
} else {
|
||||||
|
onChange("" + value);
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -134,11 +142,23 @@ export const UserFederationLdapSettings = () => {
|
||||||
|
|
||||||
const save = async (component: ComponentRepresentation) => {
|
const save = async (component: ComponentRepresentation) => {
|
||||||
try {
|
try {
|
||||||
await adminClient.components.update({ id }, component);
|
if (id) {
|
||||||
|
if (id === "new") {
|
||||||
|
await adminClient.components.create(component);
|
||||||
|
} else {
|
||||||
|
await adminClient.components.update({ id }, component);
|
||||||
|
}
|
||||||
|
}
|
||||||
setupForm(component as ComponentRepresentation);
|
setupForm(component as ComponentRepresentation);
|
||||||
addAlert(t("saveSuccess"), AlertVariant.success);
|
addAlert(
|
||||||
|
t(id === "new" ? "createSuccess" : "saveSuccess"),
|
||||||
|
AlertVariant.success
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
addAlert(`${t("saveError")} '${error}'`, AlertVariant.danger);
|
addAlert(
|
||||||
|
`${t(id === "new" ? "createError" : "saveError")} '${error}'`,
|
||||||
|
AlertVariant.danger
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -179,7 +199,7 @@ export const UserFederationLdapSettings = () => {
|
||||||
<RemoveUsersConfirm />
|
<RemoveUsersConfirm />
|
||||||
<Controller
|
<Controller
|
||||||
name="config.enabled[0]"
|
name="config.enabled[0]"
|
||||||
defaultValue={["true"]}
|
defaultValue={["true"][0]}
|
||||||
control={form.control}
|
control={form.control}
|
||||||
render={({ onChange, value }) => (
|
render={({ onChange, value }) => (
|
||||||
<LdapSettingsHeader
|
<LdapSettingsHeader
|
||||||
|
|
|
@ -190,7 +190,11 @@ export const UserFederationSection = () => {
|
||||||
</Split>
|
</Split>
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
</Card>
|
</Card>
|
||||||
<Card isHoverable>
|
<Card
|
||||||
|
isHoverable
|
||||||
|
onClick={() => history.push(`${url}/ldap/new`)}
|
||||||
|
data-testid="ldap-card"
|
||||||
|
>
|
||||||
<CardTitle>
|
<CardTitle>
|
||||||
<Split hasGutter>
|
<Split hasGutter>
|
||||||
<SplitItem>
|
<SplitItem>
|
||||||
|
|
|
@ -74,7 +74,7 @@ export const LdapSettingsAdvanced = ({
|
||||||
>
|
>
|
||||||
<Controller
|
<Controller
|
||||||
name="config.validatePasswordPolicy"
|
name="config.validatePasswordPolicy"
|
||||||
defaultValue={"false"}
|
defaultValue={["false"]}
|
||||||
control={form.control}
|
control={form.control}
|
||||||
render={({ onChange, value }) => (
|
render={({ onChange, value }) => (
|
||||||
<Switch
|
<Switch
|
||||||
|
@ -103,7 +103,7 @@ export const LdapSettingsAdvanced = ({
|
||||||
>
|
>
|
||||||
<Controller
|
<Controller
|
||||||
name="config.trustEmail"
|
name="config.trustEmail"
|
||||||
defaultValue={"false"}
|
defaultValue={["false"]}
|
||||||
control={form.control}
|
control={form.control}
|
||||||
render={({ onChange, value }) => (
|
render={({ onChange, value }) => (
|
||||||
<Switch
|
<Switch
|
||||||
|
|
|
@ -167,7 +167,7 @@ export const LdapSettingsConnection = ({
|
||||||
>
|
>
|
||||||
<Controller
|
<Controller
|
||||||
name="config.connectionPooling"
|
name="config.connectionPooling"
|
||||||
defaultValue={false}
|
defaultValue={["false"]}
|
||||||
control={form.control}
|
control={form.control}
|
||||||
render={({ onChange, value }) => (
|
render={({ onChange, value }) => (
|
||||||
<Switch
|
<Switch
|
||||||
|
|
|
@ -10,6 +10,8 @@ import React, { useState } from "react";
|
||||||
import { HelpItem } from "../../components/help-enabler/HelpItem";
|
import { HelpItem } from "../../components/help-enabler/HelpItem";
|
||||||
import { UseFormMethods, Controller } from "react-hook-form";
|
import { UseFormMethods, Controller } from "react-hook-form";
|
||||||
import { FormAccess } from "../../components/form-access/FormAccess";
|
import { FormAccess } from "../../components/form-access/FormAccess";
|
||||||
|
import { useRealm } from "../../context/realm-context/RealmContext";
|
||||||
|
|
||||||
import { WizardSectionHeader } from "../../components/wizard-section-header/WizardSectionHeader";
|
import { WizardSectionHeader } from "../../components/wizard-section-header/WizardSectionHeader";
|
||||||
|
|
||||||
export type LdapSettingsGeneralProps = {
|
export type LdapSettingsGeneralProps = {
|
||||||
|
@ -25,6 +27,7 @@ export const LdapSettingsGeneral = ({
|
||||||
}: LdapSettingsGeneralProps) => {
|
}: LdapSettingsGeneralProps) => {
|
||||||
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 { realm } = useRealm();
|
||||||
|
|
||||||
const [isVendorDropdownOpen, setIsVendorDropdownOpen] = useState(false);
|
const [isVendorDropdownOpen, setIsVendorDropdownOpen] = useState(false);
|
||||||
|
|
||||||
|
@ -51,12 +54,36 @@ export const LdapSettingsGeneral = ({
|
||||||
isRequired
|
isRequired
|
||||||
>
|
>
|
||||||
{/* These hidden fields are required so data object written back matches data retrieved */}
|
{/* These hidden fields are required so data object written back matches data retrieved */}
|
||||||
<TextInput
|
{/* <TextInput
|
||||||
hidden
|
hidden
|
||||||
type="text"
|
type="text"
|
||||||
id="kc-console-id"
|
id="kc-console-id"
|
||||||
name="id"
|
name="id"
|
||||||
ref={form.register}
|
ref={form.register}
|
||||||
|
/> */}
|
||||||
|
<TextInput
|
||||||
|
hidden
|
||||||
|
type="text"
|
||||||
|
id="kc-console-provider-id"
|
||||||
|
name="providerId"
|
||||||
|
defaultValue="ldap"
|
||||||
|
ref={form.register}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
hidden
|
||||||
|
type="text"
|
||||||
|
id="kc-console-provider-type"
|
||||||
|
name="providerType"
|
||||||
|
defaultValue="org.keycloak.storage.UserStorageProvider"
|
||||||
|
ref={form.register}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
hidden
|
||||||
|
type="text"
|
||||||
|
id="kc-console-parentId"
|
||||||
|
name="parentId"
|
||||||
|
defaultValue={realm}
|
||||||
|
ref={form.register}
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
isRequired
|
isRequired
|
||||||
|
@ -70,27 +97,6 @@ export const LdapSettingsGeneral = ({
|
||||||
},
|
},
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<TextInput
|
|
||||||
hidden
|
|
||||||
type="text"
|
|
||||||
id="kc-console-provider-id"
|
|
||||||
name="providerId"
|
|
||||||
ref={form.register}
|
|
||||||
/>
|
|
||||||
<TextInput
|
|
||||||
hidden
|
|
||||||
type="text"
|
|
||||||
id="kc-console-provider-type"
|
|
||||||
name="providerType"
|
|
||||||
ref={form.register}
|
|
||||||
/>
|
|
||||||
<TextInput
|
|
||||||
hidden
|
|
||||||
type="text"
|
|
||||||
id="kc-console-parentId"
|
|
||||||
name="parentId"
|
|
||||||
ref={form.register}
|
|
||||||
/>
|
|
||||||
{form.errors.name && (
|
{form.errors.name && (
|
||||||
<div className="error">{form.errors.name.message}</div>
|
<div className="error">{form.errors.name.message}</div>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -45,7 +45,7 @@ export const LdapSettingsKerberosIntegration = ({
|
||||||
>
|
>
|
||||||
<Controller
|
<Controller
|
||||||
name="config.allowKerberosAuthentication"
|
name="config.allowKerberosAuthentication"
|
||||||
defaultValue={false}
|
defaultValue={["false"]}
|
||||||
control={form.control}
|
control={form.control}
|
||||||
render={({ onChange, value }) => (
|
render={({ onChange, value }) => (
|
||||||
<Switch
|
<Switch
|
||||||
|
@ -73,7 +73,7 @@ export const LdapSettingsKerberosIntegration = ({
|
||||||
>
|
>
|
||||||
<Controller
|
<Controller
|
||||||
name="config.useKerberosForPasswordAuthentication"
|
name="config.useKerberosForPasswordAuthentication"
|
||||||
defaultValue={false}
|
defaultValue={["false"]}
|
||||||
control={form.control}
|
control={form.control}
|
||||||
render={({ onChange, value }) => (
|
render={({ onChange, value }) => (
|
||||||
<Switch
|
<Switch
|
||||||
|
|
|
@ -332,7 +332,7 @@ export const LdapSettingsSearching = ({
|
||||||
>
|
>
|
||||||
<Controller
|
<Controller
|
||||||
name="config.pagination"
|
name="config.pagination"
|
||||||
defaultValue={false}
|
defaultValue={["false"]}
|
||||||
control={form.control}
|
control={form.control}
|
||||||
render={({ onChange, value }) => (
|
render={({ onChange, value }) => (
|
||||||
<Switch
|
<Switch
|
||||||
|
|
|
@ -44,7 +44,7 @@ export const LdapSettingsSynchronization = ({
|
||||||
>
|
>
|
||||||
<Controller
|
<Controller
|
||||||
name="config.importEnabled"
|
name="config.importEnabled"
|
||||||
defaultValue={false}
|
defaultValue={["false"]}
|
||||||
control={form.control}
|
control={form.control}
|
||||||
render={({ onChange, value }) => (
|
render={({ onChange, value }) => (
|
||||||
<Switch
|
<Switch
|
||||||
|
|
Loading…
Reference in a new issue