import { useState } from "react"; import { DescriptionList, TextContent, TextList, TextListItem, capitalize, } from "@patternfly/react-core"; import { Tbody, Tr, Td, ExpandableRowContent } from "@patternfly/react-table"; import { useTranslation } from "react-i18next"; import type PolicyResultRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyResultRepresentation"; import type EvaluationResultRepresentation from "@keycloak/keycloak-admin-client/lib/defs/evaluationResultRepresentation"; import { DecisionEffect } from "@keycloak/keycloak-admin-client/lib/defs/policyRepresentation"; import { useParams } from "react-router-dom"; import { Link } from "react-router-dom-v5-compat"; import { toPermissionDetails } from "../routes/PermissionDetails"; import { toPolicyDetails } from "../routes/PolicyDetails"; import { useRealm } from "../../context/realm-context/RealmContext"; import type { ClientParams } from "../routes/Client"; type Props = { idx: number; rowIndex: number; outerPolicy: PolicyResultRepresentation; resource: EvaluationResultRepresentation; }; export const AuthorizationEvaluateResourcePolicies = ({ idx, rowIndex, outerPolicy, resource, }: Props) => { const [expanded, setExpanded] = useState(false); const { t } = useTranslation("clients"); const { realm } = useRealm(); const { clientId } = useParams(); return ( setExpanded((prev) => !prev), }} /> {outerPolicy.policy?.name} {t(outerPolicy.status?.toLowerCase() as string)} {t(`${outerPolicy.policy?.decisionStrategy?.toLowerCase()}`)} {outerPolicy.status === DecisionEffect.Permit ? resource.policies?.[rowIndex].scopes?.join(", ") : "-"} {outerPolicy.status === DecisionEffect.Deny && resource.policies?.[rowIndex]?.scopes?.length ? resource.policies[rowIndex].scopes?.join(", ") : "-"} {expanded && ( {outerPolicy.associatedPolicies?.map((item) => ( {item.policy?.name} {t("votedToStatus", { status: capitalize(item.status as string), })} ))} )} ); };