theme.keycloak.v2.admin.resources.assets.AddSamlConnect-DFdMcDyu.js.map Maven / Gradle / Ivy
{"version":3,"file":"AddSamlConnect-DFdMcDyu.js","sources":["../../src/identity-providers/add/SamlConnectSettings.tsx","../../src/identity-providers/add/AddSamlConnect.tsx"],"sourcesContent":["import { fetchWithError } from \"@keycloak/keycloak-admin-client\";\nimport type IdentityProviderRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/identityProviderRepresentation\";\nimport {\n FormErrorText,\n HelpItem,\n TextControl,\n useEnvironment,\n} from \"@keycloak/keycloak-ui-shared\";\nimport { FormGroup, Title } from \"@patternfly/react-core\";\nimport { useFormContext } from \"react-hook-form\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { useAdminClient } from \"../../admin-client\";\nimport { FileUploadForm } from \"../../components/json-file-upload/FileUploadForm\";\nimport { useRealm } from \"../../context/realm-context/RealmContext\";\nimport type { Environment } from \"../../environment\";\nimport { addTrailingSlash } from \"../../util\";\nimport { getAuthorizationHeaders } from \"../../utils/getAuthorizationHeaders\";\nimport { DiscoveryEndpointField } from \"../component/DiscoveryEndpointField\";\nimport { DescriptorSettings } from \"./DescriptorSettings\";\n\ntype FormFields = IdentityProviderRepresentation & {\n discoveryError: string;\n};\n\nexport const SamlConnectSettings = () => {\n const { adminClient } = useAdminClient();\n const { environment } = useEnvironment();\n\n const { t } = useTranslation();\n const id = \"saml\";\n\n const { realm } = useRealm();\n const {\n setValue,\n setError,\n clearErrors,\n formState: { errors },\n } = useFormContext();\n\n const setupForm = (result: IdentityProviderRepresentation) => {\n Object.entries(result).map(([key, value]) =>\n setValue(`config.${key}`, value),\n );\n };\n\n const fileUpload = async (xml: string) => {\n clearErrors(\"discoveryError\");\n if (!xml) {\n return;\n }\n const formData = new FormData();\n formData.append(\"providerId\", id);\n formData.append(\"file\", new Blob([xml]));\n\n try {\n const response = await fetchWithError(\n `${addTrailingSlash(\n adminClient.baseUrl,\n )}admin/realms/${realm}/identity-provider/import-config`,\n {\n method: \"POST\",\n body: formData,\n headers: getAuthorizationHeaders(await adminClient.getAccessToken()),\n },\n );\n if (response.ok) {\n const result = await response.json();\n setupForm(result);\n } else {\n setError(\"discoveryError\", {\n type: \"manual\",\n message: response.statusText,\n });\n }\n } catch (error) {\n setError(\"discoveryError\", {\n type: \"manual\",\n message: (error as Error).message,\n });\n }\n };\n\n return (\n <>\n \n {t(\"samlSettings\")}\n \n\n \n\n \n }\n >\n fileUpload(value)}\n />\n {errors.discoveryError && (\n \n )}\n \n }\n >\n {(readonly) => }\n \n >\n );\n};\n","import type IdentityProviderRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/identityProviderRepresentation\";\nimport {\n ActionGroup,\n AlertVariant,\n Button,\n PageSection,\n} from \"@patternfly/react-core\";\nimport { FormProvider, useForm } from \"react-hook-form\";\nimport { useTranslation } from \"react-i18next\";\nimport { Link, useNavigate } from \"react-router-dom\";\nimport { useAdminClient } from \"../../admin-client\";\nimport { useAlerts } from \"../../components/alert/Alerts\";\nimport { FormAccess } from \"../../components/form/FormAccess\";\nimport { ViewHeader } from \"../../components/view-header/ViewHeader\";\nimport { useRealm } from \"../../context/realm-context/RealmContext\";\nimport { toIdentityProvider } from \"../routes/IdentityProvider\";\nimport { toIdentityProviders } from \"../routes/IdentityProviders\";\nimport { SamlConnectSettings } from \"./SamlConnectSettings\";\nimport { SamlGeneralSettings } from \"./SamlGeneralSettings\";\n\ntype DiscoveryIdentityProvider = IdentityProviderRepresentation & {\n discoveryEndpoint?: string;\n};\n\nexport default function AddSamlConnect() {\n const { adminClient } = useAdminClient();\n\n const { t } = useTranslation();\n const navigate = useNavigate();\n const id = \"saml\";\n\n const form = useForm({\n defaultValues: { alias: id, config: { allowCreate: \"true\" } },\n mode: \"onChange\",\n });\n const {\n handleSubmit,\n formState: { isDirty },\n } = form;\n\n const { addAlert, addError } = useAlerts();\n const { realm } = useRealm();\n\n const onSubmit = async (provider: DiscoveryIdentityProvider) => {\n delete provider.discoveryEndpoint;\n try {\n await adminClient.identityProviders.create({\n ...provider,\n providerId: id,\n });\n addAlert(t(\"createIdentityProviderSuccess\"), AlertVariant.success);\n navigate(\n toIdentityProvider({\n realm,\n providerId: id,\n alias: provider.alias!,\n tab: \"settings\",\n }),\n );\n } catch (error: any) {\n addError(\"createIdentityProviderError\", error);\n }\n };\n\n return (\n <>\n \n \n \n \n \n \n \n \n \n \n \n \n \n >\n );\n}\n"],"names":["SamlConnectSettings","adminClient","useAdminClient","environment","useEnvironment","useTranslation","id","realm","useRealm","setValue","setError","clearErrors","errors","useFormContext","setupForm","result","key","value","fileUpload","xml","formData","response","fetchWithError","addTrailingSlash","getAuthorizationHeaders","error","jsxs","Fragment","jsx","Title","TextControl","DiscoveryEndpointField","FormGroup","HelpItem","FileUploadForm","FormErrorText","readonly","DescriptorSettings","AddSamlConnect","t","navigate","useNavigate","form","useForm","handleSubmit","isDirty","addAlert","addError","useAlerts","onSubmit","provider","AlertVariant","toIdentityProvider","ViewHeader","PageSection","FormProvider","FormAccess","SamlGeneralSettings","ActionGroup","Button","props","Link","toIdentityProviders"],"mappings":"w3BAyBO,MAAMA,EAAsB,IAAM,CACjC,KAAA,CAAE,YAAAC,GAAgBC,IAClB,CAAE,YAAAC,GAAgBC,IAElB,CAAE,GAAMC,IACRC,EAAK,OAEL,CAAE,MAAAC,GAAUC,IACZ,CACJ,SAAAC,EACA,SAAAC,EACA,YAAAC,EACA,UAAW,CAAE,OAAAC,CAAO,GAClBC,EAA2B,EAEzBC,EAAaC,GAA2C,CACrD,OAAA,QAAQA,CAAM,EAAE,IAAI,CAAC,CAACC,EAAKC,CAAK,IACrCR,EAAS,UAAUO,CAAG,GAAIC,CAAK,CAAA,CACjC,EAGIC,EAAa,MAAOC,GAAgB,CAExC,GADAR,EAAY,gBAAgB,EACxB,CAACQ,EACH,OAEI,MAAAC,EAAW,IAAI,SACZA,EAAA,OAAO,aAAcd,CAAE,EAChCc,EAAS,OAAO,OAAQ,IAAI,KAAK,CAACD,CAAG,CAAC,CAA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