theme.keycloak.v2.admin.resources.assets.PermissionTab-CKEvhIGg.js.map Maven / Gradle / Ivy
{"version":3,"file":"PermissionTab-CKEvhIGg.js","sources":["../../src/components/permission-tab/PermissionTab.tsx"],"sourcesContent":["import type { ManagementPermissionReference } from \"@keycloak/keycloak-admin-client/lib/defs/managementPermissionReference\";\nimport {\n Card,\n CardBody,\n CardTitle,\n Form,\n FormGroup,\n PageSection,\n Switch,\n} from \"@patternfly/react-core\";\nimport {\n ActionsColumn,\n Table,\n Tbody,\n Td,\n Th,\n Thead,\n Tr,\n} from \"@patternfly/react-table\";\nimport { useState } from \"react\";\nimport { Trans, useTranslation } from \"react-i18next\";\nimport { Link, useNavigate } from \"react-router-dom\";\nimport { HelpItem } from \"@keycloak/keycloak-ui-shared\";\nimport { useAdminClient } from \"../../admin-client\";\nimport { toPermissionDetails } from \"../../clients/routes/PermissionDetails\";\nimport { KeycloakSpinner } from \"../../components/keycloak-spinner/KeycloakSpinner\";\nimport { useRealm } from \"../../context/realm-context/RealmContext\";\nimport { useFetch } from \"../../utils/useFetch\";\nimport useLocaleSort from \"../../utils/useLocaleSort\";\nimport { useConfirmDialog } from \"../confirm-dialog/ConfirmDialog\";\n\nimport \"./permissions-tab.css\";\n\ntype PermissionScreenType =\n | \"clients\"\n | \"users\"\n | \"groups\"\n | \"roles\"\n | \"identityProviders\";\n\ntype PermissionsTabProps = {\n id?: string;\n type: PermissionScreenType;\n};\n\nexport const PermissionsTab = ({ id, type }: PermissionsTabProps) => {\n const { adminClient } = useAdminClient();\n\n const { t } = useTranslation();\n const navigate = useNavigate();\n const { realm } = useRealm();\n const [realmId, setRealmId] = useState(\"\");\n const [permission, setPermission] = useState();\n const localeSort = useLocaleSort();\n\n const togglePermissionEnabled = (enabled: boolean) => {\n switch (type) {\n case \"clients\":\n return adminClient.clients.updateFineGrainPermission(\n { id: id! },\n { enabled },\n );\n case \"users\":\n return adminClient.realms.updateUsersManagementPermissions({\n realm,\n enabled,\n });\n case \"groups\":\n return adminClient.groups.updatePermission({ id: id! }, { enabled });\n case \"roles\":\n return adminClient.roles.updatePermission({ id: id! }, { enabled });\n case \"identityProviders\":\n return adminClient.identityProviders.updatePermission(\n { alias: id! },\n { enabled },\n );\n }\n };\n\n useFetch(\n () =>\n Promise.all([\n adminClient.clients.find({\n search: true,\n clientId: realm === \"master\" ? \"master-realm\" : \"realm-management\",\n }),\n (() => {\n switch (type) {\n case \"clients\":\n return adminClient.clients.listFineGrainPermissions({ id: id! });\n case \"users\":\n return adminClient.realms.getUsersManagementPermissions({\n realm,\n });\n case \"groups\":\n return adminClient.groups.listPermissions({ id: id! });\n case \"roles\":\n return adminClient.roles.listPermissions({ id: id! });\n case \"identityProviders\":\n return adminClient.identityProviders.listPermissions({\n alias: id!,\n });\n }\n })(),\n ]),\n ([clients, permission]) => {\n setRealmId(clients[0]?.id!);\n setPermission(permission);\n },\n [id],\n );\n\n const [toggleDisableDialog, DisableConfirm] = useConfirmDialog({\n titleKey: \"permissionsDisable\",\n messageKey: \"permissionsDisableConfirm\",\n continueButtonLabel: \"confirm\",\n onConfirm: async () => {\n const permission = await togglePermissionEnabled(false);\n setPermission(permission);\n },\n });\n\n if (!permission) {\n return ;\n }\n\n return (\n \n \n \n {t(\"permissions\")} \n \n {t(`${type}PermissionsHint`)}\n \n \n \n {permission.enabled && (\n <>\n \n {t(\"permissionsList\")} \n \n \n {\" \"}\n \n {{\n realm:\n realm === \"master\" ? \"master-realm\" : \"realm-management\",\n }}\n \n .\n \n \n \n \n \n \n \n \n \n {t(\"permissionsScopeName\")}\n \n {t(\"description\")} \n \n \n \n {localeSort(\n Object.entries(permission.scopePermissions || {}),\n ([name]) => name,\n ).map(([name, id]) => (\n \n \n \n {name}\n \n \n \n {t(`scopePermissions.${type}.${name}-description`)}\n \n \n \n \n \n ))}\n \n
\n \n \n >\n )}\n \n );\n};\n"],"names":["PermissionsTab","id","type","adminClient","useAdminClient","t","useTranslation","navigate","useNavigate","realm","useRealm","realmId","setRealmId","useState","permission","setPermission","localeSort","useLocaleSort","togglePermissionEnabled","enabled","useFetch","clients","toggleDisableDialog","DisableConfirm","useConfirmDialog","jsxs","PageSection","jsx","Card","CardTitle","CardBody","Form","FormGroup","HelpItem","Switch","_event","Fragment","Trans","Table","Thead","Tr","Th","Tbody","name","Td","Link","toPermissionDetails","ActionsColumn","KeycloakSpinner"],"mappings":"saA6CO,MAAMA,EAAiB,CAAC,CAAE,GAAAC,EAAI,KAAAC,KAAgC,CAC7D,KAAA,CAAE,YAAAC,GAAgBC,IAElB,CAAE,EAAAC,GAAMC,IACRC,EAAWC,IACX,CAAE,MAAAC,GAAUC,IACZ,CAACC,EAASC,CAAU,EAAIC,EAAS,EAAE,EACnC,CAACC,EAAYC,CAAa,EAAIF,EAAwC,EACtEG,EAAaC,IAEbC,EAA2BC,GAAqB,CACpD,OAAQjB,EAAM,CACZ,IAAK,UACH,OAAOC,EAAY,QAAQ,0BACzB,CAAE,GAAAF,CAAQ,EACV,CAAE,QAAAkB,CAAQ,CAAA,EAEd,IAAK,QACI,OAAAhB,EAAY,OAAO,iCAAiC,CACzD,MAAAM,EACA,QAAAU,CAAA,CACD,EACH,IAAK,SACI,OAAAhB,EAAY,OAAO,iBAAiB,CAAE,GAAAF,GAAW,CAAE,QAAAkB,EAAS,EACrE,IAAK,QACI,OAAAhB,EAAY,MAAM,iBAAiB,CAAE,GAAAF,GAAW,CAAE,QAAAkB,EAAS,EACpE,IAAK,oBACH,OAAOhB,EAAY,kBAAkB,iBACnC,CAAE,MAAOF,CAAI,EACb,CAAE,QAAAkB,CAAQ,CAAA,CAEhB,CAAA,EAGFC,EACE,IACE,QAAQ,IAAI,CACVjB,EAAY,QAAQ,KAAK,CACvB,OAAQ,GACR,SAAUM,IAAU,SAAW,eAAiB,kBAAA,CACjD,GACA,IAAM,CACL,OAAQP,EAAM,CACZ,IAAK,UACH,OAAOC,EAAY,QAAQ,yBAAyB,CAAE,GAAAF,CAAS,CAAA,EACjE,IAAK,QACI,OAAAE,E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