diff --git a/js/apps/admin-ui/src/clients/authorization/policy/JavaScript.tsx b/js/apps/admin-ui/src/clients/authorization/policy/JavaScript.tsx index 5dbb13e121..b0269f7917 100644 --- a/js/apps/admin-ui/src/clients/authorization/policy/JavaScript.tsx +++ b/js/apps/admin-ui/src/clients/authorization/policy/JavaScript.tsx @@ -33,6 +33,7 @@ export const JavaScript = () => { code={field.value} height="600px" language={Language.javascript} + isReadOnly={true} /> )} /> diff --git a/js/apps/admin-ui/src/clients/authorization/policy/LogicSelector.tsx b/js/apps/admin-ui/src/clients/authorization/policy/LogicSelector.tsx index e9a2ff7263..9562419868 100644 --- a/js/apps/admin-ui/src/clients/authorization/policy/LogicSelector.tsx +++ b/js/apps/admin-ui/src/clients/authorization/policy/LogicSelector.tsx @@ -6,7 +6,11 @@ import { HelpItem } from "ui-shared"; const LOGIC_TYPES = ["POSITIVE", "NEGATIVE"] as const; -export const LogicSelector = () => { +type LogicSelectorProps = { + isDisabled: boolean; +}; + +export const LogicSelector = ({ isDisabled }: LogicSelectorProps) => { const { t } = useTranslation("clients"); const { control } = useFormContext(); @@ -39,6 +43,7 @@ export const LogicSelector = () => { onChange={() => field.onChange(type)} label={t(`logicType.${type.toLowerCase()}`)} className="pf-u-mb-md" + isDisabled={isDisabled} /> ))} diff --git a/js/apps/admin-ui/src/clients/authorization/policy/NameDescription.tsx b/js/apps/admin-ui/src/clients/authorization/policy/NameDescription.tsx index ee35f22bca..7da0b02b64 100644 --- a/js/apps/admin-ui/src/clients/authorization/policy/NameDescription.tsx +++ b/js/apps/admin-ui/src/clients/authorization/policy/NameDescription.tsx @@ -8,9 +8,13 @@ import { KeycloakTextArea } from "../../../components/keycloak-text-area/Keycloa type NameDescriptionProps = { prefix: string; + isDisabled: boolean; }; -export const NameDescription = ({ prefix }: NameDescriptionProps) => { +export const NameDescription = ({ + prefix, + isDisabled, +}: NameDescriptionProps) => { const { t } = useTranslation("clients"); const { register, @@ -35,6 +39,7 @@ export const NameDescription = ({ prefix }: NameDescriptionProps) => { } > { helperTextInvalid={t("common:maxLength", { length: 255 })} > (); + const isDisabled = policyType === "js"; useFetch( async () => { @@ -164,9 +165,13 @@ export default function PolicyDetails() { return ; } - const ComponentType = isValidComponentType(policyType) - ? COMPONENTS[policyType] - : COMPONENTS["js"]; + function getComponentType() { + return isValidComponentType(policyType) + ? COMPONENTS[policyType] + : COMPONENTS["js"]; + } + + const ComponentType = getComponentType(); return ( <> @@ -198,13 +203,14 @@ export default function PolicyDetails() { role="view-clients" > - + - +