keycloak-scim/src/user-federation/LdapSettingsGeneral.tsx

93 lines
2.9 KiB
TypeScript
Raw Normal View History

2020-11-25 14:50:40 +00:00
import {
FormGroup,
Select,
SelectOption,
SelectVariant,
TextInput,
} from "@patternfly/react-core";
import { useTranslation } from "react-i18next";
2020-11-25 14:50:40 +00:00
import React, { useState } from "react";
import { HelpItem } from "../components/help-enabler/HelpItem";
2020-11-25 14:50:40 +00:00
import { useForm, Controller } from "react-hook-form";
import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation";
2020-11-25 16:17:50 +00:00
import { FormAccess } from "../components/form-access/FormAccess";
export const LdapSettingsGeneral = () => {
const { t } = useTranslation("user-federation");
const helpText = useTranslation("user-federation-help").t;
2020-11-25 14:50:40 +00:00
const [isVendorDropdownOpen, setIsVendorDropdownOpen] = useState(false);
2020-11-25 16:17:50 +00:00
const { register, control } = useForm<ComponentRepresentation>();
2020-11-25 14:50:40 +00:00
return (
<>
{/* Cache settings */}
2020-11-25 16:17:50 +00:00
<FormAccess role="manage-realm" isHorizontal>
<FormGroup
label={t("consoleDisplayName")}
labelIcon={
<HelpItem
helpText={helpText("consoleDisplayNameHelp")}
forLabel={t("consoleDisplayName")}
forID="kc-console-display-name"
/>
}
fieldId="kc-console-display-name"
isRequired
>
<TextInput
isRequired
type="text"
id="kc-console-display-name"
2020-11-25 14:50:40 +00:00
name="displayName"
ref={register}
/>
</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
name="vendor"
defaultValue=""
control={control}
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}
// aria-label="Other"
// isDisabled
>
<SelectOption key={0} value="Choose..." isPlaceholder />
<SelectOption key={1} value="Active Directory" />
<SelectOption key={2} value="Red Hat Directory Server" />
<SelectOption key={3} value="Tivoli" />
<SelectOption key={4} value="Novell eDirectory" />
<SelectOption key={5} value="Other" />
</Select>
)}
></Controller>
</FormGroup>
2020-11-25 16:17:50 +00:00
</FormAccess>
</>
);
};