keycloak-d4science-spi-parent/keycloak-d4science-theme/src/main/resources/theme/d4science/account/resources/assets/Groups-ggcw-_aR.js.map

1 line
7.3 KiB
Plaintext
Raw Normal View History

{"version":3,"file":"Groups-ggcw-_aR.js","sources":["../../src/groups/Groups.tsx"],"sourcesContent":["import {\r\n Checkbox,\r\n DataList,\r\n DataListCell,\r\n DataListItem,\r\n DataListItemCells,\r\n DataListItemRow,\r\n} from \"@patternfly/react-core\";\r\nimport { useState } from \"react\";\r\nimport { useTranslation } from \"react-i18next\";\r\nimport { getGroups } from \"../api/methods\";\r\nimport { Group } from \"../api/representations\";\r\nimport { Page } from \"../components/page/Page\";\r\nimport { useEnvironment } from \"../root/KeycloakContext\";\r\nimport { usePromise } from \"../utils/usePromise\";\r\n\r\nexport const Groups = () => {\r\n const { t } = useTranslation();\r\n const context = useEnvironment();\r\n\r\n const [groups, setGroups] = useState<Group[]>([]);\r\n const [directMembership, setDirectMembership] = useState(false);\r\n\r\n usePromise(\r\n (signal) => getGroups({ signal, context }),\r\n (groups) => {\r\n if (!directMembership) {\r\n groups.forEach((el) =>\r\n getParents(\r\n el,\r\n groups,\r\n groups.map(({ path }) => path),\r\n ),\r\n );\r\n }\r\n setGroups(groups);\r\n },\r\n [directMembership],\r\n );\r\n\r\n const getParents = (el: Group, groups: Group[], groupsPaths: string[]) => {\r\n const parentPath = el.path.slice(0, el.path.lastIndexOf(\"/\"));\r\n if (parentPath && !groupsPaths.includes(parentPath)) {\r\n el = {\r\n name: parentPath.slice(parentPath.lastIndexOf(\"/\") + 1),\r\n path: parentPath,\r\n };\r\n groups.push(el);\r\n groupsPaths.push(parentPath);\r\n\r\n getParents(el, groups, groupsPaths);\r\n }\r\n };\r\n\r\n return (\r\n <Page title={t(\"groups\")} description={t(\"groupDescriptionLabel\")}>\r\n <DataList id=\"groups-list\" aria-label={t(\"groups\")} isCompact>\r\n <DataListItem\r\n id=\"groups-list-header\"\r\n aria-label={t(\"groupsListHeader\")}\r\n >\r\n <DataListItemRow>\r\n <DataListItemCells\r\n dataListCells={[\r\n <DataListCell key=\"directMembership-header\">\r\n <Checkbox\r\n label={t(\"directMembership\")}\r\n id=\"directMembership-checkbox\"\r\n data-testid=\"directMembership-checkbox\"\r\n isChecked={directMembership}\r\n onChange={(_event, checked) => setDirectMembership(checked)}\r\n />\r\n </DataListCell>,\r\n ]}\r\n />\r\n </DataListItemRow>\r\n </DataListItem>\r\n <DataListItem\r\n id=\"groups-list-columns-names\"\r\n aria-label={t(\"groupsListColumnsNames\")}\r\n >\r\n <DataListItemRow>\r\n <DataListItemCells\r\n dataListCells={[\r\n <DataListCell key=\"group-name-header\" width={2}>\r\n <strong>{t(\"name\")}</strong>\r\n </DataListCell>,\r\n <DataListCell key=\"group-path-header\" width={2}>\r\n <strong>{t(\"path\")}</strong>\r\n </DataListCell>,\r\n <DataListCell key=\"group-direct-membership-header\" width={2}>\r\n <strong>{t(\"directMembership\")}</strong>\r\n </DataListCell>,\r\n ]}\r\n />\r\n </DataListItemRow>\r\n </DataListItem>\r\n {groups.map((group, appIndex) => (\r\n <DataListItem\r\n id={`${appIndex}-group`}\r\n key={\"group-\" + appIndex}\r\n aria-labelledby=\"groups-list\"\r\n >\r\n <DataListItemRow>\r\n <DataListItemCells\r\n dataListCells={[\r\n <DataListCell\r\n data-testid={`group[${appIndex}].name`}\r\n width={2}\r\n key={\"name-\" + appIndex}\r\n >\r\n {group.