2020-09-17 13:51:40 +00:00
|
|
|
import React from "react";
|
2022-03-02 16:08:01 +00:00
|
|
|
import { Controller, useFormContext } from "react-hook-form";
|
2020-09-10 18:04:03 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
2021-03-09 13:59:41 +00:00
|
|
|
import {
|
|
|
|
FormGroup,
|
2022-03-02 16:08:01 +00:00
|
|
|
Switch,
|
2021-03-09 13:59:41 +00:00
|
|
|
TextArea,
|
|
|
|
TextInput,
|
|
|
|
ValidatedOptions,
|
|
|
|
} from "@patternfly/react-core";
|
|
|
|
|
2022-03-09 16:42:23 +00:00
|
|
|
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
|
2021-03-09 13:59:41 +00:00
|
|
|
import { HelpItem } from "../components/help-enabler/HelpItem";
|
2021-02-28 20:02:31 +00:00
|
|
|
import { FormAccess } from "../components/form-access/FormAccess";
|
2020-09-03 19:25:05 +00:00
|
|
|
|
2022-03-02 16:08:01 +00:00
|
|
|
type ClientDescriptionProps = {
|
|
|
|
protocol?: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const ClientDescription = ({ protocol }: ClientDescriptionProps) => {
|
2020-09-10 18:04:03 +00:00
|
|
|
const { t } = useTranslation("clients");
|
2022-03-09 16:42:23 +00:00
|
|
|
const { register, errors, control } = useFormContext<ClientRepresentation>();
|
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
|
2021-03-09 13:59:41 +00:00
|
|
|
labelIcon={
|
2021-12-14 14:56:36 +00:00
|
|
|
<HelpItem helpText="clients-help:clientId" fieldLabelId="clientId" />
|
2021-03-09 13:59:41 +00:00
|
|
|
}
|
2021-04-06 17:39:27 +00:00
|
|
|
label={t("common:clientId")}
|
2020-09-23 19:19:02 +00:00
|
|
|
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-03-09 13:59:41 +00:00
|
|
|
<FormGroup
|
|
|
|
labelIcon={
|
2021-12-14 14:56:36 +00:00
|
|
|
<HelpItem helpText="clients-help:clientName" fieldLabelId="name" />
|
2021-03-09 13:59:41 +00:00
|
|
|
}
|
|
|
|
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
|
2021-03-09 13:59:41 +00:00
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:description"
|
2021-12-14 14:56:36 +00:00
|
|
|
fieldLabelId="description"
|
2021-03-09 13:59:41 +00:00
|
|
|
/>
|
|
|
|
}
|
2021-02-16 19:18:09 +00:00
|
|
|
label={t("common:description")}
|
|
|
|
fieldId="kc-description"
|
|
|
|
validated={
|
|
|
|
errors.description ? ValidatedOptions.error : ValidatedOptions.default
|
|
|
|
}
|
|
|
|
helperTextInvalid={errors.description?.message}
|
|
|
|
>
|
2021-03-09 13:59:41 +00:00
|
|
|
<TextArea
|
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>
|
2022-03-02 16:08:01 +00:00
|
|
|
{protocol === "saml" && (
|
|
|
|
<>
|
|
|
|
<FormGroup
|
|
|
|
label={t("clients:alwaysDisplayInConsole")}
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:alwaysDisplayInConsole"
|
|
|
|
fieldLabelId="clients:alwaysDisplayInConsole"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
fieldId="kc-always-display-in-console"
|
|
|
|
hasNoPaddingTop
|
|
|
|
>
|
|
|
|
<Controller
|
|
|
|
name="alwaysDisplayInConsole"
|
|
|
|
defaultValue={false}
|
|
|
|
control={control}
|
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<Switch
|
|
|
|
id="kc-always-display-in-console-switch"
|
|
|
|
label={t("common:on")}
|
|
|
|
labelOff={t("common:off")}
|
|
|
|
isChecked={value}
|
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
label={t("frontchannelLogout")}
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:frontchannelLogout"
|
|
|
|
fieldLabelId="clients:frontchannelLogout"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
fieldId="kc-frontchannelLogout"
|
|
|
|
hasNoPaddingTop
|
|
|
|
>
|
|
|
|
<Controller
|
|
|
|
name="frontchannelLogout"
|
|
|
|
defaultValue={true}
|
|
|
|
control={control}
|
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<Switch
|
|
|
|
id="kc-frontchannelLogout-switch"
|
|
|
|
label={t("common:on")}
|
|
|
|
labelOff={t("common:off")}
|
|
|
|
isChecked={value.toString() === "true"}
|
|
|
|
onChange={(value) => onChange(value.toString())}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
</>
|
|
|
|
)}
|
2020-10-28 18:17:15 +00:00
|
|
|
</FormAccess>
|
2020-09-03 19:25:05 +00:00
|
|
|
);
|
|
|
|
};
|