2020-09-17 13:51:40 +00:00
|
|
|
import React from "react";
|
2020-11-09 19:49:32 +00:00
|
|
|
import { FormGroup, TextInput, ValidatedOptions } from "@patternfly/react-core";
|
2020-09-23 19:19:02 +00:00
|
|
|
import { UseFormMethods } from "react-hook-form";
|
2020-09-10 18:04:03 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
2020-10-28 18:17:15 +00:00
|
|
|
import { FormAccess } from "../components/form-access/FormAccess";
|
2020-09-03 19:25:05 +00:00
|
|
|
|
|
|
|
type ClientDescriptionProps = {
|
2020-09-23 19:19:02 +00:00
|
|
|
form: UseFormMethods;
|
2020-09-03 19:25:05 +00:00
|
|
|
};
|
|
|
|
|
2020-09-23 19:19:02 +00:00
|
|
|
export const ClientDescription = ({ form }: ClientDescriptionProps) => {
|
2020-09-10 18:04:03 +00:00
|
|
|
const { t } = useTranslation("clients");
|
2020-09-23 19:19:02 +00:00
|
|
|
const { register, errors } = form;
|
2020-09-03 19:25:05 +00:00
|
|
|
return (
|
2020-10-28 18:17:15 +00:00
|
|
|
<FormAccess role="manage-clients" unWrap>
|
2020-09-23 19:19:02 +00:00
|
|
|
<FormGroup
|
|
|
|
label={t("clientID")}
|
|
|
|
fieldId="kc-client-id"
|
|
|
|
helperTextInvalid={t("common:required")}
|
2020-11-09 19:49:32 +00:00
|
|
|
validated={
|
|
|
|
errors.clientId ? ValidatedOptions.error : ValidatedOptions.default
|
|
|
|
}
|
2020-09-23 19:19:02 +00:00
|
|
|
isRequired
|
|
|
|
>
|
2020-09-03 19:25:05 +00:00
|
|
|
<TextInput
|
2020-09-23 19:19:02 +00:00
|
|
|
ref={register({ required: true })}
|
2020-09-03 19:25:05 +00:00
|
|
|
type="text"
|
|
|
|
id="kc-client-id"
|
|
|
|
name="clientId"
|
2020-11-09 19:49:32 +00:00
|
|
|
validated={
|
|
|
|
errors.clientId ? ValidatedOptions.error : ValidatedOptions.default
|
|
|
|
}
|
2020-09-03 19:25:05 +00:00
|
|
|
/>
|
|
|
|
</FormGroup>
|
2021-01-13 20:48:16 +00:00
|
|
|
<FormGroup label={t("common:name")} fieldId="kc-name">
|
2020-09-17 13:51:40 +00:00
|
|
|
<TextInput ref={register()} type="text" id="kc-name" name="name" />
|
2020-09-03 19:25:05 +00:00
|
|
|
</FormGroup>
|
2021-02-16 19:18:09 +00:00
|
|
|
<FormGroup
|
|
|
|
label={t("common:description")}
|
|
|
|
fieldId="kc-description"
|
|
|
|
validated={
|
|
|
|
errors.description ? ValidatedOptions.error : ValidatedOptions.default
|
|
|
|
}
|
|
|
|
helperTextInvalid={errors.description?.message}
|
|
|
|
>
|
2020-09-03 19:25:05 +00:00
|
|
|
<TextInput
|
2021-02-16 19:18:09 +00:00
|
|
|
ref={register({
|
|
|
|
maxLength: {
|
|
|
|
value: 255,
|
|
|
|
message: t("common:maxLength", { length: 255 }),
|
|
|
|
},
|
|
|
|
})}
|
2020-09-03 19:25:05 +00:00
|
|
|
type="text"
|
|
|
|
id="kc-description"
|
|
|
|
name="description"
|
2021-02-16 19:18:09 +00:00
|
|
|
validated={
|
|
|
|
errors.description
|
|
|
|
? ValidatedOptions.error
|
|
|
|
: ValidatedOptions.default
|
|
|
|
}
|
2020-09-03 19:25:05 +00:00
|
|
|
/>
|
|
|
|
</FormGroup>
|
2020-10-28 18:17:15 +00:00
|
|
|
</FormAccess>
|
2020-09-03 19:25:05 +00:00
|
|
|
);
|
|
|
|
};
|