From 2a02b38888743450a4c7dd9c8411c7ee12df03d0 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Fri, 23 Apr 2021 11:55:15 +0200 Subject: [PATCH 1/3] fixing PR comment: https://github.com/keycloak/keycloak-admin-ui/pull/474#issuecomment-825417974 --- src/clients/add/CapabilityConfig.tsx | 9 +++++---- src/clients/messages.json | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/clients/add/CapabilityConfig.tsx b/src/clients/add/CapabilityConfig.tsx index 7f1f5521d7..6bdb510cc5 100644 --- a/src/clients/add/CapabilityConfig.tsx +++ b/src/clients/add/CapabilityConfig.tsx @@ -187,11 +187,12 @@ export const CapabilityConfig = ({ label={t("serviceAccount")} id="kc-flow-service-account" name="serviceAccountsEnabled" - isChecked={value} - onChange={onChange} - isDisabled={ - !clientAuthentication || clientAuthorization + isChecked={ + value || + (clientAuthentication && clientAuthorization) } + onChange={onChange} + isDisabled={clientAuthorization} /> Date: Mon, 26 Apr 2021 09:40:59 +0200 Subject: [PATCH 2/3] fixed the wrong comment --- src/clients/add/CapabilityConfig.tsx | 14 ++++++++------ src/clients/add/NewClientForm.tsx | 1 - 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/clients/add/CapabilityConfig.tsx b/src/clients/add/CapabilityConfig.tsx index 6bdb510cc5..8f2b58f339 100644 --- a/src/clients/add/CapabilityConfig.tsx +++ b/src/clients/add/CapabilityConfig.tsx @@ -26,7 +26,7 @@ export const CapabilityConfig = ({ const { control, watch, setValue } = useFormContext(); const protocol = type || watch("protocol"); const clientAuthentication = watch("publicClient"); - const clientAuthorization = watch("authorizationServicesEnabled"); + const authorization = watch("authorizationServicesEnabled"); return ( @@ -47,7 +47,7 @@ export const CapabilityConfig = ({ > ( { onChange(value); if (value) { @@ -188,11 +188,13 @@ export const CapabilityConfig = ({ id="kc-flow-service-account" name="serviceAccountsEnabled" isChecked={ - value || - (clientAuthentication && clientAuthorization) + value || (clientAuthentication && authorization) } onChange={onChange} - isDisabled={clientAuthorization} + isDisabled={ + (clientAuthentication && !authorization) || + (!clientAuthentication && authorization) + } /> Date: Mon, 26 Apr 2021 13:48:09 +0200 Subject: [PATCH 3/3] small fixes --- src/clients/add/CapabilityConfig.tsx | 28 ++++++++++++++++++++------- src/clients/add/capability-config.css | 5 +++++ src/clients/messages.json | 2 +- 3 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 src/clients/add/capability-config.css diff --git a/src/clients/add/CapabilityConfig.tsx b/src/clients/add/CapabilityConfig.tsx index 8f2b58f339..3ba9036af5 100644 --- a/src/clients/add/CapabilityConfig.tsx +++ b/src/clients/add/CapabilityConfig.tsx @@ -1,5 +1,6 @@ import React from "react"; import { useTranslation } from "react-i18next"; +import { Controller, useFormContext } from "react-hook-form"; import { FormGroup, Switch, @@ -8,11 +9,13 @@ import { GridItem, InputGroup, } from "@patternfly/react-core"; -import { Controller, useFormContext } from "react-hook-form"; + import { FormAccess } from "../../components/form-access/FormAccess"; import { ClientForm } from "../ClientDetails"; import { HelpItem } from "../../components/help-enabler/HelpItem"; +import "./capability-config.css"; + type CapabilityConfigProps = { unWrap?: boolean; protocol?: string; @@ -29,7 +32,12 @@ export const CapabilityConfig = ({ const authorization = watch("authorizationServicesEnabled"); return ( - + <> {protocol === "openid-connect" && ( <> @@ -57,7 +65,13 @@ export const CapabilityConfig = ({ label={t("common:on")} labelOff={t("common:off")} isChecked={!value} - onChange={(value) => onChange(!value)} + onChange={(value) => { + onChange(!value); + if (!value) { + setValue("authorizationServicesEnabled", false); + setValue("serviceAccountsEnabled", false); + } + }} /> )} /> @@ -103,7 +117,7 @@ export const CapabilityConfig = ({ fieldId="kc-flow" > - + - + - + - +