plugin-git-manager 1.2.12 → 1.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/900.ec1fa7f16eb8cce6.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client-v2/900.7a5e80bf21feda66.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +7 -7
- package/dist/locale/en-US.json +28 -1
- package/dist/locale/vi-VN.json +30 -1
- package/dist/server/actions/git-actions.js +6 -4
- package/dist/server/actions/review.js +40 -3
- package/dist/server/ai-tools.js +30 -0
- package/dist/server/collections/gitCodeReviews.js +8 -1
- package/dist/server/plugin.js +17 -10
- package/package.json +1 -1
- package/src/client/components/FileExplorer.tsx +63 -11
- package/src/client/components/ReviewFlows.tsx +33 -11
- package/src/client/components/ReviewHistory.tsx +45 -9
- package/src/client/components/RunReviewButton.tsx +436 -375
- package/src/client/promptTemplates.ts +31 -0
- package/src/locale/en-US.json +28 -1
- package/src/locale/vi-VN.json +30 -1
- package/src/server/actions/git-actions.ts +432 -430
- package/src/server/actions/review.ts +51 -7
- package/src/server/ai-tools.ts +32 -4
- package/src/server/collections/gitCodeReviews.ts +7 -0
- package/src/server/plugin.ts +250 -242
- package/dist/client/878.3e7b8b27c157996c.js +0 -10
- package/dist/client-v2/878.295f09c9d77ea6d8.js +0 -10
package/dist/server/ai-tools.js
CHANGED
|
@@ -253,6 +253,36 @@ function registerGitReviewAiTools(app) {
|
|
|
253
253
|
return (body == null ? void 0 : body.data) ?? body;
|
|
254
254
|
}
|
|
255
255
|
},
|
|
256
|
+
{
|
|
257
|
+
scope: "GENERAL",
|
|
258
|
+
execution: "backend",
|
|
259
|
+
defaultPermission: "ALLOW",
|
|
260
|
+
silence: false,
|
|
261
|
+
introduction: { title: "Git: List files" },
|
|
262
|
+
definition: {
|
|
263
|
+
name: "git_list_files",
|
|
264
|
+
description: "List files and folders of a cloned repository at a given ref. Set recursive=true with a treePath to enumerate every file under a folder, e.g. when reviewing the full code of a folder.",
|
|
265
|
+
schema: import_zod.z.object({
|
|
266
|
+
repositoryId: import_zod.z.number(),
|
|
267
|
+
treePath: import_zod.z.string().optional().describe("Folder path relative to repo root; omit for the root"),
|
|
268
|
+
ref: import_zod.z.string().optional().describe("Branch, tag or commit SHA; defaults to HEAD"),
|
|
269
|
+
recursive: import_zod.z.boolean().optional().describe("true to list all files under treePath recursively")
|
|
270
|
+
})
|
|
271
|
+
},
|
|
272
|
+
invoke: async (ctx, args) => {
|
|
273
|
+
const body = await runResourceAction(ctx, gitActions.fileTree, args, {
|
|
274
|
+
resource: "gitManager",
|
|
275
|
+
action: "fileTree"
|
|
276
|
+
});
|
|
277
|
+
const files = (body == null ? void 0 : body.data) ?? body ?? [];
|
|
278
|
+
const list = Array.isArray(files) ? files : [];
|
|
279
|
+
const MAX_ENTRIES = 500;
|
|
280
|
+
if (list.length > MAX_ENTRIES) {
|
|
281
|
+
return { files: list.slice(0, MAX_ENTRIES), totalCount: list.length, truncated: true };
|
|
282
|
+
}
|
|
283
|
+
return { files: list, totalCount: list.length, truncated: false };
|
|
284
|
+
}
|
|
285
|
+
},
|
|
256
286
|
{
|
|
257
287
|
scope: "GENERAL",
|
|
258
288
|
execution: "backend",
|
|
@@ -74,7 +74,8 @@ var gitCodeReviews_default = (0, import_database.defineCollection)({
|
|
|
74
74
|
enum: [
|
|
75
75
|
{ value: "mr", label: "Merge Request" },
|
|
76
76
|
{ value: "commit", label: "Commit" },
|
|
77
|
-
{ value: "branch", label: "Branch" }
|
|
77
|
+
{ value: "branch", label: "Branch" },
|
|
78
|
+
{ value: "folder", label: "Folder" }
|
|
78
79
|
]
|
|
79
80
|
}
|
|
80
81
|
},
|
|
@@ -96,6 +97,12 @@ var gitCodeReviews_default = (0, import_database.defineCollection)({
|
|
|
96
97
|
interface: "input",
|
|
97
98
|
uiSchema: { title: "Branch", type: "string", "x-component": "Input" }
|
|
98
99
|
},
|
|
100
|
+
{
|
|
101
|
+
type: "string",
|
|
102
|
+
name: "folderPath",
|
|
103
|
+
interface: "input",
|
|
104
|
+
uiSchema: { title: "Folder Path", type: "string", "x-component": "Input" }
|
|
105
|
+
},
|
|
99
106
|
{
|
|
100
107
|
type: "string",
|
|
101
108
|
name: "headSha",
|
package/dist/server/plugin.js
CHANGED
|
@@ -180,9 +180,7 @@ class PluginGitManagerServer extends import_server.Plugin {
|
|
|
180
180
|
});
|
|
181
181
|
this.app.acl.registerSnippet({
|
|
182
182
|
name: `pm.${this.name}.repositories`,
|
|
183
|
-
actions: [
|
|
184
|
-
"gitRepositories:*"
|
|
185
|
-
]
|
|
183
|
+
actions: ["gitRepositories:*"]
|
|
186
184
|
});
|
|
187
185
|
this.app.acl.registerSnippet({
|
|
188
186
|
name: `pm.${this.name}.manage`,
|
|
@@ -241,13 +239,22 @@ async function ensureAutoReviewFlowSchema(app) {
|
|
|
241
239
|
const queryInterface = (_b = sequelize == null ? void 0 : sequelize.getQueryInterface) == null ? void 0 : _b.call(sequelize);
|
|
242
240
|
if (!queryInterface) return;
|
|
243
241
|
const tablePrefix = ((_c = app.db.options) == null ? void 0 : _c.tablePrefix) || "";
|
|
244
|
-
const
|
|
245
|
-
const
|
|
246
|
-
if (
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
242
|
+
const repoTable = `${tablePrefix}gitRepositories`;
|
|
243
|
+
const repoInfo = await queryInterface.describeTable(repoTable).catch(() => null);
|
|
244
|
+
if (repoInfo && !repoInfo.autoReviewFlowId) {
|
|
245
|
+
await queryInterface.addColumn(repoTable, "autoReviewFlowId", {
|
|
246
|
+
type: import_sequelize.DataTypes.INTEGER,
|
|
247
|
+
allowNull: true
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
const reviewTable = `${tablePrefix}gitCodeReviews`;
|
|
251
|
+
const reviewInfo = await queryInterface.describeTable(reviewTable).catch(() => null);
|
|
252
|
+
if (reviewInfo && !reviewInfo.folderPath) {
|
|
253
|
+
await queryInterface.addColumn(reviewTable, "folderPath", {
|
|
254
|
+
type: import_sequelize.DataTypes.STRING,
|
|
255
|
+
allowNull: true
|
|
256
|
+
});
|
|
257
|
+
}
|
|
251
258
|
}
|
|
252
259
|
var plugin_default = PluginGitManagerServer;
|
|
253
260
|
// Annotate the CommonJS export names for ESM import in node:
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"displayName": "Git Manager",
|
|
4
4
|
"displayName.zh-CN": "Git 管理器",
|
|
5
5
|
"description": "Manage Git repositories with PAT authentication - pull, push, fetch, diff, file browsing",
|
|
6
|
-
"version": "1.2.
|
|
6
|
+
"version": "1.2.14",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"main": "dist/server/index.js",
|
|
9
9
|
"files": [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useState, useCallback, useRef } from 'react';
|
|
1
|
+
import React, { useEffect, useState, useCallback, useMemo, useRef } from 'react';
|
|
2
2
|
import { Tree, Empty, Spin, Typography, Select, Space, Breadcrumb, Input, theme } from 'antd';
|
|
3
3
|
import {
|
|
4
4
|
FileOutlined,
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from '@ant-design/icons';
|
|
11
11
|
import { useApp } from '@nocobase/client-v2';
|
|
12
12
|
import { useGitManager } from '../context/GitManagerContext';
|
|
13
|
+
import { RunReviewButton } from './RunReviewButton';
|
|
13
14
|
import { useT } from '../locale';
|
|
14
15
|
|
|
15
16
|
const { Text } = Typography;
|
|
@@ -40,10 +41,25 @@ function getFileIcon(name: string, type: string) {
|
|
|
40
41
|
function getLanguage(filename: string): string {
|
|
41
42
|
const ext = filename.split('.').pop()?.toLowerCase() || '';
|
|
42
43
|
const map: Record<string, string> = {
|
|
43
|
-
ts: 'typescript',
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
ts: 'typescript',
|
|
45
|
+
tsx: 'typescript',
|
|
46
|
+
js: 'javascript',
|
|
47
|
+
jsx: 'javascript',
|
|
48
|
+
json: 'json',
|
|
49
|
+
md: 'markdown',
|
|
50
|
+
html: 'html',
|
|
51
|
+
css: 'css',
|
|
52
|
+
scss: 'scss',
|
|
53
|
+
py: 'python',
|
|
54
|
+
sh: 'bash',
|
|
55
|
+
yml: 'yaml',
|
|
56
|
+
yaml: 'yaml',
|
|
57
|
+
sql: 'sql',
|
|
58
|
+
xml: 'xml',
|
|
59
|
+
java: 'java',
|
|
60
|
+
go: 'go',
|
|
61
|
+
rs: 'rust',
|
|
62
|
+
rb: 'ruby',
|
|
47
63
|
};
|
|
48
64
|
return map[ext] || 'text';
|
|
49
65
|
}
|
|
@@ -67,6 +83,7 @@ export const FileExplorer: React.FC = () => {
|
|
|
67
83
|
const [loading, setLoading] = useState(false);
|
|
68
84
|
const [fileContent, setFileContent] = useState<string | null>(null);
|
|
69
85
|
const [selectedFile, setSelectedFile] = useState<string | null>(null);
|
|
86
|
+
const [selectedFolder, setSelectedFolder] = useState<string | null>(null);
|
|
70
87
|
const [currentRef, setCurrentRef] = useState('HEAD');
|
|
71
88
|
const [searchText, setSearchText] = useState('');
|
|
72
89
|
const [debouncedSearch, setDebouncedSearch] = useState('');
|
|
@@ -81,8 +98,12 @@ export const FileExplorer: React.FC = () => {
|
|
|
81
98
|
params: { repositoryId: selectedRepo.id, ref, treePath },
|
|
82
99
|
});
|
|
83
100
|
const responseData = data?.data || data || [];
|
|
84
|
-
const list = Array.isArray(responseData)
|
|
85
|
-
|
|
101
|
+
const list = Array.isArray(responseData)
|
|
102
|
+
? responseData
|
|
103
|
+
: Array.isArray(responseData?.data)
|
|
104
|
+
? responseData.data
|
|
105
|
+
: [];
|
|
106
|
+
|
|
86
107
|
return list.map((item: any) => ({
|
|
87
108
|
key: item.path,
|
|
88
109
|
title: (
|
|
@@ -123,6 +144,7 @@ export const FileExplorer: React.FC = () => {
|
|
|
123
144
|
refreshBranches();
|
|
124
145
|
setFileContent(null);
|
|
125
146
|
setSelectedFile(null);
|
|
147
|
+
setSelectedFolder(null);
|
|
126
148
|
} else {
|
|
127
149
|
setTreeData([]);
|
|
128
150
|
}
|
|
@@ -149,7 +171,11 @@ export const FileExplorer: React.FC = () => {
|
|
|
149
171
|
|
|
150
172
|
const onSelect = async (_: any, info: any) => {
|
|
151
173
|
const node = info.node;
|
|
152
|
-
if (!node.isLeaf)
|
|
174
|
+
if (!node.isLeaf) {
|
|
175
|
+
setSelectedFolder((prev) => (prev === node.filePath ? null : node.filePath));
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
setSelectedFolder(null);
|
|
153
179
|
setContentLoading(true);
|
|
154
180
|
setSelectedFile(node.filePath);
|
|
155
181
|
try {
|
|
@@ -173,6 +199,16 @@ export const FileExplorer: React.FC = () => {
|
|
|
173
199
|
return () => clearTimeout(debounceRef.current);
|
|
174
200
|
}, [searchText]);
|
|
175
201
|
|
|
202
|
+
const folderTarget = useMemo(
|
|
203
|
+
() => ({
|
|
204
|
+
type: 'folder' as const,
|
|
205
|
+
repositoryId: selectedRepo?.id ?? 0,
|
|
206
|
+
folderPath: selectedFolder ?? '',
|
|
207
|
+
ref: currentRef,
|
|
208
|
+
}),
|
|
209
|
+
[selectedRepo?.id, selectedFolder, currentRef],
|
|
210
|
+
);
|
|
211
|
+
|
|
176
212
|
if (!selectedRepo) {
|
|
177
213
|
return <Empty description={t('No repository selected')} />;
|
|
178
214
|
}
|
|
@@ -206,6 +242,7 @@ export const FileExplorer: React.FC = () => {
|
|
|
206
242
|
setCurrentRef(val);
|
|
207
243
|
setFileContent(null);
|
|
208
244
|
setSelectedFile(null);
|
|
245
|
+
setSelectedFolder(null);
|
|
209
246
|
}}
|
|
210
247
|
options={branchList.map((b) => ({ label: b, value: b }))}
|
|
211
248
|
placeholder="Branch"
|
|
@@ -216,18 +253,31 @@ export const FileExplorer: React.FC = () => {
|
|
|
216
253
|
allowClear
|
|
217
254
|
onChange={(e) => setSearchText(e.target.value)}
|
|
218
255
|
/>
|
|
256
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
|
257
|
+
<Text
|
|
258
|
+
type="secondary"
|
|
259
|
+
ellipsis
|
|
260
|
+
title={selectedFolder || t('Entire repository')}
|
|
261
|
+
style={{ flex: 1, minWidth: 0, fontSize: 12 }}
|
|
262
|
+
>
|
|
263
|
+
{selectedFolder || t('Entire repository')}
|
|
264
|
+
</Text>
|
|
265
|
+
<RunReviewButton target={folderTarget} />
|
|
266
|
+
</div>
|
|
219
267
|
</Space>
|
|
220
268
|
</div>
|
|
221
269
|
<div style={{ flex: 1, overflow: 'auto', padding: '4px 0' }}>
|
|
222
270
|
{loading ? (
|
|
223
|
-
<div style={{ textAlign: 'center', padding: 40 }}
|
|
271
|
+
<div style={{ textAlign: 'center', padding: 40 }}>
|
|
272
|
+
<Spin />
|
|
273
|
+
</div>
|
|
224
274
|
) : (
|
|
225
275
|
<Tree
|
|
226
276
|
showIcon
|
|
227
277
|
treeData={filteredTree}
|
|
228
278
|
loadData={onLoadData}
|
|
229
279
|
onSelect={onSelect}
|
|
230
|
-
selectedKeys={selectedFile ? [selectedFile] : []}
|
|
280
|
+
selectedKeys={selectedFile ? [selectedFile] : selectedFolder ? [selectedFolder] : []}
|
|
231
281
|
style={{ fontSize: 13 }}
|
|
232
282
|
blockNode
|
|
233
283
|
/>
|
|
@@ -260,7 +310,9 @@ export const FileExplorer: React.FC = () => {
|
|
|
260
310
|
</div>
|
|
261
311
|
<div style={{ flex: 1, overflow: 'auto' }}>
|
|
262
312
|
{contentLoading ? (
|
|
263
|
-
<div style={{ textAlign: 'center', padding: 40 }}
|
|
313
|
+
<div style={{ textAlign: 'center', padding: 40 }}>
|
|
314
|
+
<Spin />
|
|
315
|
+
</div>
|
|
264
316
|
) : (
|
|
265
317
|
<pre
|
|
266
318
|
style={{
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import {
|
|
3
|
-
Table,
|
|
3
|
+
Table,
|
|
4
|
+
Button,
|
|
5
|
+
Space,
|
|
6
|
+
Modal,
|
|
7
|
+
Form,
|
|
8
|
+
Input,
|
|
9
|
+
Select,
|
|
10
|
+
Switch,
|
|
11
|
+
Tag,
|
|
12
|
+
Popconfirm,
|
|
13
|
+
message,
|
|
14
|
+
Empty,
|
|
15
|
+
Tooltip,
|
|
4
16
|
} from 'antd';
|
|
5
17
|
import { PlusOutlined, EditOutlined, DeleteOutlined, BranchesOutlined } from '@ant-design/icons';
|
|
6
18
|
import { useApp } from '@nocobase/client-v2';
|
|
@@ -8,6 +20,7 @@ import { useGitManager } from '../context/GitManagerContext';
|
|
|
8
20
|
import { AIEmployeeSelect } from './AIEmployeeSelect';
|
|
9
21
|
import { LLMServiceSelect } from './LLMServiceSelect';
|
|
10
22
|
import { LLMModelSelect } from './LLMModelSelect';
|
|
23
|
+
import { REVIEW_PROMPT_TEMPLATES } from '../promptTemplates';
|
|
11
24
|
import { useT } from '../locale';
|
|
12
25
|
|
|
13
26
|
const TRIGGER_LABELS: Record<string, string> = {
|
|
@@ -22,15 +35,6 @@ const POST_LABELS: Record<string, string> = {
|
|
|
22
35
|
disabled: 'Disabled',
|
|
23
36
|
};
|
|
24
37
|
|
|
25
|
-
const DEFAULT_INSTRUCTION = `Please review the code changes with a focus on:
|
|
26
|
-
1. Best Practices & Style:
|
|
27
|
-
- C#/VB.NET: Follow standard naming conventions (PascalCase for methods/properties, camelCase for fields). Ensure proper use of async/await (avoid .Result/.Wait()). Use LINQ efficiently.
|
|
28
|
-
- JS/TS: Use strict equality (===), prefer const/let. Ensure TypeScript types are explicit and avoid 'any'.
|
|
29
|
-
2. Performance: Watch out for N+1 queries, unnecessary loops, and memory leaks.
|
|
30
|
-
3. Security: Identify potential SQL injections, XSS vulnerabilities, and improper data validation.
|
|
31
|
-
4. Maintainability: Check for readability, SOLID principles, and DRY. Ensure meaningful naming.
|
|
32
|
-
5. Error Handling: Verify that exceptions are properly caught, handled, and logged.`;
|
|
33
|
-
|
|
34
38
|
export const ReviewFlows: React.FC = () => {
|
|
35
39
|
const t = useT();
|
|
36
40
|
const api = useApp().apiClient;
|
|
@@ -39,6 +43,7 @@ export const ReviewFlows: React.FC = () => {
|
|
|
39
43
|
const [loading, setLoading] = useState(false);
|
|
40
44
|
const [editing, setEditing] = useState<any | null>(null);
|
|
41
45
|
const [open, setOpen] = useState(false);
|
|
46
|
+
const [templateKey, setTemplateKey] = useState<string | undefined>();
|
|
42
47
|
const [form] = Form.useForm();
|
|
43
48
|
|
|
44
49
|
const load = useCallback(async () => {
|
|
@@ -76,6 +81,7 @@ export const ReviewFlows: React.FC = () => {
|
|
|
76
81
|
}
|
|
77
82
|
setOpen(false);
|
|
78
83
|
setEditing(null);
|
|
84
|
+
setTemplateKey(undefined);
|
|
79
85
|
form.resetFields();
|
|
80
86
|
load();
|
|
81
87
|
} catch (err: any) {
|
|
@@ -97,17 +103,19 @@ export const ReviewFlows: React.FC = () => {
|
|
|
97
103
|
const openCreate = () => {
|
|
98
104
|
setEditing(null);
|
|
99
105
|
form.resetFields();
|
|
106
|
+
setTemplateKey('application');
|
|
100
107
|
form.setFieldsValue({
|
|
101
108
|
enabled: true,
|
|
102
109
|
triggerMode: 'manual',
|
|
103
110
|
postMode: 'manual',
|
|
104
|
-
instructions:
|
|
111
|
+
instructions: REVIEW_PROMPT_TEMPLATES.find((tpl) => tpl.key === 'application')?.text,
|
|
105
112
|
});
|
|
106
113
|
setOpen(true);
|
|
107
114
|
};
|
|
108
115
|
|
|
109
116
|
const openEdit = (record: any) => {
|
|
110
117
|
setEditing(record);
|
|
118
|
+
setTemplateKey(undefined);
|
|
111
119
|
form.setFieldsValue(record);
|
|
112
120
|
setOpen(true);
|
|
113
121
|
};
|
|
@@ -200,6 +208,7 @@ export const ReviewFlows: React.FC = () => {
|
|
|
200
208
|
onCancel={() => {
|
|
201
209
|
setOpen(false);
|
|
202
210
|
setEditing(null);
|
|
211
|
+
setTemplateKey(undefined);
|
|
203
212
|
form.resetFields();
|
|
204
213
|
}}
|
|
205
214
|
onOk={handleSave}
|
|
@@ -268,6 +277,19 @@ export const ReviewFlows: React.FC = () => {
|
|
|
268
277
|
<Form.Item name="branchFilter" label={t('Branch Filter (regex, optional)')}>
|
|
269
278
|
<Input placeholder="^(feature|hotfix)/.*$" />
|
|
270
279
|
</Form.Item>
|
|
280
|
+
<Form.Item label={t('Prompt template')} extra={t('Selecting a template replaces the instructions text')}>
|
|
281
|
+
<Select
|
|
282
|
+
allowClear
|
|
283
|
+
value={templateKey}
|
|
284
|
+
placeholder={t('Load a default prompt by code type')}
|
|
285
|
+
options={REVIEW_PROMPT_TEMPLATES.map((tpl) => ({ value: tpl.key, label: t(tpl.label) }))}
|
|
286
|
+
onChange={(key) => {
|
|
287
|
+
setTemplateKey(key);
|
|
288
|
+
const tpl = REVIEW_PROMPT_TEMPLATES.find((item) => item.key === key);
|
|
289
|
+
if (tpl) form.setFieldsValue({ instructions: tpl.text });
|
|
290
|
+
}}
|
|
291
|
+
/>
|
|
292
|
+
</Form.Item>
|
|
271
293
|
<Form.Item name="instructions" label={t('Additional Instructions (optional)')}>
|
|
272
294
|
<Input.TextArea rows={8} placeholder={t('Extra guidance appended to every review prompt')} />
|
|
273
295
|
</Form.Item>
|
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import {
|
|
3
|
-
Table,
|
|
3
|
+
Table,
|
|
4
|
+
Tag,
|
|
5
|
+
Drawer,
|
|
6
|
+
Space,
|
|
7
|
+
Button,
|
|
8
|
+
Typography,
|
|
9
|
+
Empty,
|
|
10
|
+
Tooltip,
|
|
11
|
+
Popconfirm,
|
|
12
|
+
message,
|
|
13
|
+
Select,
|
|
14
|
+
Tabs,
|
|
15
|
+
Input,
|
|
16
|
+
Alert,
|
|
17
|
+
theme,
|
|
4
18
|
} from 'antd';
|
|
5
19
|
import {
|
|
6
|
-
RobotOutlined,
|
|
7
|
-
|
|
20
|
+
RobotOutlined,
|
|
21
|
+
ReloadOutlined,
|
|
22
|
+
CheckOutlined,
|
|
23
|
+
CloseOutlined,
|
|
24
|
+
ClockCircleOutlined,
|
|
25
|
+
FileTextOutlined,
|
|
26
|
+
ExportOutlined,
|
|
27
|
+
EditOutlined,
|
|
8
28
|
} from '@ant-design/icons';
|
|
9
29
|
import { useApp } from '@nocobase/client-v2';
|
|
10
30
|
import { useGitManager } from '../context/GitManagerContext';
|
|
@@ -30,9 +50,7 @@ const POST_STATUS_COLOR: Record<string, string> = {
|
|
|
30
50
|
rejected: 'red',
|
|
31
51
|
};
|
|
32
52
|
|
|
33
|
-
export const ReviewHistory: React.FC<{ initialFilter?: 'all' | 'pending_approval' }> = ({
|
|
34
|
-
initialFilter = 'all',
|
|
35
|
-
}) => {
|
|
53
|
+
export const ReviewHistory: React.FC<{ initialFilter?: 'all' | 'pending_approval' }> = ({ initialFilter = 'all' }) => {
|
|
36
54
|
const t = useT();
|
|
37
55
|
const { token } = useToken();
|
|
38
56
|
const api = useApp().apiClient;
|
|
@@ -40,7 +58,9 @@ export const ReviewHistory: React.FC<{ initialFilter?: 'all' | 'pending_approval
|
|
|
40
58
|
const [reviews, setReviews] = useState<any[]>([]);
|
|
41
59
|
const [loading, setLoading] = useState(false);
|
|
42
60
|
const [statusFilter, setStatusFilter] = useState<string>('all');
|
|
43
|
-
const [postFilter, setPostFilter] = useState<string>(
|
|
61
|
+
const [postFilter, setPostFilter] = useState<string>(
|
|
62
|
+
initialFilter === 'pending_approval' ? 'pending_approval' : 'all',
|
|
63
|
+
);
|
|
44
64
|
const [triggerFilter, setTriggerFilter] = useState<string>('all');
|
|
45
65
|
const [selected, setSelected] = useState<any | null>(null);
|
|
46
66
|
const [editing, setEditing] = useState(false);
|
|
@@ -154,6 +174,15 @@ export const ReviewHistory: React.FC<{ initialFilter?: 'all' | 'pending_approval
|
|
|
154
174
|
</Space>
|
|
155
175
|
);
|
|
156
176
|
}
|
|
177
|
+
if (record.targetType === 'folder') {
|
|
178
|
+
return (
|
|
179
|
+
<Space size={4}>
|
|
180
|
+
<Text strong>{repoName}</Text>
|
|
181
|
+
<Text type="secondary">{record.folderPath || '/'}</Text>
|
|
182
|
+
{record.branch && <Tag style={{ fontSize: 11 }}>{record.branch}</Tag>}
|
|
183
|
+
</Space>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
157
186
|
return (
|
|
158
187
|
<Space size={4}>
|
|
159
188
|
<Text strong>{repoName}</Text>
|
|
@@ -497,12 +526,19 @@ const ReviewDetailView: React.FC<{
|
|
|
497
526
|
<Meta label={t('Status')} value={review.status} />
|
|
498
527
|
<Meta label={t('Post Status')} value={review.postStatus} />
|
|
499
528
|
<Meta label={t('Trigger Type')} value={review.targetType} />
|
|
529
|
+
{review.targetType === 'folder' && <Meta label={t('Folder')} value={review.folderPath || '/'} />}
|
|
500
530
|
<Meta label={t('Triggered By')} value={review.triggeredBy} />
|
|
501
531
|
<Meta label={t('Reviewed SHA')} value={review.headSha || '—'} />
|
|
502
532
|
<Meta label={t('Latest SHA')} value={review.latestSha || '—'} />
|
|
503
533
|
<Meta label={t('Started At')} value={review.startedAt && new Date(review.startedAt).toLocaleString()} />
|
|
504
|
-
<Meta
|
|
505
|
-
|
|
534
|
+
<Meta
|
|
535
|
+
label={t('Finished At')}
|
|
536
|
+
value={review.finishedAt && new Date(review.finishedAt).toLocaleString()}
|
|
537
|
+
/>
|
|
538
|
+
<Meta
|
|
539
|
+
label={t('Duration')}
|
|
540
|
+
value={review.durationMs ? `${(review.durationMs / 1000).toFixed(1)}s` : '—'}
|
|
541
|
+
/>
|
|
506
542
|
<Meta label={t('Posted Note ID')} value={review.postedNoteId || '—'} />
|
|
507
543
|
<Meta label={t('Approved By')} value={review.approvedBy || '—'} />
|
|
508
544
|
<Meta
|