All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.admin.resources.assets.DedicatedScopes-Ceq3knF5.js.map Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
{"version":3,"file":"DedicatedScopes-Ceq3knF5.js","sources":["../../src/clients/scopes/DedicatedScope.tsx","../../src/clients/scopes/DedicatedScopes.tsx"],"sourcesContent":["import type ClientRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/clientRepresentation\";\nimport type { RoleMappingPayload } from \"@keycloak/keycloak-admin-client/lib/defs/roleRepresentation\";\nimport {\n  AlertVariant,\n  Divider,\n  FormGroup,\n  PageSection,\n  Switch,\n} from \"@patternfly/react-core\";\nimport { useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { HelpItem } from \"@keycloak/keycloak-ui-shared\";\nimport { useAdminClient } from \"../../admin-client\";\nimport { useAlerts } from \"../../components/alert/Alerts\";\nimport { FormAccess } from \"../../components/form/FormAccess\";\nimport { RoleMapping, Row } from \"../../components/role-mapping/RoleMapping\";\nimport { useAccess } from \"../../context/access/Access\";\n\ntype DedicatedScopeProps = {\n  client: ClientRepresentation;\n};\n\nexport const DedicatedScope = ({\n  client: initialClient,\n}: DedicatedScopeProps) => {\n  const { adminClient } = useAdminClient();\n\n  const { t } = useTranslation();\n  const { addAlert, addError } = useAlerts();\n\n  const [client, setClient] = useState(initialClient);\n\n  const { hasAccess } = useAccess();\n  const isManager = hasAccess(\"manage-clients\") || client.access?.manage;\n\n  const assignRoles = async (rows: Row[]) => {\n    try {\n      const realmRoles = rows\n        .filter((row) => row.client === undefined)\n        .map((row) => row.role as RoleMappingPayload)\n        .flat();\n      await Promise.all([\n        adminClient.clients.addRealmScopeMappings(\n          {\n            id: client.id!,\n          },\n          realmRoles,\n        ),\n        ...rows\n          .filter((row) => row.client !== undefined)\n          .map((row) =>\n            adminClient.clients.addClientScopeMappings(\n              {\n                id: client.id!,\n                client: row.client!.id!,\n              },\n              [row.role as RoleMappingPayload],\n            ),\n          ),\n      ]);\n\n      addAlert(t(\"clientScopeSuccess\"), AlertVariant.success);\n    } catch (error) {\n      addError(\"clientScopeError\", error);\n    }\n  };\n\n  const update = async () => {\n    const newClient = { ...client, fullScopeAllowed: !client.fullScopeAllowed };\n    try {\n      await adminClient.clients.update({ id: client.id! }, newClient);\n      addAlert(t(\"clientScopeSuccess\"), AlertVariant.success);\n      setClient(newClient);\n    } catch (error) {\n      addError(\"clientScopeError\", error);\n    }\n  };\n\n  return (\n    \n      \n        \n          }\n          fieldId=\"fullScopeAllowed\"\n        >\n          \n        \n      \n      {!client.fullScopeAllowed && (\n        <>\n          \n          \n        \n      )}\n    \n  );\n};\n","import type ClientRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/clientRepresentation\";\nimport type ProtocolMapperRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/protocolMapperRepresentation\";\nimport type { ProtocolMapperTypeRepresentation } from \"@keycloak/keycloak-admin-client/lib/defs/serverInfoRepesentation\";\nimport {\n  AlertVariant,\n  PageSection,\n  Tab,\n  TabTitleText,\n} from \"@patternfly/react-core\";\nimport { useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { useNavigate } from \"react-router-dom\";\nimport { useAdminClient } from \"../../admin-client\";\nimport { MapperList } from \"../../client-scopes/details/MapperList\";\nimport { useAlerts } from \"../../components/alert/Alerts\";\nimport { KeycloakSpinner } from \"../../components/keycloak-spinner/KeycloakSpinner\";\nimport {\n  RoutableTabs,\n  useRoutableTab,\n} from \"../../components/routable-tabs/RoutableTabs\";\nimport { ViewHeader } from \"../../components/view-header/ViewHeader\";\nimport { useFetch } from \"../../utils/useFetch\";\nimport { useParams } from \"../../utils/useParams\";\nimport {\n  DedicatedScopeDetailsParams,\n  DedicatedScopeTab,\n  toDedicatedScope,\n} from \"../routes/DedicatedScopeDetails\";\nimport { toMapper } from \"../routes/Mapper\";\nimport { DedicatedScope } from \"./DedicatedScope\";\n\nexport default function DedicatedScopes() {\n  const { adminClient } = useAdminClient();\n\n  const { t } = useTranslation();\n  const navigate = useNavigate();\n  const { realm, clientId } = useParams();\n  const { addAlert, addError } = useAlerts();\n\n  const [client, setClient] = useState();\n\n  useFetch(() => adminClient.clients.findOne({ id: clientId }), setClient, []);\n\n  const useTab = (tab: DedicatedScopeTab) =>\n    useRoutableTab(toDedicatedScope({ realm, clientId, tab }));\n\n  const mappersTab = useTab(\"mappers\");\n  const scopeTab = useTab(\"scope\");\n\n  if (!client) {\n    return ;\n  }\n\n  const addMappers = async (\n    mappers: ProtocolMapperTypeRepresentation | ProtocolMapperRepresentation[],\n  ): Promise => {\n    if (!Array.isArray(mappers)) {\n      const mapper = mappers as ProtocolMapperTypeRepresentation;\n      navigate(\n        toMapper({\n          realm,\n          id: client.id!,\n          mapperId: mapper.id!,\n        }),\n      );\n    } else {\n      try {\n        await adminClient.clients.addMultipleProtocolMappers(\n          { id: client.id! },\n          mappers as ProtocolMapperRepresentation[],\n        );\n        setClient(await adminClient.clients.findOne({ id: client.id! }));\n        addAlert(t(\"mappingCreatedSuccess\"), AlertVariant.success);\n      } catch (error) {\n        addError(\"mappingCreatedError\", error);\n      }\n    }\n  };\n\n  const onDeleteMapper = async (mapper: ProtocolMapperRepresentation) => {\n    try {\n      await adminClient.clients.delProtocolMapper({\n        id: client.id!,\n        mapperId: mapper.id!,\n      });\n      setClient({\n        ...client,\n        protocolMappers: client.protocolMappers?.filter(\n          (m) => m.id !== mapper.id,\n        ),\n      });\n      addAlert(t(\"mappingDeletedSuccess\"), AlertVariant.success);\n    } catch (error) {\n      addError(\"mappingDeletedError\", error);\n    }\n    return true;\n  };\n\n  return (\n    <>\n      \n      \n        \n          {t(\"mappers\")}}\n            data-testid=\"mappersTab\"\n            {...mappersTab}\n          >\n            \n                toMapper({ realm, id: client.id!, mapperId })\n              }\n            />\n          \n          {t(\"scope\")}}\n            data-testid=\"scopeTab\"\n            {...scopeTab}\n          >\n            \n          \n        \n      \n    \n  );\n}\n"],"names":["DedicatedScope","initialClient","adminClient","useAdminClient","t","useTranslation","addAlert","addError","useAlerts","client","setClient","useState","hasAccess","useAccess","isManager","assignRoles","rows","realmRoles","row","AlertVariant","error","update","newClient","PageSection","jsx","FormAccess","FormGroup","HelpItem","Switch","jsxs","Fragment","Divider","RoleMapping","DedicatedScopes","navigate","useNavigate","realm","clientId","useParams","useFetch","useTab","tab","useRoutableTab","toDedicatedScope","mappersTab","scopeTab","KeycloakSpinner","addMappers","mappers","mapper","toMapper","onDeleteMapper","m","ViewHeader","RoutableTabs","Tab","TabTitleText","MapperList","mapperId"],"mappings":"41CAsBO,MAAMA,EAAiB,CAAC,CAC7B,OAAQC,CACV,IAA2B,CACnB,KAAA,CAAE,YAAAC,GAAgBC,IAElB,CAAE,EAAAC,GAAMC,IACR,CAAE,SAAAC,EAAU,SAAAC,CAAS,EAAIC,EAAU,EAEnC,CAACC,EAAQC,CAAS,EAAIC,EAA+BV,CAAa,EAElE,CAAE,UAAAW,GAAcC,IAChBC,EAAYF,EAAU,gBAAgB,GAAKH,EAAO,QAAQ,OAE1DM,EAAc,MAAOC,GAAgB,CACrC,GAAA,CACF,MAAMC,EAAaD,EAChB,OAAQE,GAAQA,EAAI,SAAW,MAAS,EACxC,IAAKA,GAAQA,EAAI,IAA0B,EAC3C,OACH,MAAM,QAAQ,IAAI,CAChBhB,EAAY,QAAQ,sBAClB,CACE,GAAIO,EAAO,EACb,EACAQ,CACF,EACA,GAAGD,EACA,OAAQE,GAAQA,EAAI,SAAW,MAAS,EACxC,IAAKA,GACJhB,EAAY,QAAQ,uBAClB,CACE,GAAIO,EAAO,GACX,OAAQS,EAAI,OAAQ,EACtB,EACA,CAACA,EAAI,IAA0B,CACjC,CACF,CAAA,CACH,EAEDZ,EAASF,EAAE,oBAAoB,EAAGe,EAAa,OAAO,QAC/CC,EAAO,CACdb,EAAS,mBAAoBa,CAAK,CACpC,CAAA,EAGIC,EAAS,SAAY,CACzB,MAAMC,EAAY,CAAE,GAAGb,EAAQ,iBAAkB,CAACA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