import { useState } from "react"; import { ExpandableRowContent, TableComposable, 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 "./AuthorizationEvaluateResourcePolicies"; import type EvaluationResultRepresentation from "@keycloak/keycloak-admin-client/lib/defs/evaluationResultRepresentation"; import type PolicyResultRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyResultRepresentation"; type Props = { rowIndex: number; resource: EvaluationResultRepresentation; evaluateResults: any; }; export const AuthorizationEvaluateResource = ({ rowIndex, resource, evaluateResults, }: Props) => { const [expanded, setExpanded] = useState(false); const { t } = useTranslation("clients"); return ( setExpanded((prev) => !prev), }} /> {resource.resource?.name} {t(`${resource.status?.toLowerCase()}`)} {resource.allowedScopes?.length ? resource.allowedScopes.map((item) => item.name) : "-"} {expanded && ( {t("permission")} {t("results")} {t("decisionStrategy")} {t("grantedScopes")} {t("deniedScopes")} {Object.values(evaluateResults[rowIndex].policies).map( (outerPolicy, idx) => ( ) )} )} ); };