fix: audit log fixes

This commit is contained in:
Daniel Hougaard
2024-09-09 10:42:39 +04:00
parent 26add7bfd1
commit 372b6cbaea
4 changed files with 9 additions and 4 deletions
@@ -12,7 +12,7 @@ export const AuditLogsPage = withProjectPermission(
<p className="text-3xl font-semibold text-gray-200">Audit Logs</p> <p className="text-3xl font-semibold text-gray-200">Audit Logs</p>
<div /> <div />
</div> </div>
<LogsSection /> <LogsSection showFilters />
</div> </div>
</div> </div>
); );
@@ -68,6 +68,7 @@ export const LogsSection = ({
isOrgAuditLogs={isOrgAuditLogs} isOrgAuditLogs={isOrgAuditLogs}
eventType={eventType} eventType={eventType}
userAgentType={userAgentType} userAgentType={userAgentType}
showActorColumn={!presetActor}
actor={actor} actor={actor}
startDate={startDate} startDate={startDate}
endDate={endDate} endDate={endDate}
@@ -26,6 +26,7 @@ type Props = {
startDate?: Date; startDate?: Date;
endDate?: Date; endDate?: Date;
isOrgAuditLogs?: boolean; isOrgAuditLogs?: boolean;
showActorColumn: boolean;
}; };
const AUDIT_LOG_LIMIT = 15; const AUDIT_LOG_LIMIT = 15;
@@ -33,6 +34,7 @@ const AUDIT_LOG_LIMIT = 15;
export const LogsTable = ({ export const LogsTable = ({
eventType, eventType,
userAgentType, userAgentType,
showActorColumn,
actor, actor,
startDate, startDate,
endDate, endDate,
@@ -63,7 +65,7 @@ export const LogsTable = ({
<Th>Timestamp</Th> <Th>Timestamp</Th>
<Th>Event</Th> <Th>Event</Th>
{isOrgAuditLogs && <Th>Project</Th>} {isOrgAuditLogs && <Th>Project</Th>}
<Th>Actor</Th> {showActorColumn && <Th>Actor</Th>}
<Th>Source</Th> <Th>Source</Th>
<Th>Metadata</Th> <Th>Metadata</Th>
</Tr> </Tr>
@@ -74,6 +76,7 @@ export const LogsTable = ({
<Fragment key={`auditlog-item-${i + 1}`}> <Fragment key={`auditlog-item-${i + 1}`}>
{group.map((auditLog) => ( {group.map((auditLog) => (
<LogsTableRow <LogsTableRow
showActorColumn={showActorColumn}
isOrgAuditLogs={isOrgAuditLogs} isOrgAuditLogs={isOrgAuditLogs}
auditLog={auditLog} auditLog={auditLog}
key={`audit-log-${auditLog.id}`} key={`audit-log-${auditLog.id}`}
@@ -6,9 +6,10 @@ import { Actor, AuditLog, Event } from "@app/hooks/api/auditLogs/types";
type Props = { type Props = {
auditLog: AuditLog; auditLog: AuditLog;
isOrgAuditLogs?: boolean; isOrgAuditLogs?: boolean;
showActorColumn: boolean;
}; };
export const LogsTableRow = ({ auditLog, isOrgAuditLogs }: Props) => { export const LogsTableRow = ({ auditLog, isOrgAuditLogs, showActorColumn }: Props) => {
const renderActor = (actor: Actor) => { const renderActor = (actor: Actor) => {
switch (actor.type) { switch (actor.type) {
case ActorType.USER: case ActorType.USER:
@@ -471,7 +472,7 @@ export const LogsTableRow = ({ auditLog, isOrgAuditLogs }: Props) => {
<Td>{formatDate(auditLog.createdAt)}</Td> <Td>{formatDate(auditLog.createdAt)}</Td>
<Td>{`${eventToNameMap[auditLog.event.type]}`}</Td> <Td>{`${eventToNameMap[auditLog.event.type]}`}</Td>
{isOrgAuditLogs && <Td>{auditLog.project.name}</Td>} {isOrgAuditLogs && <Td>{auditLog.project.name}</Td>}
{renderActor(auditLog.actor)} {showActorColumn && renderActor(auditLog.actor)}
<Td> <Td>
<p>{userAgentTTypeoNameMap[auditLog.userAgentType]}</p> <p>{userAgentTTypeoNameMap[auditLog.userAgentType]}</p>
<p>{auditLog.ipAddress}</p> <p>{auditLog.ipAddress}</p>