UNPKG

@keycloakify/keycloak-admin-ui

Version:
44 lines 4.53 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { DecisionEffect } from "@keycloak/keycloak-admin-client/lib/defs/policyRepresentation"; import { capitalize, DescriptionList, TextContent, TextList, TextListItem, } from "@patternfly/react-core"; import { ExpandableRowContent, Tbody, Td, Tr } from "@patternfly/react-table"; import { useState } from "react"; import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; import { useRealm } from "../../context/realm-context/RealmContext"; import { useParams } from "../../utils/useParams"; import { toPermissionDetails } from "../../clients/routes/PermissionDetails"; import { toPolicyDetails } from "../../clients/routes/PolicyDetails"; export const AuthorizationEvaluateResourcePolicies = ({ idx, rowIndex, outerPolicy, resource, }) => { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; const [expanded, setExpanded] = useState(false); const { t } = useTranslation(); const { realm } = useRealm(); const { clientId } = useParams(); 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: _jsx(Link, { to: toPermissionDetails({ realm, id: clientId, permissionType: (_a = outerPolicy.policy) === null || _a === void 0 ? void 0 : _a.type, permissionId: (_b = outerPolicy.policy) === null || _b === void 0 ? void 0 : _b.id, }), children: (_c = outerPolicy.policy) === null || _c === void 0 ? void 0 : _c.name }) }), _jsx(Td, { id: (_d = outerPolicy.status) === null || _d === void 0 ? void 0 : _d.toLowerCase(), children: t((_e = outerPolicy.status) === null || _e === void 0 ? void 0 : _e.toLowerCase()) }), _jsx(Td, { children: t(`${(_g = (_f = outerPolicy.policy) === null || _f === void 0 ? void 0 : _f.decisionStrategy) === null || _g === void 0 ? void 0 : _g.toLowerCase()}`) }), _jsx(Td, { children: outerPolicy.status === DecisionEffect.Permit ? (_k = (_j = (_h = resource.policies) === null || _h === void 0 ? void 0 : _h[rowIndex]) === null || _j === void 0 ? void 0 : _j.scopes) === null || _k === void 0 ? void 0 : _k.join(", ") : "-" }), _jsx(Td, { children: outerPolicy.status === DecisionEffect.Deny && ((_o = (_m = (_l = resource.policies) === null || _l === void 0 ? void 0 : _l[rowIndex]) === null || _m === void 0 ? void 0 : _m.scopes) === null || _o === void 0 ? void 0 : _o.length) ? (_p = resource.policies[rowIndex].scopes) === null || _p === void 0 ? void 0 : _p.join(", ") : "-" })] }), _jsxs(Tr, { isExpanded: expanded, children: [_jsx(Td, {}), _jsx(Td, { colSpan: 5, children: expanded && (_jsx(ExpandableRowContent, { children: _jsx(DescriptionList, { isHorizontal: true, className: "keycloak_resource_details", children: _jsx(TextContent, { children: _jsx(TextList, { children: (_q = outerPolicy.associatedPolicies) === null || _q === void 0 ? void 0 : _q.map((item) => { var _a, _b, _c; return (_jsxs(TextListItem, { children: [_jsx(Link, { to: toPolicyDetails({ realm, id: clientId, policyType: (_a = item.policy) === null || _a === void 0 ? void 0 : _a.type, policyId: (_b = item.policy) === null || _b === void 0 ? void 0 : _b.id, }), children: (_c = item.policy) === null || _c === void 0 ? void 0 : _c.name }), t("votedToStatus", { status: capitalize(item.status), })] }, "policyDetails")); }) }) }) }) })) })] }, `child-${resource.resource}`)] }, idx)); }; //# sourceMappingURL=AuthorizationEvaluateResourcePolicies.js.map