UNPKG

@keycloakify/keycloak-admin-ui

Version:
19 lines 2.47 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { useState } from "react"; import { ExpandableRowContent, Table, Tbody, Td, Th, Thead, Tr, } from "@patternfly/react-table"; import { DescriptionList } from "@patternfly/react-core/dist/esm/components"; import { useTranslation } from "react-i18next"; import { AuthorizationEvaluateResourcePolicies } from "../../clients/authorization/AuthorizationEvaluateResourcePolicies"; export const AuthorizationEvaluateResource = ({ rowIndex, resource, evaluateResults, }) => { var _a, _b, _c, _d; const [expanded, setExpanded] = useState(false); const { t } = useTranslation(); return (_jsxs(Tbody, { isExpanded: expanded, children: [_jsxs(Tr, { children: [_jsx(Td, { expand: { rowIndex, isExpanded: expanded, onToggle: () => setExpanded((prev) => !prev), } }), _jsx(Td, { "data-testid": `name-column-${resource.resource}`, children: (_a = resource.resource) === null || _a === void 0 ? void 0 : _a.name }), _jsx(Td, { id: (_b = resource.status) === null || _b === void 0 ? void 0 : _b.toLowerCase(), children: t(`${(_c = resource.status) === null || _c === void 0 ? void 0 : _c.toLowerCase()}`) }), _jsx(Td, { children: ((_d = resource.allowedScopes) === null || _d === void 0 ? void 0 : _d.length) ? resource.allowedScopes.map((item) => item.name) : "-" })] }), _jsxs(Tr, { isExpanded: expanded, children: [_jsx(Td, {}), _jsx(Td, { colSpan: 5, children: _jsx(ExpandableRowContent, { children: expanded && (_jsx(DescriptionList, { isHorizontal: true, className: "keycloak_resource_details", children: _jsxs(Table, { "aria-label": t("evaluationResults"), children: [_jsx(Thead, { children: _jsxs(Tr, { children: [_jsx(Th, { "aria-hidden": "true" }), _jsx(Th, { children: t("permission") }), _jsx(Th, { children: t("results") }), _jsx(Th, { children: t("decisionStrategy") }), _jsx(Th, { children: t("grantedScopes") }), _jsx(Th, { children: t("deniedScopes") }), _jsx(Th, { "aria-hidden": "true" })] }) }), Object.values(evaluateResults[rowIndex].policies).map((outerPolicy, idx) => (_jsx(AuthorizationEvaluateResourcePolicies, { idx: idx, rowIndex: rowIndex, outerPolicy: outerPolicy, resource: resource }, idx)))] }) })) }) })] }, `child-${resource.resource}`)] })); }; //# sourceMappingURL=AuthorizationEvaluateResource.js.map