import { useState } from "react"; import { faBoxOpen, faChevronDown, faChevronUp, faEdit, faEllipsisV, faTerminal } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { useRouter } from "@tanstack/react-router"; import { twMerge } from "tailwind-merge"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, IconButton, Td, Tooltip, Tr } from "@app/components/v2"; import { HighlightText } from "@app/components/v2/HighlightText"; import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context"; import { PAM_RESOURCE_TYPE_MAP, TPamSession } from "@app/hooks/api/pam"; import { PamSessionStatusBadge } from "./PamSessionStatusBadge"; type Props = { session: TPamSession; search: string; filteredCommandLogs: TPamSession["commandLogs"]; }; export const PamSessionRow = ({ session, search, filteredCommandLogs }: Props) => { const router = useRouter(); const [showAllLogs, setShowAllLogs] = useState(false); const { id, accountName, resourceType, resourceName, projectId, status, actorName, actorEmail, createdAt, endedAt } = session; const { image, name: resourceTypeName } = PAM_RESOURCE_TYPE_MAP[resourceType]; const LOGS_TO_SHOW = 5; const logsToShow = showAllLogs ? filteredCommandLogs : filteredCommandLogs.slice(0, LOGS_TO_SHOW); return ( <> router.history.push(`/projects/pam/${projectId}/sessions/${id}`)} >
{resourceTypeName}
{new Date(createdAt).toLocaleTimeString()} {new Date(createdAt).toLocaleDateString()}
{endedAt ? (
{new Date(endedAt).toLocaleTimeString()} {new Date(endedAt).toLocaleDateString()}
) : ( Ongoing )}
{(isAllowed: boolean) => ( } onClick={() => router.history.push(`/projects/pam/${projectId}/sessions/${id}`) } > View Session )}
{filteredCommandLogs.length > 0 && ( {logsToShow.map((log) => (
{new Date(log.timestamp).toLocaleString()}
))} {filteredCommandLogs.length > LOGS_TO_SHOW && (
)} )} ); };