2020-11-02 20:15:09 +00:00
|
|
|
import React from "react";
|
2020-09-22 12:43:51 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import {
|
|
|
|
FormGroup,
|
|
|
|
TextInput,
|
|
|
|
Form,
|
|
|
|
Switch,
|
|
|
|
TextArea,
|
2020-09-25 17:42:32 +00:00
|
|
|
ActionGroup,
|
|
|
|
Button,
|
2020-09-22 12:43:51 +00:00
|
|
|
} from "@patternfly/react-core";
|
2020-11-02 20:15:09 +00:00
|
|
|
import { Controller, UseFormMethods } from "react-hook-form";
|
2020-09-22 12:43:51 +00:00
|
|
|
|
|
|
|
import { ScrollForm } from "../components/scroll-form/ScrollForm";
|
|
|
|
import { ClientDescription } from "./ClientDescription";
|
|
|
|
import { CapabilityConfig } from "./add/CapabilityConfig";
|
2020-11-02 20:15:09 +00:00
|
|
|
import { MultiLineInput } from "../components/multi-line-input/MultiLineInput";
|
2020-10-28 18:17:15 +00:00
|
|
|
import { FormAccess } from "../components/form-access/FormAccess";
|
2020-09-22 12:43:51 +00:00
|
|
|
|
2020-11-02 20:15:09 +00:00
|
|
|
type ClientSettingsProps = {
|
|
|
|
form: UseFormMethods;
|
|
|
|
save: () => void;
|
|
|
|
};
|
2020-10-13 17:57:35 +00:00
|
|
|
|
2020-11-02 20:15:09 +00:00
|
|
|
export const ClientSettings = ({ form, save }: ClientSettingsProps) => {
|
|
|
|
const { t } = useTranslation("clients");
|
2020-09-25 17:42:32 +00:00
|
|
|
|
2020-09-22 12:43:51 +00:00
|
|
|
return (
|
2020-10-02 13:56:46 +00:00
|
|
|
<>
|
2020-11-02 20:15:09 +00:00
|
|
|
<ScrollForm
|
|
|
|
sections={[
|
|
|
|
t("capabilityConfig"),
|
|
|
|
t("generalSettings"),
|
|
|
|
t("accessSettings"),
|
|
|
|
t("loginSettings"),
|
|
|
|
]}
|
|
|
|
>
|
|
|
|
<CapabilityConfig form={form} />
|
|
|
|
<Form isHorizontal>
|
|
|
|
<ClientDescription form={form} />
|
|
|
|
</Form>
|
|
|
|
<FormAccess isHorizontal role="manage-clients">
|
|
|
|
<FormGroup label={t("rootUrl")} fieldId="kc-root-url">
|
|
|
|
<TextInput
|
|
|
|
type="text"
|
|
|
|
id="kc-root-url"
|
|
|
|
name="rootUrl"
|
|
|
|
ref={form.register}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup label={t("validRedirectUri")} fieldId="kc-redirect">
|
|
|
|
<MultiLineInput form={form} name="redirectUris" />
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup label={t("homeURL")} fieldId="kc-home-url">
|
|
|
|
<TextInput
|
|
|
|
type="text"
|
|
|
|
id="kc-home-url"
|
|
|
|
name="baseUrl"
|
|
|
|
ref={form.register}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
</FormAccess>
|
|
|
|
<FormAccess isHorizontal role="manage-clients">
|
|
|
|
<FormGroup
|
|
|
|
label={t("consentRequired")}
|
|
|
|
fieldId="kc-consent"
|
|
|
|
hasNoPaddingTop
|
|
|
|
>
|
|
|
|
<Controller
|
|
|
|
name="consentRequired"
|
|
|
|
defaultValue={false}
|
|
|
|
control={form.control}
|
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<Switch
|
|
|
|
id="kc-consent"
|
|
|
|
label={t("common:on")}
|
|
|
|
labelOff={t("common:off")}
|
|
|
|
isChecked={value}
|
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
label={t("displayOnClient")}
|
|
|
|
fieldId="kc-display-on-client"
|
|
|
|
hasNoPaddingTop
|
|
|
|
>
|
|
|
|
<Controller
|
|
|
|
name="alwaysDisplayInConsole"
|
|
|
|
defaultValue={false}
|
|
|
|
control={form.control}
|
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<Switch
|
|
|
|
id="kc-display-on-client"
|
|
|
|
label={t("common:on")}
|
|
|
|
labelOff={t("common:off")}
|
|
|
|
isChecked={value}
|
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
label={t("consentScreenText")}
|
|
|
|
fieldId="kc-consent-screen-text"
|
|
|
|
>
|
|
|
|
<TextArea
|
|
|
|
id="kc-consent-screen-text"
|
|
|
|
name="consentText"
|
|
|
|
ref={form.register}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
<ActionGroup>
|
|
|
|
<Button variant="primary" onClick={() => save()}>
|
|
|
|
{t("common:save")}
|
|
|
|
</Button>
|
|
|
|
<Button variant="link">{t("common:cancel")}</Button>
|
|
|
|
</ActionGroup>
|
|
|
|
</FormAccess>
|
|
|
|
</ScrollForm>
|
2020-10-02 13:56:46 +00:00
|
|
|
</>
|
2020-09-22 12:43:51 +00:00
|
|
|
);
|
|
|
|
};
|