2020-09-22 12:43:51 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
2022-05-30 11:07:33 +00:00
|
|
|
import { useFormContext } from "react-hook-form";
|
|
|
|
import { Form } from "@patternfly/react-core";
|
2020-09-22 12:43:51 +00:00
|
|
|
|
2022-05-30 11:07:33 +00:00
|
|
|
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
|
2020-09-22 12:43:51 +00:00
|
|
|
import { ScrollForm } from "../components/scroll-form/ScrollForm";
|
|
|
|
import { ClientDescription } from "./ClientDescription";
|
|
|
|
import { CapabilityConfig } from "./add/CapabilityConfig";
|
2021-10-05 10:32:20 +00:00
|
|
|
import { SamlConfig } from "./add/SamlConfig";
|
|
|
|
import { SamlSignature } from "./add/SamlSignature";
|
2022-05-30 11:07:33 +00:00
|
|
|
import { AccessSettings } from "./add/AccessSettings";
|
|
|
|
import { LoginSettingsPanel } from "./add/LoginSettingsPanel";
|
|
|
|
import { LogoutPanel } from "./add/LogoutPanel";
|
2020-09-22 12:43:51 +00:00
|
|
|
|
2022-05-30 11:07:33 +00:00
|
|
|
export type ClientSettingsProps = {
|
2021-10-06 11:05:27 +00:00
|
|
|
client: ClientRepresentation;
|
2020-11-02 20:15:09 +00:00
|
|
|
save: () => void;
|
2021-03-19 07:49:33 +00:00
|
|
|
reset: () => void;
|
2020-11-02 20:15:09 +00:00
|
|
|
};
|
2020-10-13 17:57:35 +00:00
|
|
|
|
2022-05-30 11:07:33 +00:00
|
|
|
export const ClientSettings = (props: ClientSettingsProps) => {
|
2020-11-02 20:15:09 +00:00
|
|
|
const { t } = useTranslation("clients");
|
2020-09-25 17:42:32 +00:00
|
|
|
|
2022-05-30 11:07:33 +00:00
|
|
|
const { watch } = useFormContext<ClientRepresentation>();
|
2021-10-05 10:32:20 +00:00
|
|
|
const protocol = watch("protocol");
|
2021-10-06 11:05:27 +00:00
|
|
|
|
2022-05-30 11:07:33 +00:00
|
|
|
const { client } = props;
|
2021-03-19 07:49:33 +00:00
|
|
|
|
2020-09-22 12:43:51 +00:00
|
|
|
return (
|
2021-08-26 12:15:28 +00:00
|
|
|
<ScrollForm
|
2022-08-04 12:54:33 +00:00
|
|
|
className="pf-u-px-lg pf-u-pb-lg"
|
2022-05-30 11:07:33 +00:00
|
|
|
sections={[
|
|
|
|
{
|
|
|
|
title: t("generalSettings"),
|
|
|
|
panel: (
|
|
|
|
<Form isHorizontal>
|
|
|
|
<ClientDescription
|
|
|
|
protocol={client.protocol}
|
|
|
|
hasConfigureAccess={client.access?.configure}
|
2022-02-22 11:22:29 +00:00
|
|
|
/>
|
2022-05-30 11:07:33 +00:00
|
|
|
</Form>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: t("accessSettings"),
|
|
|
|
panel: <AccessSettings {...props} />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: t("samlCapabilityConfig"),
|
|
|
|
isHidden: protocol !== "saml" || client.bearerOnly,
|
|
|
|
panel: <SamlConfig />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: t("signatureAndEncryption"),
|
|
|
|
isHidden: protocol !== "saml" || client.bearerOnly,
|
|
|
|
panel: <SamlSignature />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: t("capabilityConfig"),
|
|
|
|
isHidden: protocol !== "openid-connect" || client.bearerOnly,
|
|
|
|
panel: <CapabilityConfig />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: t("loginSettings"),
|
2022-07-13 19:13:47 +00:00
|
|
|
isHidden: client.bearerOnly,
|
2022-05-30 11:07:33 +00:00
|
|
|
panel: <LoginSettingsPanel access={client.access?.configure} />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: t("logoutSettings"),
|
|
|
|
isHidden: client.bearerOnly,
|
|
|
|
panel: <LogoutPanel {...props} />,
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>
|
2020-09-22 12:43:51 +00:00
|
|
|
);
|
|
|
|
};
|