2020-11-25 14:50:40 +00:00
|
|
|
import {
|
|
|
|
Form,
|
|
|
|
FormGroup,
|
|
|
|
Select,
|
|
|
|
SelectOption,
|
|
|
|
SelectVariant,
|
|
|
|
TextInput,
|
|
|
|
} from "@patternfly/react-core";
|
2020-10-30 20:15:37 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
2020-11-25 14:50:40 +00:00
|
|
|
import React, { useState } from "react";
|
2020-10-30 20:15:37 +00:00
|
|
|
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-10-30 20:15:37 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
const { register, handleSubmit, control } = useForm<
|
|
|
|
ComponentRepresentation
|
|
|
|
>();
|
|
|
|
const onSubmit = (data: ComponentRepresentation) => {
|
|
|
|
console.log(data);
|
|
|
|
};
|
|
|
|
|
2020-10-30 20:15:37 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{/* Cache settings */}
|
2020-11-25 14:50:40 +00:00
|
|
|
<Form isHorizontal onSubmit={handleSubmit(onSubmit)}>
|
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
|
|
|
|
>
|
|
|
|
<TextInput
|
|
|
|
isRequired
|
|
|
|
type="text"
|
|
|
|
id="kc-console-display-name"
|
2020-11-25 14:50:40 +00:00
|
|
|
name="displayName"
|
|
|
|
ref={register}
|
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
|
|
|
|
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>
|
2020-10-30 20:15:37 +00:00
|
|
|
</FormGroup>
|
2020-11-25 14:50:40 +00:00
|
|
|
<button type="submit">Test submit</button>
|
2020-10-30 20:15:37 +00:00
|
|
|
</Form>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|