theme.keycloak.v2.admin.resources.assets.ClientScopesSection-C1acOUJ1.js.map Maven / Gradle / Ivy
{"version":3,"file":"ClientScopesSection-C1acOUJ1.js","sources":["../../src/client-scopes/ClientScopesSection.tsx"],"sourcesContent":["import {\n AlertVariant,\n Button,\n ButtonVariant,\n Dropdown,\n DropdownItem,\n DropdownList,\n MenuToggle,\n PageSection,\n ToolbarItem,\n} from \"@patternfly/react-core\";\nimport { EllipsisVIcon } from \"@patternfly/react-icons\";\nimport { cellWidth } from \"@patternfly/react-table\";\nimport { useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { Link } from \"react-router-dom\";\nimport { useAdminClient } from \"../admin-client\";\nimport type { Row } from \"../clients/scopes/ClientScopes\";\nimport { getProtocolName } from \"../clients/utils\";\nimport { useAlerts } from \"../components/alert/Alerts\";\nimport {\n AllClientScopeType,\n AllClientScopes,\n CellDropdown,\n ClientScope,\n ClientScopeDefaultOptionalType,\n changeScope,\n removeScope,\n} from \"../components/client-scope/ClientScopeTypes\";\nimport { useConfirmDialog } from \"../components/confirm-dialog/ConfirmDialog\";\nimport {\n Action,\n KeycloakDataTable,\n} from \"../components/table-toolbar/KeycloakDataTable\";\nimport { ViewHeader } from \"../components/view-header/ViewHeader\";\nimport { useRealm } from \"../context/realm-context/RealmContext\";\nimport helpUrls from \"../help-urls\";\nimport { emptyFormatter } from \"../util\";\nimport useLocaleSort, { mapByKey } from \"../utils/useLocaleSort\";\nimport { ChangeTypeDropdown } from \"./ChangeTypeDropdown\";\nimport {\n ProtocolType,\n SearchDropdown,\n SearchToolbar,\n SearchType,\n nameFilter,\n protocolFilter,\n typeFilter,\n} from \"./details/SearchFilter\";\nimport { toClientScope } from \"./routes/ClientScope\";\nimport { toNewClientScope } from \"./routes/NewClientScope\";\n\ntype TypeSelectorProps = ClientScopeDefaultOptionalType & {\n refresh: () => void;\n};\n\nconst TypeSelector = (scope: TypeSelectorProps) => {\n const { adminClient } = useAdminClient();\n\n const { t } = useTranslation();\n const { addAlert, addError } = useAlerts();\n\n return (\n {\n try {\n await changeScope(adminClient, scope, value as AllClientScopeType);\n addAlert(t(\"clientScopeSuccess\"), AlertVariant.success);\n scope.refresh();\n } catch (error) {\n addError(\"clientScopeError\", error);\n }\n }}\n />\n );\n};\n\nconst ClientScopeDetailLink = ({\n id,\n name,\n}: ClientScopeDefaultOptionalType) => {\n const { realm } = useRealm();\n return (\n \n {name}\n \n );\n};\n\nexport default function ClientScopesSection() {\n const { adminClient } = useAdminClient();\n\n const { realm } = useRealm();\n const { t } = useTranslation();\n const { addAlert, addError } = useAlerts();\n\n const [kebabOpen, setKebabOpen] = useState(false);\n const [selectedScopes, setSelectedScopes] = useState<\n ClientScopeDefaultOptionalType[]\n >([]);\n\n const [searchType, setSearchType] = useState(\"name\");\n const [searchTypeType, setSearchTypeType] = useState(\n AllClientScopes.none,\n );\n const [searchProtocol, setSearchProtocol] = useState(\"all\");\n const localeSort = useLocaleSort();\n\n const [key, setKey] = useState(0);\n const refresh = () => {\n setSelectedScopes([]);\n setKey(key + 1);\n };\n\n const loader = async (first?: number, max?: number, search?: string) => {\n const defaultScopes =\n await adminClient.clientScopes.listDefaultClientScopes();\n const optionalScopes =\n await adminClient.clientScopes.listDefaultOptionalClientScopes();\n const clientScopes = await adminClient.clientScopes.find();\n\n const filter =\n searchType === \"name\"\n ? nameFilter(search)\n : searchType === \"type\"\n ? typeFilter(searchTypeType)\n : protocolFilter(searchProtocol);\n\n const transformed = clientScopes\n .map((scope) => {\n const row: Row = {\n ...scope,\n type: defaultScopes.find(\n (defaultScope) => defaultScope.name === scope.name,\n )\n ? ClientScope.default\n : optionalScopes.find(\n (optionalScope) => optionalScope.name === scope.name,\n )\n ? ClientScope.optional\n : AllClientScopes.none,\n };\n return row;\n })\n .filter(filter);\n\n return localeSort(transformed, mapByKey(\"name\")).slice(\n first,\n Number(first) + Number(max),\n );\n };\n\n const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({\n titleKey: t(\"deleteClientScope\", {\n count: selectedScopes.length,\n name: selectedScopes[0]?.name,\n }),\n messageKey: \"deleteConfirmClientScopes\",\n continueButtonLabel: \"delete\",\n continueButtonVariant: ButtonVariant.danger,\n onConfirm: async () => {\n const clientScopes = await adminClient.clientScopes.find();\n const clientScopeLength = Object.keys(clientScopes).length;\n if (clientScopeLength - selectedScopes.length > 0) {\n try {\n for (const scope of selectedScopes) {\n try {\n await removeScope(adminClient, scope);\n } catch (error: any) {\n console.warn(\n \"could not remove scope\",\n error.response?.data?.errorMessage || error,\n );\n }\n await adminClient.clientScopes.del({ id: scope.id! });\n }\n addAlert(t(\"deletedSuccessClientScope\"), AlertVariant.success);\n refresh();\n } catch (error) {\n addError(\"deleteErrorClientScope\", error);\n }\n } else {\n addError(t(\"notAllowedToDeleteAllClientScopes\"), \"error\");\n }\n },\n });\n\n return (\n <>\n \n \n \n setSearchType(searchType)}\n withProtocol\n />\n }\n isPaginated\n onSelect={(clientScopes) => setSelectedScopes([...clientScopes])}\n canSelectAll\n toolbarItem={\n <>\n {\n setSearchType(searchType);\n setSearchProtocol(\"all\");\n setSearchTypeType(AllClientScopes.none);\n refresh();\n }}\n onType={(value) => {\n setSearchTypeType(value);\n setSearchProtocol(\"all\");\n refresh();\n }}\n protocol={searchProtocol}\n onProtocol={(protocol) => {\n setSearchProtocol(protocol);\n setSearchTypeType(AllClientScopes.none);\n refresh();\n }}\n />\n\n \n \n \n \n \n \n \n setKebabOpen(isOpen)}\n toggle={(ref) => (\n setKebabOpen(!kebabOpen)}\n variant=\"plain\"\n >\n \n \n )}\n isOpen={kebabOpen}\n >\n \n {\n toggleDeleteDialog();\n setKebabOpen(false);\n }}\n >\n {t(\"delete\")}\n \n \n \n \n >\n }\n actions={[\n {\n title: t(\"delete\"),\n onRowClick: (clientScope) => {\n setSelectedScopes([clientScope]);\n toggleDeleteDialog();\n },\n } as Action,\n ]}\n columns={[\n {\n name: \"name\",\n cellRenderer: ClientScopeDetailLink,\n },\n {\n name: \"type\",\n displayKey: \"assignedType\",\n cellRenderer: (row) => (\n \n ),\n },\n {\n name: \"protocol\",\n displayKey: \"protocol\",\n cellRenderer: (client) =>\n getProtocolName(t, client.protocol ?? \"openid-connect\"),\n transforms: [cellWidth(15)],\n },\n {\n name: \"attributes['gui.order']\",\n displayKey: \"displayOrder\",\n cellFormatters: [emptyFormatter()],\n transforms: [cellWidth(15)],\n },\n { name: \"description\", cellFormatters: [emptyFormatter()] },\n ]}\n />\n
\n >\n );\n}\n"],"names":["TypeSelector","scope","adminClient","useAdminClient","t","useTranslation","addAlert","addError","useAlerts","jsx","CellDropdown","value","changeScope","AlertVariant","error","ClientScopeDetailLink","id","name","realm","useRealm","Link","toClientScope","ClientScopesSection","kebabOpen","setKebabOpen","useState","selectedScopes","setSelectedScopes","searchType","setSearchType","searchTypeType","setSearchTypeType","AllClientScopes","searchProtocol","setSearchProtocol","localeSort","useLocaleSort","key","setKey","refresh","loader","first","max","search","defaultScopes","optionalScopes","clientScopes","filter","nameFilter","typeFilter","protocolFilter","transformed","defaultScope","ClientScope","optionalScope","mapByKey","toggleDeleteDialog","DeleteConfirm","useConfirmDialog","ButtonVariant","removeScope","jsxs","Fragment","ViewHeader","helpUrls","PageSection","KeycloakDataTable","SearchDropdown","SearchToolbar","protocol","ToolbarItem","Button","props","toNewClientScope","ChangeTypeDropdown","Dropdown","isOpen","ref","MenuToggle","EllipsisVIcon","DropdownList","DropdownItem","clientScope","row","client","getProtocolName","cellWidth","emptyFormatter"],"mappings":"w6BAwDA,MAAMA,GAAgBC,GAA6B,CAC3C,KAAA,CAAE,YAAAC,GAAgBC,IAElB,CAAE,EAAAC,GAAMC,IACR,CAAE,SAAAC,EAAU,SAAAC,CAAS,EAAIC,EAAU,EAGvC,OAAAC,EAACC,GAAA,CACC,YAAaT,EACb,KAAMA,EAAM,KACZ,IAAG,GACH,SAAU,MAAOU,GAAU,CACrB,GAAA,CACI,MAAAC,GAAYV,EAAaD,EAAOU,CAA2B,EACjEL,EAASF,EAAE,oBA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