theme.keycloak.v2.admin.resources.assets.ScopeForm-C9VixkBN.js.map Maven / Gradle / Ivy
{"version":3,"file":"ScopeForm-C9VixkBN.js","sources":["../../src/client-scopes/details/ScopeForm.tsx"],"sourcesContent":["import type ClientScopeRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/clientScopeRepresentation\";\nimport { ActionGroup, Button } from \"@patternfly/react-core\";\nimport { useEffect } from \"react\";\nimport { FormProvider, useForm, useWatch } from \"react-hook-form\";\nimport { useTranslation } from \"react-i18next\";\nimport { Link } from \"react-router-dom\";\nimport {\n FormSubmitButton,\n SelectControl,\n TextAreaControl,\n TextControl,\n} from \"@keycloak/keycloak-ui-shared\";\n\nimport { getProtocolName } from \"../../clients/utils\";\nimport { DefaultSwitchControl } from \"../../components/SwitchControl\";\nimport {\n ClientScopeDefaultOptionalType,\n allClientScopeTypes,\n} from \"../../components/client-scope/ClientScopeTypes\";\nimport { FormAccess } from \"../../components/form/FormAccess\";\nimport { useRealm } from \"../../context/realm-context/RealmContext\";\nimport { useLoginProviders } from \"../../context/server-info/ServerInfoProvider\";\nimport { convertAttributeNameToForm, convertToFormValues } from \"../../util\";\nimport useIsFeatureEnabled, { Feature } from \"../../utils/useIsFeatureEnabled\";\nimport { toClientScopes } from \"../routes/ClientScopes\";\n\ntype ScopeFormProps = {\n clientScope?: ClientScopeRepresentation;\n save: (clientScope: ClientScopeDefaultOptionalType) => void;\n};\n\nexport const ScopeForm = ({ clientScope, save }: ScopeFormProps) => {\n const { t } = useTranslation();\n const form = useForm({ mode: \"onChange\" });\n const { control, handleSubmit, setValue, formState } = form;\n const { realm } = useRealm();\n\n const providers = useLoginProviders();\n const isFeatureEnabled = useIsFeatureEnabled();\n const isDynamicScopesEnabled = isFeatureEnabled(Feature.DynamicScopes);\n\n const displayOnConsentScreen: string = useWatch({\n control,\n name: convertAttributeNameToForm(\"attributes.display.on.consent.screen\"),\n defaultValue:\n clientScope?.attributes?.[\"display.on.consent.screen\"] ?? \"true\",\n });\n\n const dynamicScope = useWatch({\n control,\n name: convertAttributeNameToForm(\n \"attributes.is.dynamic.scope\",\n ),\n defaultValue: \"false\",\n });\n\n const setDynamicRegex = (value: string, append: boolean) =>\n setValue(\n convertAttributeNameToForm(\n \"attributes.dynamic.scope.regexp\",\n ),\n append ? `${value}:*` : value,\n );\n\n useEffect(() => {\n convertToFormValues(clientScope ?? {}, setValue);\n }, [clientScope]);\n\n return (\n \n \n {\n if (isDynamicScopesEnabled)\n setDynamicRegex(e.target.validated, true);\n },\n }}\n />\n {isDynamicScopesEnabled && (\n <>\n (\n \"attributes.is.dynamic.scope\",\n )}\n label={t(\"dynamicScope\")}\n labelIcon={t(\"dynamicScopeHelp\")}\n onChange={(event, value) => {\n setDynamicRegex(\n value ? form.getValues(\"name\") || \"\" : \"\",\n value,\n );\n }}\n stringify\n />\n {dynamicScope === \"true\" && (\n (\n \"attributes.dynamic.scope.regexp\",\n )}\n label={t(\"dynamicScopeFormat\")}\n labelIcon={t(\"dynamicScopeFormatHelp\")}\n isDisabled\n />\n )}\n >\n )}\n \n ({\n key,\n value: t(`clientScopeType.${key}`),\n }))}\n />\n {!clientScope && (\n ({\n key: option,\n value: getProtocolName(t, option),\n }))}\n />\n )}\n (\n \"attributes.display.on.consent.screen\",\n )}\n defaultValue={displayOnConsentScreen}\n label={t(\"displayOnConsentScreen\")}\n labelIcon={t(\"displayOnConsentScreenHelp\")}\n stringify\n />\n {displayOnConsentScreen === \"true\" && (\n (\n \"attributes.consent.screen.text\",\n )}\n label={t(\"consentScreenText\")}\n labelIcon={t(\"consentScreenTextHelp\")}\n />\n )}\n (\n \"attributes.include.in.token.scope\",\n )}\n label={t(\"includeInTokenScope\")}\n labelIcon={t(\"includeInTokenScopeHelp\")}\n stringify\n />\n (\n \"attributes.gui.order\",\n )}\n label={t(\"guiOrder\")}\n labelIcon={t(\"guiOrderHelp\")}\n type=\"number\"\n min={0}\n />\n \n {t(\"save\")} \n \n \n \n \n );\n};\n"],"names":["ScopeForm","clientScope","save","t","useTranslation","form","useForm","control","handleSubmit","setValue","formState","realm","useRealm","providers","useLoginProviders","isDynamicScopesEnabled","useIsFeatureEnabled","Feature","displayOnConsentScreen","useWatch","convertAttributeNameToForm","dynamicScope","setDynamicRegex","value","append","useEffect","convertToFormValues","jsx","FormAccess","jsxs","FormProvider","TextControl","e","Fragment","DefaultSwitchControl","event","SelectControl","allClientScopeTypes","key","option","getProtocolName","TextAreaControl","ActionGroup","FormSubmitButton","Button","props","Link","toClientScopes"],"mappings":"+bA+BO,MAAMA,EAAY,CAAC,CAAE,YAAAC,EAAa,KAAAC,KAA2B,CAC5D,KAAA,CAAE,EAAAC,GAAMC,IACRC,EAAOC,EAAwC,CAAE,KAAM,UAAY,CAAA,EACnE,CAAE,QAAAC,EAAS,aAAAC,EAAc,SAAAC,EAAU,UAAAC,GAAcL,EACjD,CAAE,MAAAM,GAAUC,IAEZC,EAAYC,IAEZC,EADmBC,IACuBC,EAAQ,aAAa,EAE/DC,EAAiCC,EAAS,CAC9C,QAAAZ,EACA,KAAMa,EAA2B,sCAAsC,EACvE,aACEnB,GAAa,aAAa,2BAA2B,GAAK,MAAA,CAC7D,EAEKoB,EAAeF,EAAS,CAC5B,QAAAZ,EACA,KAAMa,EACJ,6BACF,EACA,aAAc,OAAA,CACf,EAEKE,EAAkB,CAACC,EAAeC,IACtCf,EACEW,EACE,iCACF,EACAI,EAAS,GAAGD,CAAK,KAAOA,CAAA,EAG5B,OAAAE,EAAU,IAAM,CACMC,EAAAzB,GAAe,GAAIQ,CAAQ,CAAA,EAC9C,CAACR,CAAW,CAAC,EAGd0B,EAACC,EAAA,CACC,KAAK,iBACL,SAAUpB,EAAaN,CAAI,EAC3B,aAAY,GAEZ,SAAA2B,EAACC,EAAc,CAAA,GAAGzB,EAChB,SAAA,CAAAsB,EAACI,EAAA,CACC,KAAK,OACL,MAAO5B,EAAE,MAAM,EACf,UAAWA,EAAE,eAAe,EAC5B,MAAO,CACL,SAAU,CACR,MAAO,GACP,QAAS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