import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { Controller, useForm } from "react-hook-form"; import { Button, Divider, FormGroup, PageSection, Radio, Switch, } from "@patternfly/react-core"; import type ResourceServerRepresentation from "@keycloak/keycloak-admin-client/lib/defs/resourceServerRepresentation"; import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner"; import { useAdminClient, useFetch } from "../../context/auth/AdminClient"; import { FormAccess } from "../../components/form-access/FormAccess"; import { HelpItem } from "../../components/help-enabler/HelpItem"; import { SaveReset } from "../advanced/SaveReset"; const POLICY_ENFORCEMENT_MODES = [ "ENFORCING", "PERMISSIVE", "DISABLED", ] as const; const DECISION_STRATEGY = ["UNANIMOUS", "AFFIRMATIVE"] as const; export const AuthorizationSettings = ({ clientId }: { clientId: string }) => { const { t } = useTranslation("clients"); const [resource, setResource] = useState(); const { control, reset } = useForm({ shouldUnregister: false, }); const adminClient = useAdminClient(); useFetch( () => adminClient.clients.getResourceServer({ id: clientId }), (resource) => { setResource(resource); reset(resource); }, [] ); if (!resource) { return ; } return ( } > } fieldId="policyEnforcementMode" hasNoPaddingTop > ( <> {POLICY_ENFORCEMENT_MODES.map((mode) => ( onChange(mode)} label={t(`policyEnforcementModes.${mode}`)} className="pf-u-mb-md" /> ))} )} /> } fieldId="decisionStrategy" hasNoPaddingTop > ( <> {DECISION_STRATEGY.map((strategy) => ( onChange(strategy)} label={t(`decisionStrategies.${strategy}`)} className="pf-u-mb-md" /> ))} )} /> } > ( )} /> { // another PR }} reset={() => reset(resource)} /> ); };