import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { Td, Tooltip, Tr } from "@app/components/v2"; import { eventToNameMap, userAgentTTypeoNameMap } from "@app/hooks/api/auditLogs/constants"; import { ActorType, EventType } from "@app/hooks/api/auditLogs/enums"; import { Actor, AuditLog } from "@app/hooks/api/auditLogs/types"; type Props = { auditLog: AuditLog; isOrgAuditLogs?: boolean; showActorColumn: boolean; }; export const LogsTableRow = ({ auditLog, isOrgAuditLogs, showActorColumn }: Props) => { const renderActor = (actor: Actor) => { if (!actor) { return ; } switch (actor.type) { case ActorType.USER: return (

{actor.metadata.email}

User

); case ActorType.SERVICE: return (

{`${actor.metadata.name}`}

Service token

); case ActorType.IDENTITY: return (

{`${actor.metadata.name}`}

Machine Identity

); case ActorType.UNKNOWN_USER: return (

Unknown User

); default: return ; } }; const formatDate = (dateToFormat: string) => { const date = new Date(dateToFormat); const year = date.getFullYear(); const month = String(date.getMonth() + 1).padStart(2, "0"); const day = String(date.getDate()).padStart(2, "0"); let hours = date.getHours(); const minutes = String(date.getMinutes()).padStart(2, "0"); // convert from 24h to 12h format const period = hours >= 12 ? "PM" : "AM"; hours %= 12; hours = hours || 12; // the hour '0' should be '12' const formattedDate = `${day}-${month}-${year} at ${hours}:${minutes} ${period}`; return formattedDate; }; const renderSource = () => { const { event, actor } = auditLog; if (event.type === EventType.INTEGRATION_SYNCED) { if (actor.type === ActorType.USER) { return (

Manually triggered by {actor.metadata.email}

); } // Platform / automatic syncs return (

Automatically synced by Infisical

); } return (

{userAgentTTypeoNameMap[auditLog.userAgentType]}

{auditLog.ipAddress}

); }; return ( {formatDate(auditLog.createdAt)} {`${eventToNameMap[auditLog.event.type]}`} {isOrgAuditLogs && {auditLog?.projectName ?? auditLog?.projectId ?? "N/A"}} {showActorColumn && renderActor(auditLog.actor)} {renderSource()} {JSON.stringify(auditLog.event.metadata || {})} ); };