2020-10-08 11:38:25 +00:00
|
|
|
import React, { useState } from "react";
|
2020-08-31 18:26:25 +00:00
|
|
|
import {
|
|
|
|
FormGroup,
|
|
|
|
Select,
|
|
|
|
SelectVariant,
|
|
|
|
SelectOption,
|
|
|
|
} from "@patternfly/react-core";
|
2020-09-17 13:51:40 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
2021-02-28 20:02:31 +00:00
|
|
|
import { Controller, useFormContext } from "react-hook-form";
|
2020-09-03 19:25:05 +00:00
|
|
|
|
2020-10-08 11:38:25 +00:00
|
|
|
import { useLoginProviders } from "../../context/server-info/ServerInfoProvider";
|
2020-09-10 18:04:03 +00:00
|
|
|
import { ClientDescription } from "../ClientDescription";
|
2021-02-09 12:32:41 +00:00
|
|
|
import { FormAccess } from "../../components/form-access/FormAccess";
|
2021-03-29 10:00:56 +00:00
|
|
|
import { HelpItem } from "../../components/help-enabler/HelpItem";
|
2020-08-31 18:26:25 +00:00
|
|
|
|
2021-02-28 20:02:31 +00:00
|
|
|
export const GeneralSettings = () => {
|
2021-03-29 10:00:56 +00:00
|
|
|
const { t } = useTranslation("clients");
|
2021-02-28 20:02:31 +00:00
|
|
|
const { errors, control } = useFormContext();
|
2020-08-31 18:26:25 +00:00
|
|
|
|
2020-10-08 11:38:25 +00:00
|
|
|
const providers = useLoginProviders();
|
2020-08-31 18:26:25 +00:00
|
|
|
const [open, isOpen] = useState(false);
|
|
|
|
|
|
|
|
return (
|
2021-02-09 12:32:41 +00:00
|
|
|
<FormAccess isHorizontal role="manage-clients">
|
2020-09-17 13:51:40 +00:00
|
|
|
<FormGroup
|
2021-03-29 10:00:56 +00:00
|
|
|
label={t("clientType")}
|
2020-09-17 13:51:40 +00:00
|
|
|
fieldId="kc-type"
|
|
|
|
validated={errors.protocol ? "error" : "default"}
|
2021-03-29 10:00:56 +00:00
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:clientType"
|
|
|
|
forLabel={t("clientType")}
|
2021-07-09 13:42:45 +00:00
|
|
|
forID="kc-type"
|
2021-03-29 10:00:56 +00:00
|
|
|
/>
|
|
|
|
}
|
2020-09-17 13:51:40 +00:00
|
|
|
>
|
|
|
|
<Controller
|
|
|
|
name="protocol"
|
|
|
|
defaultValue=""
|
|
|
|
control={control}
|
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<Select
|
|
|
|
id="kc-type"
|
|
|
|
onToggle={() => isOpen(!open)}
|
2021-03-29 10:00:56 +00:00
|
|
|
onSelect={(_, value) => {
|
|
|
|
onChange(value as string);
|
2020-09-17 13:51:40 +00:00
|
|
|
isOpen(false);
|
|
|
|
}}
|
|
|
|
selections={value}
|
|
|
|
variant={SelectVariant.single}
|
2020-10-08 11:38:25 +00:00
|
|
|
aria-label={t("selectEncryptionType")}
|
2020-09-17 13:51:40 +00:00
|
|
|
isOpen={open}
|
|
|
|
>
|
|
|
|
{providers.map((option) => (
|
|
|
|
<SelectOption
|
|
|
|
selected={option === value}
|
|
|
|
key={option}
|
2020-10-08 11:38:25 +00:00
|
|
|
value={option}
|
2020-09-17 13:51:40 +00:00
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</Select>
|
|
|
|
)}
|
|
|
|
/>
|
2020-08-31 18:26:25 +00:00
|
|
|
</FormGroup>
|
2021-02-28 20:02:31 +00:00
|
|
|
<ClientDescription />
|
2021-02-09 12:32:41 +00:00
|
|
|
</FormAccess>
|
2020-08-31 18:26:25 +00:00
|
|
|
);
|
|
|
|
};
|