Skip to content

Commit 3ad52c0

Browse files
committed
add audit logs
1 parent 04c1a76 commit 3ad52c0

File tree

4 files changed

+60
-3
lines changed

4 files changed

+60
-3
lines changed

client/packages/lowcoder/src/pages/setting/environments/components/DeployableItemsList.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ function DeployableItemsList<T extends DeployableItem, S extends BaseStats>({
3131

3232
const { openDeployModal } = useDeployModal();
3333

34+
// Open audit page
35+
const openAuditPage = (item: T, e: React.MouseEvent) => {
36+
e.stopPropagation();
37+
if (config.audit?.getAuditUrl) {
38+
const auditUrl = config.audit.getAuditUrl(item, environment, additionalParams);
39+
window.open(auditUrl, '_blank');
40+
}
41+
};
42+
3443

3544
// Handle row click for navigation
3645
// Handle row click for navigation
@@ -103,6 +112,25 @@ const handleRowClick = (item: T) => {
103112
});
104113
}
105114

115+
const hasAudit = config.audit?.enabled;
116+
117+
// Add audit column if enabled - SEPARATE CONDITION
118+
if (config.audit?.enabled) {
119+
columns.push({
120+
title: 'Audit',
121+
key: 'audit',
122+
render: (_, record: T) => (
123+
<Tooltip title={config.audit?.tooltip || `View audit logs`}>
124+
<Button
125+
icon={config.audit?.icon}
126+
onClick={(e) => openAuditPage(record, e)}
127+
>
128+
{config.audit?.label || 'Audit'}
129+
</Button>
130+
</Tooltip>
131+
),
132+
});
133+
}
106134

107135
if (loading) {
108136
return (

client/packages/lowcoder/src/pages/setting/environments/config/apps.config.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// config/apps.config.tsx
22
import React from 'react';
33
import { Row, Col, Statistic, Tag, Space, Button, Tooltip } from 'antd';
4-
import { AppstoreOutlined, CloudUploadOutlined } from '@ant-design/icons';
4+
import { AppstoreOutlined, AuditOutlined } from '@ant-design/icons';
55
import {DeployableItemConfig } from '../types/deployable-item.types';
66
import { Environment } from '../types/environment.types';
77
import { getMergedWorkspaceApps, deployApp } from '../services/apps.service';
@@ -105,7 +105,16 @@ export const appsConfig: DeployableItemConfig<App, AppStats> = {
105105
id: app.applicationId // Map applicationId to id for DeployableItem compatibility
106106
}));
107107
},
108-
108+
audit: {
109+
enabled: true,
110+
icon: <AuditOutlined />,
111+
label: 'Audit',
112+
tooltip: 'View audit logs for this app',
113+
getAuditUrl: (item, environment, additionalParams) => {
114+
console.log("Additional params:", additionalParams);
115+
return `/setting/audit?environmentId=${environment.environmentId}&orgId=${item.id}&appId=${additionalParams?.workspaceId}&pageSize=100&pageNum=1`
116+
}
117+
},
109118
toggleManaged: async ({ item, checked, environment }) => {
110119
try {
111120
if (checked) {

client/packages/lowcoder/src/pages/setting/environments/config/workspace.config.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// config/workspace.config.tsx
22
import React from 'react';
33
import { Row, Col, Statistic, Tag } from 'antd';
4-
import { ClusterOutlined } from '@ant-design/icons';
4+
import { ClusterOutlined, AuditOutlined } from '@ant-design/icons';
55
import { Workspace, WorkspaceStats, DeployableItemConfig } from '../types/deployable-item.types';
66
import { buildEnvironmentWorkspaceId } from '@lowcoder-ee/constants/routesURL';
77
import { getMergedEnvironmentWorkspaces } from '../services/workspace.service';
@@ -99,6 +99,15 @@ export const workspaceConfig: DeployableItemConfig<Workspace, WorkspaceStats> =
9999
);
100100
return result.workspaces;
101101
},
102+
103+
audit: {
104+
enabled: true,
105+
icon: <AuditOutlined />,
106+
label: 'Audit',
107+
tooltip: 'View audit logs for this workspace',
108+
getAuditUrl: (item, environment) =>
109+
`/setting/audit?environmentId=${environment.environmentId}&orgId=${item.id}&pageSize=100&pageNum=1`
110+
},
102111

103112
toggleManaged: async ({ item, checked, environment }) => {
104113
try {

client/packages/lowcoder/src/pages/setting/environments/types/deployable-item.types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import { ReactNode } from 'react';
33
import { Environment } from './environment.types';
44

55
// Base interface for all deployable items
6+
export interface AuditConfig {
7+
enabled: boolean;
8+
icon?: React.ReactNode;
9+
label?: string;
10+
tooltip?: string;
11+
getAuditUrl: (item: any, environment: Environment, additionalParams?: Record<string, any>) => string;
12+
}
613
export interface DeployableItem {
714
id: string;
815
name: string;
@@ -61,6 +68,10 @@ export interface DeployableItemConfig<T extends DeployableItem, S extends BaseSt
6168
// Stats
6269
renderStats: (stats: S) => ReactNode;
6370
calculateStats: (items: T[]) => S;
71+
72+
// Add audit configuration
73+
audit?: AuditConfig;
74+
6475

6576
// Table configuration
6677
columns: Array<{

0 commit comments

Comments
 (0)