theme.keycloak.v2.admin.resources.assets.RolesList-LyWYaZd3.js.map Maven / Gradle / Ivy
{"version":3,"file":"RolesList-LyWYaZd3.js","sources":["../../src/components/roles-list/RolesList.tsx"],"sourcesContent":["import type RoleRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/roleRepresentation\";\nimport { HelpItem } from \"@keycloak/keycloak-ui-shared\";\nimport { AlertVariant, Button, ButtonVariant } from \"@patternfly/react-core\";\nimport { useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { Link, To, useNavigate } from \"react-router-dom\";\nimport { useAdminClient } from \"../../admin-client\";\nimport { useRealm } from \"../../context/realm-context/RealmContext\";\nimport { toRealmSettings } from \"../../realm-settings/routes/RealmSettings\";\nimport { emptyFormatter, upperCaseFormatter } from \"../../util\";\nimport { useAlerts } from \"../alert/Alerts\";\nimport { useConfirmDialog } from \"../confirm-dialog/ConfirmDialog\";\nimport { ListEmptyState } from \"../list-empty-state/ListEmptyState\";\nimport { Action, KeycloakDataTable } from \"../table-toolbar/KeycloakDataTable\";\n\nimport \"./RolesList.css\";\n\ntype RoleDetailLinkProps = RoleRepresentation & {\n defaultRoleName?: string;\n toDetail: (roleId: string) => To;\n messageBundle?: string;\n};\n\nconst RoleDetailLink = ({\n defaultRoleName,\n toDetail,\n messageBundle,\n ...role\n}: RoleDetailLinkProps) => {\n const { t } = useTranslation(messageBundle);\n const { realm } = useRealm();\n return role.name !== defaultRoleName ? (\n {role.name}\n ) : (\n <>\n \n {role.name}{\" \"}\n \n \n >\n );\n};\n\ntype RolesListProps = {\n paginated?: boolean;\n parentRoleId?: string;\n messageBundle?: string;\n isReadOnly: boolean;\n toCreate: To;\n toDetail: (roleId: string) => To;\n loader?: (\n first?: number,\n max?: number,\n search?: string,\n ) => Promise;\n};\n\nexport const RolesList = ({\n loader,\n paginated = true,\n parentRoleId,\n messageBundle = \"roles\",\n toCreate,\n toDetail,\n isReadOnly,\n}: RolesListProps) => {\n const { adminClient } = useAdminClient();\n\n const { t } = useTranslation();\n const navigate = useNavigate();\n const { addAlert, addError } = useAlerts();\n const { realmRepresentation: realm } = useRealm();\n\n const [selectedRole, setSelectedRole] = useState();\n\n const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({\n titleKey: \"roleDeleteConfirm\",\n messageKey: t(\"roleDeleteConfirmDialog\", {\n selectedRoleName: selectedRole ? selectedRole!.name : \"\",\n }),\n continueButtonLabel: \"delete\",\n continueButtonVariant: ButtonVariant.danger,\n onConfirm: async () => {\n try {\n if (!parentRoleId) {\n await adminClient.roles.delById({\n id: selectedRole!.id!,\n });\n } else {\n await adminClient.roles.delCompositeRoles({ id: parentRoleId }, [\n selectedRole!,\n ]);\n }\n setSelectedRole(undefined);\n addAlert(t(\"roleDeletedSuccess\"), AlertVariant.success);\n } catch (error) {\n addError(\"roleDeleteError\", error);\n }\n },\n });\n\n return (\n <>\n \n }\n >\n {t(\"createRole\")}\n \n )\n }\n actions={\n isReadOnly\n ? []\n : [\n {\n title: t(\"delete\"),\n onRowClick: (role) => {\n setSelectedRole(role);\n if (\n realm?.defaultRole &&\n role.name === realm!.defaultRole!.name\n ) {\n addAlert(\n t(\"defaultRoleDeleteError\"),\n AlertVariant.danger,\n );\n } else toggleDeleteDialog();\n },\n } as Action,\n ]\n }\n columns={[\n {\n name: \"name\",\n displayKey: \"roleName\",\n cellRenderer: (row) => (\n \n ),\n },\n {\n name: \"composite\",\n displayKey: \"composite\",\n cellFormatters: [upperCaseFormatter(), emptyFormatter()],\n },\n {\n name: \"description\",\n displayKey: \"description\",\n cellFormatters: [emptyFormatter()],\n },\n ]}\n emptyState={\n navigate(toCreate)}\n />\n }\n />\n >\n );\n};\n"],"names":["RoleDetailLink","defaultRoleName","toDetail","messageBundle","role","t","useTranslation","realm","useRealm","jsx","Link","jsxs","Fragment","toRealmSettings","HelpItem","RolesList","loader","paginated","parentRoleId","toCreate","isReadOnly","adminClient","useAdminClient","navigate","useNavigate","addAlert","addError","useAlerts","selectedRole","setSelectedRole","useState","toggleDeleteDialog","DeleteConfirm","useConfirmDialog","ButtonVariant","AlertVariant","error","KeycloakDataTable","Button","props","row","upperCaseFormatter","emptyFormatter","ListEmptyState"],"mappings":"8XAuBA,MAAMA,EAAiB,CAAC,CACtB,gBAAAC,EACA,SAAAC,EACA,cAAAC,EACA,GAAGC,CACL,IAA2B,CACzB,KAAM,CAAE,EAAAC,CAAA,EAAMC,EAAeH,CAAa,EACpC,CAAE,MAAAI,GAAUC,IAClB,OAAOJ,EAAK,OAASH,EACnBQ,EAACC,EAAK,CAAA,GAAIR,EAASE,EAAK,EAAG,EAAI,SAAKA,EAAA,IAAA,CAAK,EAGvCO,EAAAC,EAAA,CAAA,SAAA,CAACD,EAAAD,EAAA,CAAK,GAAIG,EAAgB,CAAE,MAAAN,EAAO,IAAK,oBAAqB,EAC1D,SAAA,CAAKH,EAAA,KAAM,GAAA,EACd,EACAK,EAACK,EAAA,CACC,SAAUT,EAAE,GAAGF,CAAa,cAAc,EAC1C,aAAa,aAAA,CACf,CACF,CAAA,CAAA,CAEJ,EAgBaY,EAAY,CAAC,CACxB,OAAAC,EACA,UAAAC,EAAY,GACZ,aAAAC,EACA,cAAAf,EAAgB,QAChB,SAAAgB,EACA,SAAAjB,EACA,WAAAkB,CACF,IAAsB,CACd,KAAA,CAAE,YAAAC,GAAgBC,IAElB,CAAE,GAAMhB,IACRiB,EAAWC,IACX,CAAE,SAAAC,EAAU,SAAAC,CAAS,EAAIC,EAAU,EACnC,CAAE,oBAAqBpB,CAAM,EAAIC,EAAS,EAE1C,CAACoB,EAAcC,CAAe,EAAIC,EAA6B,EAE/D,CAACC,EAAoBC,CAAa,EAAIC,EAAiB,CAC3D,SAAU,oBACV,WAAY,EAAE,0BAA2B,CACvC,iBAAkBL,EAAeA,EAAc,KAAO,EAAA,CACvD,EACD,oBAAqB,SACrB,sBAAuBM,EAAc,OACrC,UAAW,SAAY,CACjB,GAAA,CACGhB,EAKH,MAAMG,EAAY,MAAM,kBAAkB,CAAE,GA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