mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 14:28:20 +00:00
feat: project-independent log support
This commit is contained in:
@@ -122,10 +122,12 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
})
|
})
|
||||||
.merge(
|
.merge(
|
||||||
z.object({
|
z.object({
|
||||||
project: z.object({
|
project: z
|
||||||
name: z.string(),
|
.object({
|
||||||
slug: z.string()
|
name: z.string(),
|
||||||
}),
|
slug: z.string()
|
||||||
|
})
|
||||||
|
.optional(),
|
||||||
event: z.object({
|
event: z.object({
|
||||||
type: z.string(),
|
type: z.string(),
|
||||||
metadata: z.any()
|
metadata: z.any()
|
||||||
|
|||||||
@@ -55,8 +55,7 @@ export const auditLogDALFactory = (db: TDbClient) => {
|
|||||||
// eslint-disable-next-line func-names
|
// eslint-disable-next-line func-names
|
||||||
.where(function () {
|
.where(function () {
|
||||||
if (orgId) {
|
if (orgId) {
|
||||||
void this.where(`${TableName.Project}.orgId`, orgId);
|
void this.where(`${TableName.Project}.orgId`, orgId).orWhere(`${TableName.AuditLog}.orgId`, orgId);
|
||||||
// .orWhere(`${TableName.AuditLog}.orgId`, orgId);
|
|
||||||
} else if (projectId) {
|
} else if (projectId) {
|
||||||
void this.where(`${TableName.AuditLog}.projectId`, projectId);
|
void this.where(`${TableName.AuditLog}.projectId`, projectId);
|
||||||
}
|
}
|
||||||
@@ -114,10 +113,12 @@ export const auditLogDALFactory = (db: TDbClient) => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...AuditLogsSchema.parse(doc),
|
...AuditLogsSchema.parse(doc),
|
||||||
project: {
|
...(projectDoc?.projectSlug && {
|
||||||
name: projectDoc.projectName,
|
project: {
|
||||||
slug: projectDoc.projectSlug
|
name: projectDoc.projectName,
|
||||||
}
|
slug: projectDoc.projectSlug
|
||||||
|
}
|
||||||
|
})
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -120,10 +120,12 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
|
|||||||
})
|
})
|
||||||
.merge(
|
.merge(
|
||||||
z.object({
|
z.object({
|
||||||
project: z.object({
|
project: z
|
||||||
name: z.string(),
|
.object({
|
||||||
slug: z.string()
|
name: z.string(),
|
||||||
}),
|
slug: z.string()
|
||||||
|
})
|
||||||
|
.optional(),
|
||||||
event: z.object({
|
event: z.object({
|
||||||
type: z.string(),
|
type: z.string(),
|
||||||
metadata: z.any()
|
metadata: z.any()
|
||||||
|
|||||||
@@ -886,7 +886,7 @@ export type AuditLog = {
|
|||||||
userAgentType: UserAgentType;
|
userAgentType: UserAgentType;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
project: {
|
project?: {
|
||||||
name: string;
|
name: string;
|
||||||
slug: string;
|
slug: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -531,7 +531,7 @@ export const LogsTableRow = ({ auditLog, isOrgAuditLogs, showActorColumn }: Prop
|
|||||||
<Tr className={`log-${auditLog.id} h-10 border-x-0 border-b border-t-0`}>
|
<Tr className={`log-${auditLog.id} h-10 border-x-0 border-b border-t-0`}>
|
||||||
<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 ?? "N/A"}</Td>}
|
||||||
{showActorColumn && renderActor(auditLog.actor)}
|
{showActorColumn && renderActor(auditLog.actor)}
|
||||||
{renderSource()}
|
{renderSource()}
|
||||||
{renderMetadata(auditLog.event)}
|
{renderMetadata(auditLog.event)}
|
||||||
|
|||||||
Reference in New Issue
Block a user