2020-11-25 14:50:40 +00:00
|
|
|
import {
|
|
|
|
FormGroup,
|
|
|
|
Select,
|
|
|
|
SelectOption,
|
|
|
|
SelectVariant,
|
|
|
|
TextInput,
|
|
|
|
} from "@patternfly/react-core";
|
2020-10-30 20:15:37 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
2021-01-26 01:41:14 +00:00
|
|
|
import React, { useState } from "react";
|
2020-12-16 07:02:41 +00:00
|
|
|
import { HelpItem } from "../../components/help-enabler/HelpItem";
|
2021-01-26 01:41:14 +00:00
|
|
|
import { UseFormMethods, Controller } from "react-hook-form";
|
2020-12-16 07:02:41 +00:00
|
|
|
import { FormAccess } from "../../components/form-access/FormAccess";
|
2021-02-19 23:13:07 +00:00
|
|
|
import { useRealm } from "../../context/realm-context/RealmContext";
|
|
|
|
|
2021-01-04 21:33:18 +00:00
|
|
|
import { WizardSectionHeader } from "../../components/wizard-section-header/WizardSectionHeader";
|
2020-10-30 20:15:37 +00:00
|
|
|
|
2021-01-04 21:33:18 +00:00
|
|
|
export type LdapSettingsGeneralProps = {
|
2021-01-26 01:41:14 +00:00
|
|
|
form: UseFormMethods;
|
2021-01-04 21:33:18 +00:00
|
|
|
showSectionHeading?: boolean;
|
|
|
|
showSectionDescription?: boolean;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const LdapSettingsGeneral = ({
|
2021-01-26 01:41:14 +00:00
|
|
|
form,
|
2021-01-04 21:33:18 +00:00
|
|
|
showSectionHeading = false,
|
|
|
|
showSectionDescription = false,
|
|
|
|
}: LdapSettingsGeneralProps) => {
|
2020-10-30 20:15:37 +00:00
|
|
|
const { t } = useTranslation("user-federation");
|
|
|
|
const helpText = useTranslation("user-federation-help").t;
|
2021-02-19 23:13:07 +00:00
|
|
|
const { realm } = useRealm();
|
2020-12-16 07:02:41 +00:00
|
|
|
|
2021-01-26 01:41:14 +00:00
|
|
|
const [isVendorDropdownOpen, setIsVendorDropdownOpen] = useState(false);
|
2020-11-25 14:50:40 +00:00
|
|
|
|
2020-10-30 20:15:37 +00:00
|
|
|
return (
|
|
|
|
<>
|
2021-01-04 21:33:18 +00:00
|
|
|
{showSectionHeading && (
|
|
|
|
<WizardSectionHeader
|
|
|
|
title={t("generalOptions")}
|
|
|
|
description={helpText("ldapGeneralOptionsSettingsDescription")}
|
|
|
|
showDescription={showSectionDescription}
|
|
|
|
/>
|
|
|
|
)}
|
2020-11-25 16:17:50 +00:00
|
|
|
<FormAccess role="manage-realm" isHorizontal>
|
2020-10-30 20:15:37 +00:00
|
|
|
<FormGroup
|
|
|
|
label={t("consoleDisplayName")}
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={helpText("consoleDisplayNameHelp")}
|
|
|
|
forLabel={t("consoleDisplayName")}
|
|
|
|
forID="kc-console-display-name"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
fieldId="kc-console-display-name"
|
|
|
|
isRequired
|
|
|
|
>
|
2021-01-26 01:41:14 +00:00
|
|
|
{/* These hidden fields are required so data object written back matches data retrieved */}
|
2021-02-19 23:13:07 +00:00
|
|
|
{/* <TextInput
|
2021-01-26 01:41:14 +00:00
|
|
|
hidden
|
|
|
|
type="text"
|
|
|
|
id="kc-console-id"
|
|
|
|
name="id"
|
|
|
|
ref={form.register}
|
2021-02-19 23:13:07 +00:00
|
|
|
/> */}
|
2021-01-26 01:41:14 +00:00
|
|
|
<TextInput
|
|
|
|
hidden
|
|
|
|
type="text"
|
|
|
|
id="kc-console-provider-id"
|
|
|
|
name="providerId"
|
2021-02-19 23:13:07 +00:00
|
|
|
defaultValue="ldap"
|
2021-01-26 01:41:14 +00:00
|
|
|
ref={form.register}
|
|
|
|
/>
|
|
|
|
<TextInput
|
|
|
|
hidden
|
|
|
|
type="text"
|
|
|
|
id="kc-console-provider-type"
|
|
|
|
name="providerType"
|
2021-02-19 23:13:07 +00:00
|
|
|
defaultValue="org.keycloak.storage.UserStorageProvider"
|
2021-01-26 01:41:14 +00:00
|
|
|
ref={form.register}
|
|
|
|
/>
|
|
|
|
<TextInput
|
|
|
|
hidden
|
|
|
|
type="text"
|
|
|
|
id="kc-console-parentId"
|
|
|
|
name="parentId"
|
2021-02-19 23:13:07 +00:00
|
|
|
defaultValue={realm}
|
2021-01-26 01:41:14 +00:00
|
|
|
ref={form.register}
|
2020-10-30 20:15:37 +00:00
|
|
|
/>
|
2021-02-19 23:13:07 +00:00
|
|
|
<TextInput
|
|
|
|
isRequired
|
|
|
|
type="text"
|
|
|
|
id="kc-console-display-name"
|
|
|
|
name="name"
|
|
|
|
ref={form.register({
|
|
|
|
required: {
|
|
|
|
value: true,
|
|
|
|
message: `${t("validateName")}`,
|
|
|
|
},
|
|
|
|
})}
|
|
|
|
/>
|
2021-01-26 01:41:14 +00:00
|
|
|
{form.errors.name && (
|
|
|
|
<div className="error">{form.errors.name.message}</div>
|
|
|
|
)}
|
2020-10-30 20:15:37 +00:00
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
label={t("vendor")}
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={helpText("vendorHelp")}
|
|
|
|
forLabel={t("vendor")}
|
|
|
|
forID="kc-vendor"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
fieldId="kc-vendor"
|
|
|
|
isRequired
|
|
|
|
>
|
2020-11-25 14:50:40 +00:00
|
|
|
<Controller
|
2021-01-26 01:41:14 +00:00
|
|
|
name="config.vendor[0]"
|
2020-11-25 14:50:40 +00:00
|
|
|
defaultValue=""
|
2021-01-26 01:41:14 +00:00
|
|
|
control={form.control}
|
2020-11-25 14:50:40 +00:00
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<Select
|
|
|
|
toggleId="kc-vendor"
|
|
|
|
required
|
|
|
|
onToggle={() => setIsVendorDropdownOpen(!isVendorDropdownOpen)}
|
|
|
|
isOpen={isVendorDropdownOpen}
|
|
|
|
onSelect={(_, value) => {
|
|
|
|
onChange(value as string);
|
|
|
|
setIsVendorDropdownOpen(false);
|
|
|
|
}}
|
|
|
|
selections={value}
|
|
|
|
variant={SelectVariant.single}
|
|
|
|
>
|
2021-01-26 01:41:14 +00:00
|
|
|
<SelectOption key={0} value="ad" isPlaceholder>
|
|
|
|
Active Directory
|
|
|
|
</SelectOption>
|
|
|
|
<SelectOption key={1} value="rhds">
|
|
|
|
Red Hat Directory Server
|
|
|
|
</SelectOption>
|
|
|
|
<SelectOption key={2} value="tivoli">
|
|
|
|
Tivoli
|
|
|
|
</SelectOption>
|
|
|
|
<SelectOption key={3} value="edirectory">
|
|
|
|
Novell eDirectory
|
|
|
|
</SelectOption>
|
|
|
|
<SelectOption key={4} value="other">
|
|
|
|
Other
|
|
|
|
</SelectOption>
|
2020-11-25 14:50:40 +00:00
|
|
|
</Select>
|
|
|
|
)}
|
|
|
|
></Controller>
|
2020-10-30 20:15:37 +00:00
|
|
|
</FormGroup>
|
2020-11-25 16:17:50 +00:00
|
|
|
</FormAccess>
|
2020-10-30 20:15:37 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|