plugin-git-manager 1.2.27 → 1.3.1
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/README.md +151 -108
- package/client-v2.d.ts +2 -2
- package/client-v2.js +1 -1
- package/client.d.ts +3 -3
- package/client.js +1 -1
- package/dist/client/{326.90c276058682b536.js → 313.d38fc1d40c4589b9.js} +1 -1
- package/dist/client/941.1793e67472872992.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client-v2/156.445366026c1cc9a8.js +10 -0
- package/dist/client-v2/{326.42b7b53651ffab3a.js → 313.3c867179c3a1e817.js} +1 -1
- package/dist/client-v2/434.19c7579c06b9077c.js +10 -0
- package/dist/client-v2/928.bba701b5a1ece58e.js +10 -0
- package/dist/client-v2/941.b0d55429cd053f32.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +9 -8
- package/dist/locale/en-US.json +396 -297
- package/dist/locale/vi-VN.json +384 -292
- package/dist/locale/zh-CN.json +150 -51
- package/dist/node_modules/simple-git/dist/cjs/index.js +25 -25
- package/dist/node_modules/simple-git/package.json +1 -1
- package/dist/node_modules/zod/index.cjs +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/actions/git-actions.js +90 -36
- package/dist/server/actions/gitlab-api.js +4 -2
- package/dist/server/actions/poller.js +5 -2
- package/dist/server/actions/review-cutover.js +137 -0
- package/dist/server/actions/review.js +150 -51
- package/dist/server/actions/role-permissions.js +1 -0
- package/dist/server/ai-tools.js +8 -9
- package/dist/server/collections/gitCodeReviews.js +10 -0
- package/dist/server/collections/gitReviewCutover.js +44 -0
- package/dist/server/collections/gitReviewFlows.js +3 -0
- package/dist/server/collections/gitReviewInbox.js +51 -0
- package/dist/server/collections/gitReviewProjects.js +43 -0
- package/dist/server/collections/gitReviewRequests.js +56 -0
- package/dist/server/index.js +8 -2
- package/dist/server/plugin.js +57 -20
- package/dist/server/poller.js +95 -74
- package/dist/server/repository-access.js +23 -5
- package/dist/server/request-method-policy.js +76 -0
- package/dist/server/review-control-access.js +79 -0
- package/dist/server/services/legacy-post-service.js +412 -0
- package/dist/server/services/registry-content-service.js +4 -3
- package/dist/server/services/review-service.js +1451 -0
- package/dist/server/services/review-source.js +325 -0
- package/dist/server/utils/get-repo-account.js +3 -2
- package/dist/server/utils/url-security.js +24 -0
- package/package.json +61 -43
- package/server.d.ts +2 -2
- package/server.js +1 -1
- package/src/client/__tests__/CommitHistory.test.tsx +79 -0
- package/src/client/__tests__/ReviewHistory.test.tsx +126 -0
- package/src/client/__tests__/RunReviewButton.test.tsx +84 -0
- package/src/client/__tests__/workflowRoutes.test.ts +65 -0
- package/src/client/ai-context.tsx +114 -114
- package/src/client/components/AIEmployeeSelect.tsx +63 -63
- package/src/client/components/CommitHistory.tsx +429 -374
- package/src/client/components/FileExplorer.tsx +386 -386
- package/src/client/components/GitAccounts.tsx +179 -179
- package/src/client/components/GitManagerSettings.tsx +160 -160
- package/src/client/components/GitOperations.tsx +220 -220
- package/src/client/components/LLMModelSelect.tsx +63 -63
- package/src/client/components/LLMServiceSelect.tsx +58 -58
- package/src/client/components/MarkdownView.tsx +80 -80
- package/src/client/components/MergeRequests.tsx +790 -790
- package/src/client/components/PollingStatus.tsx +225 -225
- package/src/client/components/RepositoryConfig.tsx +335 -335
- package/src/client/components/RepositoryPermissions.tsx +123 -123
- package/src/client/components/ReviewFlows.tsx +352 -303
- package/src/client/components/ReviewHistory.tsx +796 -566
- package/src/client/components/RunReviewButton.tsx +57 -173
- package/src/client/context/GitManagerContext.tsx +92 -92
- package/src/client/index.tsx +91 -82
- package/src/client/locale.ts +9 -9
- package/src/client/promptTemplates.ts +31 -31
- package/src/client/workflowRoutes.ts +42 -0
- package/src/client-v2/ai-context.tsx +99 -0
- package/src/client-v2/components/SubtreeSplits.tsx +547 -547
- package/src/client-v2/index.tsx +1 -1
- package/src/client-v2/locale.ts +8 -8
- package/src/client-v2/plugin.tsx +67 -39
- package/src/index.ts +2 -2
- package/src/locale/en-US.json +396 -297
- package/src/locale/vi-VN.json +384 -292
- package/src/locale/zh-CN.json +150 -51
- package/src/server/__tests__/git-actions.test.ts +24 -24
- package/src/server/__tests__/git-security.test.ts +170 -0
- package/src/server/__tests__/plugin-url-security.test.ts +17 -17
- package/src/server/__tests__/poller-lifecycle.test.ts +71 -0
- package/src/server/__tests__/poller.test.ts +37 -37
- package/src/server/__tests__/repository-access.test.ts +760 -752
- package/src/server/__tests__/review-service.integration.test.ts +1263 -0
- package/src/server/__tests__/review.test.ts +76 -137
- package/src/server/__tests__/role-permissions.test.ts +147 -147
- package/src/server/__tests__/smoke.test.ts +139 -17
- package/src/server/__tests__/subtree.test.ts +85 -85
- package/src/server/actions/git-actions.ts +540 -480
- package/src/server/actions/gitlab-api.ts +422 -411
- package/src/server/actions/poller.ts +39 -27
- package/src/server/actions/review-cutover.ts +121 -0
- package/src/server/actions/review.ts +1498 -1369
- package/src/server/actions/role-permissions.ts +331 -321
- package/src/server/actions/subtree.ts +508 -508
- package/src/server/ai-tools.ts +334 -319
- package/src/server/collections/gitAccounts.ts +56 -56
- package/src/server/collections/gitCodeReviews.ts +218 -199
- package/src/server/collections/gitRepositories.ts +87 -87
- package/src/server/collections/gitReviewCutover.ts +23 -0
- package/src/server/collections/gitReviewFlows.ts +120 -108
- package/src/server/collections/gitReviewInbox.ts +30 -0
- package/src/server/collections/gitReviewProjects.ts +22 -0
- package/src/server/collections/gitReviewRequests.ts +35 -0
- package/src/server/collections/gitSubtreeConfigs.ts +38 -38
- package/src/server/collections/gitSubtreeRuns.ts +30 -30
- package/src/server/index.ts +14 -2
- package/src/server/migrations/20260508000000-add-auto-review-flow-id.ts +29 -29
- package/src/server/migrations/20260712000000-add-git-accounts.ts +198 -198
- package/src/server/migrations/20260730000000-migrate-legacy-repository-permissions.ts +81 -81
- package/src/server/plugin.ts +409 -361
- package/src/server/poller.ts +365 -352
- package/src/server/repository-access.ts +803 -773
- package/src/server/request-method-policy.ts +56 -0
- package/src/server/review-control-access.ts +71 -0
- package/src/server/services/__tests__/registry-content-service.test.ts +359 -345
- package/src/server/services/__tests__/review-source.test.ts +226 -0
- package/src/server/services/legacy-post-service.ts +550 -0
- package/src/server/services/registry-content-service.ts +495 -484
- package/src/server/services/review-service.ts +1899 -0
- package/src/server/services/review-source.ts +359 -0
- package/src/server/utils/__tests__/redact.test.ts +56 -56
- package/src/server/utils/__tests__/url-security.test.ts +85 -85
- package/src/server/utils/get-repo-account.ts +51 -41
- package/src/server/utils/gitlab-url.ts +38 -38
- package/src/server/utils/redact.ts +87 -87
- package/src/server/utils/url-security.ts +128 -95
- package/dist/client/900.acf7d1fa22f95e71.js +0 -10
- package/dist/client-v2/434.7a27051db18526c0.js +0 -10
- package/dist/client-v2/900.f32b9dc85249fc0a.js +0 -10
|
@@ -1,566 +1,796 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
{
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
<
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
<
|
|
469
|
-
|
|
470
|
-
</
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
<Button
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
const
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
11
|
+
import {
|
|
12
|
+
Table,
|
|
13
|
+
Tag,
|
|
14
|
+
Drawer,
|
|
15
|
+
Space,
|
|
16
|
+
Button,
|
|
17
|
+
Typography,
|
|
18
|
+
Empty,
|
|
19
|
+
Tooltip,
|
|
20
|
+
Popconfirm,
|
|
21
|
+
message,
|
|
22
|
+
Select,
|
|
23
|
+
Tabs,
|
|
24
|
+
Input,
|
|
25
|
+
Alert,
|
|
26
|
+
theme,
|
|
27
|
+
} from 'antd';
|
|
28
|
+
import {
|
|
29
|
+
RobotOutlined,
|
|
30
|
+
ReloadOutlined,
|
|
31
|
+
CheckOutlined,
|
|
32
|
+
CloseOutlined,
|
|
33
|
+
ClockCircleOutlined,
|
|
34
|
+
FileTextOutlined,
|
|
35
|
+
ExportOutlined,
|
|
36
|
+
EditOutlined,
|
|
37
|
+
} from '@ant-design/icons';
|
|
38
|
+
import { useApp } from '@nocobase/client-v2';
|
|
39
|
+
import { useGitManager } from '../context/GitManagerContext';
|
|
40
|
+
import { MarkdownView } from './MarkdownView';
|
|
41
|
+
import { useT } from '../locale';
|
|
42
|
+
import { reviewApprovalHref, workflowHref } from '../workflowRoutes';
|
|
43
|
+
|
|
44
|
+
const { Text, Title, Paragraph } = Typography;
|
|
45
|
+
const { useToken } = theme;
|
|
46
|
+
type LegacyPostStatus = {
|
|
47
|
+
reviewId: number;
|
|
48
|
+
status: 'posted' | 'unknown' | 'observed';
|
|
49
|
+
attemptId: string | null;
|
|
50
|
+
canRetry: boolean;
|
|
51
|
+
holdActive: boolean;
|
|
52
|
+
baseUnverified: boolean;
|
|
53
|
+
baseAcknowledged: boolean;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const STATUS_COLOR: Record<string, string> = {
|
|
57
|
+
pending: 'default',
|
|
58
|
+
queued: 'default',
|
|
59
|
+
running: 'blue',
|
|
60
|
+
completed: 'green',
|
|
61
|
+
failed: 'red',
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const POST_STATUS_COLOR: Record<string, string> = {
|
|
65
|
+
pending_approval: 'orange',
|
|
66
|
+
approved: 'cyan',
|
|
67
|
+
posted: 'green',
|
|
68
|
+
post_failed: 'red',
|
|
69
|
+
post_unknown: 'orange',
|
|
70
|
+
posting: 'blue',
|
|
71
|
+
retrying: 'blue',
|
|
72
|
+
skipped: 'default',
|
|
73
|
+
rejected: 'red',
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const ReviewHistory: React.FC<{ initialFilter?: 'all' | 'pending_approval' }> = ({ initialFilter = 'all' }) => {
|
|
77
|
+
const t = useT();
|
|
78
|
+
const { token } = useToken();
|
|
79
|
+
const app = useApp();
|
|
80
|
+
const api = app.apiClient;
|
|
81
|
+
const { repos } = useGitManager();
|
|
82
|
+
const [reviews, setReviews] = useState<any[]>([]);
|
|
83
|
+
const [loading, setLoading] = useState(false);
|
|
84
|
+
const [statusFilter, setStatusFilter] = useState<string>('all');
|
|
85
|
+
const [postFilter, setPostFilter] = useState<string>(
|
|
86
|
+
initialFilter === 'pending_approval' ? 'pending_approval' : 'all',
|
|
87
|
+
);
|
|
88
|
+
const [triggerFilter, setTriggerFilter] = useState<string>('all');
|
|
89
|
+
const [selected, setSelected] = useState<any | null>(null);
|
|
90
|
+
const [editing, setEditing] = useState(false);
|
|
91
|
+
const [reconcilingPost, setReconcilingPost] = useState(false);
|
|
92
|
+
const [legacyPost, setLegacyPost] = useState<LegacyPostStatus | null>(null);
|
|
93
|
+
const [editedMarkdown, setEditedMarkdown] = useState('');
|
|
94
|
+
|
|
95
|
+
const reload = useCallback(async () => {
|
|
96
|
+
setLoading(true);
|
|
97
|
+
try {
|
|
98
|
+
const filter: any = {};
|
|
99
|
+
if (statusFilter !== 'all') filter.status = statusFilter;
|
|
100
|
+
if (postFilter !== 'all') filter.postStatus = postFilter;
|
|
101
|
+
if (triggerFilter !== 'all') filter.triggeredBy = triggerFilter;
|
|
102
|
+
const { data } = await api.request({
|
|
103
|
+
url: 'gitCodeReviews:list',
|
|
104
|
+
params: {
|
|
105
|
+
pageSize: 50,
|
|
106
|
+
sort: ['-id'],
|
|
107
|
+
filter: Object.keys(filter).length ? filter : undefined,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
setReviews(data?.data || []);
|
|
111
|
+
} finally {
|
|
112
|
+
setLoading(false);
|
|
113
|
+
}
|
|
114
|
+
}, [api, statusFilter, postFilter, triggerFilter]);
|
|
115
|
+
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
reload();
|
|
118
|
+
}, [reload]);
|
|
119
|
+
|
|
120
|
+
// Auto-refresh while there are running reviews
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
if (!reviews.some((r) => r.status === 'running' || r.status === 'pending' || r.status === 'queued')) return;
|
|
123
|
+
const tid = setInterval(reload, 4000);
|
|
124
|
+
return () => clearInterval(tid);
|
|
125
|
+
}, [reviews, reload]);
|
|
126
|
+
|
|
127
|
+
const refreshOne = useCallback(
|
|
128
|
+
async (id: number) => {
|
|
129
|
+
const { data } = await api.request({ url: 'gitCodeReviews:get', params: { filterByTk: id } });
|
|
130
|
+
const fresh = data?.data;
|
|
131
|
+
if (fresh) {
|
|
132
|
+
setReviews((prev) => prev.map((r) => (r.id === id ? fresh : r)));
|
|
133
|
+
if (selected?.id === id) setSelected(fresh);
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
[api, selected],
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
const handleApprove = async (markdown: string) => {
|
|
140
|
+
if (!selected) return;
|
|
141
|
+
try {
|
|
142
|
+
const response = await api.request({
|
|
143
|
+
url: 'gitManager:reviewApprovePost',
|
|
144
|
+
method: 'post',
|
|
145
|
+
data: { reviewId: selected.id, editedMarkdown: markdown, baseConfirmation: 'LEGACY_BASE_UNVERIFIED' },
|
|
146
|
+
});
|
|
147
|
+
const payload = response?.data?.data;
|
|
148
|
+
const result = payload?.success ? payload.data : payload;
|
|
149
|
+
if (result?.status === 'posted') message.success(t('Review posted to merge request'));
|
|
150
|
+
else if (result?.status === 'observed')
|
|
151
|
+
message.warning(t('A matching comment was found, but its attempt cannot be confirmed'));
|
|
152
|
+
else message.warning(t('Publication outcome is still unknown'));
|
|
153
|
+
setEditing(false);
|
|
154
|
+
refreshOne(selected.id);
|
|
155
|
+
reload();
|
|
156
|
+
} catch (err: any) {
|
|
157
|
+
message.error(err?.response?.data?.errors?.[0]?.message || err?.message || t('Failed to post review'));
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const handleReject = async () => {
|
|
162
|
+
if (!selected) return;
|
|
163
|
+
try {
|
|
164
|
+
await api.request({
|
|
165
|
+
url: 'gitManager:reviewReject',
|
|
166
|
+
method: 'post',
|
|
167
|
+
data: { reviewId: selected.id },
|
|
168
|
+
});
|
|
169
|
+
message.success(t('Review rejected'));
|
|
170
|
+
refreshOne(selected.id);
|
|
171
|
+
reload();
|
|
172
|
+
} catch (err: any) {
|
|
173
|
+
message.error(err?.message || t('Failed to reject'));
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const handleRetryPost = async (allowResend: boolean) => {
|
|
178
|
+
if (!selected) return;
|
|
179
|
+
setReconcilingPost(true);
|
|
180
|
+
try {
|
|
181
|
+
const response = await api.request({
|
|
182
|
+
url: 'gitManager:reviewWorkflowRetryPost',
|
|
183
|
+
method: 'post',
|
|
184
|
+
data: { reviewId: selected.id, ...(allowResend ? { confirmation: 'OUTBOUND_POST_STOPPED' } : {}) },
|
|
185
|
+
});
|
|
186
|
+
const result = response?.data?.data;
|
|
187
|
+
if (result?.status === 'posted') message.success(t('Review publication confirmed'));
|
|
188
|
+
else if (result?.status === 'observed')
|
|
189
|
+
message.info(t('Matching comment found; another publication attempt still owns the review'));
|
|
190
|
+
else if (result?.canResend)
|
|
191
|
+
message.warning(t('No matching comment found; confirm the previous post stopped before retrying'));
|
|
192
|
+
else
|
|
193
|
+
message.warning(t('A previous publication attempt may still be running; ask an administrator to recover it'));
|
|
194
|
+
await refreshOne(selected.id);
|
|
195
|
+
await reload();
|
|
196
|
+
} catch (error: unknown) {
|
|
197
|
+
const responseError = error as { response?: { data?: { errors?: Array<{ message?: string }> } } } | null;
|
|
198
|
+
message.error(
|
|
199
|
+
responseError?.response?.data?.errors?.[0]?.message ||
|
|
200
|
+
(error instanceof Error && error.message) ||
|
|
201
|
+
t('Failed to reconcile review publication'),
|
|
202
|
+
);
|
|
203
|
+
} finally {
|
|
204
|
+
setReconcilingPost(false);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const handleLegacyPost = async (action: 'check' | 'retry' | 'release') => {
|
|
209
|
+
if (!selected || (action !== 'check' && legacyPost?.reviewId !== selected.id)) return;
|
|
210
|
+
setReconcilingPost(true);
|
|
211
|
+
try {
|
|
212
|
+
const route =
|
|
213
|
+
action === 'check'
|
|
214
|
+
? 'reviewLegacyPostStatus'
|
|
215
|
+
: action === 'retry'
|
|
216
|
+
? 'reviewLegacyRetryPost'
|
|
217
|
+
: 'reviewLegacyReleaseHold';
|
|
218
|
+
const response = await api.request({
|
|
219
|
+
url: `gitManager:${route}`,
|
|
220
|
+
method: 'post',
|
|
221
|
+
data: {
|
|
222
|
+
reviewId: selected.id,
|
|
223
|
+
...(action === 'check'
|
|
224
|
+
? {}
|
|
225
|
+
: { confirmation: 'OUTBOUND_POST_STOPPED', expectedAttempt: legacyPost?.attemptId ?? null }),
|
|
226
|
+
...(action === 'retry' && legacyPost?.baseUnverified && !legacyPost.baseAcknowledged
|
|
227
|
+
? { baseConfirmation: 'LEGACY_BASE_UNVERIFIED' }
|
|
228
|
+
: {}),
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
const payload = response?.data?.data;
|
|
232
|
+
const result = payload?.success ? payload.data : payload;
|
|
233
|
+
if (action === 'check' && result) setLegacyPost({ ...result, reviewId: selected.id });
|
|
234
|
+
else setLegacyPost(null);
|
|
235
|
+
if (result?.status === 'posted') message.success(t('Review publication confirmed'));
|
|
236
|
+
else if (result?.status === 'observed' && result?.canRetry)
|
|
237
|
+
message.warning(t('A matching marked comment was found; confirm the previous attempt stopped to finalize it'));
|
|
238
|
+
else if (result?.status === 'observed')
|
|
239
|
+
message.warning(t('A matching comment was found, but its attempt cannot be confirmed'));
|
|
240
|
+
else if (action === 'release') message.success(t('Legacy publication hold released'));
|
|
241
|
+
else if (action === 'retry') message.warning(t('Publication outcome is still unknown'));
|
|
242
|
+
await refreshOne(selected.id);
|
|
243
|
+
await reload();
|
|
244
|
+
} catch (error: unknown) {
|
|
245
|
+
const responseError = error as { response?: { data?: { errors?: Array<{ message?: string }> } } } | null;
|
|
246
|
+
message.error(
|
|
247
|
+
responseError?.response?.data?.errors?.[0]?.message ||
|
|
248
|
+
(error instanceof Error && error.message) ||
|
|
249
|
+
t('Failed to reconcile review publication'),
|
|
250
|
+
);
|
|
251
|
+
} finally {
|
|
252
|
+
setReconcilingPost(false);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
const repoMap = useMemo(() => {
|
|
257
|
+
const m: Record<number, any> = {};
|
|
258
|
+
repos.forEach((r: any) => (m[r.id] = r));
|
|
259
|
+
return m;
|
|
260
|
+
}, [repos]);
|
|
261
|
+
|
|
262
|
+
const columns = [
|
|
263
|
+
{
|
|
264
|
+
title: t('Target'),
|
|
265
|
+
key: 'target',
|
|
266
|
+
render: (_: any, record: any) => {
|
|
267
|
+
const repo = repoMap[record.repositoryId];
|
|
268
|
+
const repoName = repo?.name || `#${record.repositoryId}`;
|
|
269
|
+
if (record.targetType === 'mr') {
|
|
270
|
+
return (
|
|
271
|
+
<Space size={4}>
|
|
272
|
+
<Text strong>{repoName}</Text>
|
|
273
|
+
<Text type="secondary">!{record.mrIid}</Text>
|
|
274
|
+
</Space>
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
if (record.targetType === 'commit') {
|
|
278
|
+
return (
|
|
279
|
+
<Space size={4}>
|
|
280
|
+
<Text strong>{repoName}</Text>
|
|
281
|
+
<Text type="secondary" style={{ fontFamily: 'monospace' }}>
|
|
282
|
+
{String(record.commitSha || '').slice(0, 7)}
|
|
283
|
+
</Text>
|
|
284
|
+
</Space>
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
if (record.targetType === 'folder') {
|
|
288
|
+
return (
|
|
289
|
+
<Space size={4}>
|
|
290
|
+
<Text strong>{repoName}</Text>
|
|
291
|
+
<Text type="secondary">{record.folderPath || '/'}</Text>
|
|
292
|
+
{record.branch && <Tag style={{ fontSize: 11 }}>{record.branch}</Tag>}
|
|
293
|
+
</Space>
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
return (
|
|
297
|
+
<Space size={4}>
|
|
298
|
+
<Text strong>{repoName}</Text>
|
|
299
|
+
<Text type="secondary">{record.branch}</Text>
|
|
300
|
+
</Space>
|
|
301
|
+
);
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
title: t('Type'),
|
|
306
|
+
dataIndex: 'targetType',
|
|
307
|
+
width: 80,
|
|
308
|
+
render: (v: string) => <Tag>{t(v.toUpperCase())}</Tag>,
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
title: t('Status'),
|
|
312
|
+
dataIndex: 'status',
|
|
313
|
+
width: 120,
|
|
314
|
+
render: (v: string) => {
|
|
315
|
+
const color = STATUS_COLOR[v] || 'default';
|
|
316
|
+
const icon = v === 'running' ? <ClockCircleOutlined spin /> : null;
|
|
317
|
+
return (
|
|
318
|
+
<Tag color={color} icon={icon}>
|
|
319
|
+
{t(v)}
|
|
320
|
+
</Tag>
|
|
321
|
+
);
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
title: t('Post Status'),
|
|
326
|
+
dataIndex: 'postStatus',
|
|
327
|
+
width: 140,
|
|
328
|
+
render: (v: string) => <Tag color={POST_STATUS_COLOR[v] || 'default'}>{t(v)}</Tag>,
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
title: t('Commit'),
|
|
332
|
+
key: 'sha',
|
|
333
|
+
width: 140,
|
|
334
|
+
render: (_: any, record: any) => {
|
|
335
|
+
const head = record.headSha;
|
|
336
|
+
const latest = record.latestSha;
|
|
337
|
+
const hasNew = head && latest && head !== latest;
|
|
338
|
+
if (!head) return <Text type="secondary">—</Text>;
|
|
339
|
+
return (
|
|
340
|
+
<Space size={4}>
|
|
341
|
+
<Tag style={{ fontFamily: 'monospace', fontSize: 11 }}>{String(head).slice(0, 7)}</Tag>
|
|
342
|
+
{hasNew && (
|
|
343
|
+
<Tooltip title={`${t('New commits')}: ${String(latest).slice(0, 7)}`}>
|
|
344
|
+
<Tag color="orange" style={{ fontSize: 11 }}>
|
|
345
|
+
{t('new')}
|
|
346
|
+
</Tag>
|
|
347
|
+
</Tooltip>
|
|
348
|
+
)}
|
|
349
|
+
</Space>
|
|
350
|
+
);
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
title: t('Trigger'),
|
|
355
|
+
dataIndex: 'triggeredBy',
|
|
356
|
+
width: 90,
|
|
357
|
+
render: (v: string) => (
|
|
358
|
+
<Tag color={v === 'poll' ? 'geekblue' : 'default'} style={{ fontSize: 11 }}>
|
|
359
|
+
{v === 'poll' ? t('Polling') : t('Manual')}
|
|
360
|
+
</Tag>
|
|
361
|
+
),
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
title: t('Duration'),
|
|
365
|
+
dataIndex: 'durationMs',
|
|
366
|
+
width: 90,
|
|
367
|
+
render: (v: number | null) => (v ? `${(v / 1000).toFixed(1)}s` : '—'),
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
title: t('Created'),
|
|
371
|
+
dataIndex: 'createdAt',
|
|
372
|
+
width: 160,
|
|
373
|
+
render: (v: string) => (v ? new Date(v).toLocaleString() : ''),
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
title: '',
|
|
377
|
+
key: 'actions',
|
|
378
|
+
width: 60,
|
|
379
|
+
render: (_: any, record: any) => (
|
|
380
|
+
<Tooltip title={t('View')}>
|
|
381
|
+
<Button
|
|
382
|
+
size="small"
|
|
383
|
+
icon={<FileTextOutlined />}
|
|
384
|
+
onClick={() => {
|
|
385
|
+
setSelected(record);
|
|
386
|
+
setEditing(false);
|
|
387
|
+
setEditedMarkdown(record.reviewMarkdown || '');
|
|
388
|
+
}}
|
|
389
|
+
/>
|
|
390
|
+
</Tooltip>
|
|
391
|
+
),
|
|
392
|
+
},
|
|
393
|
+
];
|
|
394
|
+
|
|
395
|
+
return (
|
|
396
|
+
<div>
|
|
397
|
+
<Space style={{ marginBottom: 12 }} wrap>
|
|
398
|
+
<Select
|
|
399
|
+
size="small"
|
|
400
|
+
style={{ width: 140 }}
|
|
401
|
+
value={statusFilter}
|
|
402
|
+
onChange={setStatusFilter}
|
|
403
|
+
options={[
|
|
404
|
+
{ value: 'all', label: t('All statuses') },
|
|
405
|
+
{ value: 'pending', label: t('pending') },
|
|
406
|
+
{ value: 'queued', label: t('queued') },
|
|
407
|
+
{ value: 'running', label: t('running') },
|
|
408
|
+
{ value: 'completed', label: t('completed') },
|
|
409
|
+
{ value: 'failed', label: t('failed') },
|
|
410
|
+
]}
|
|
411
|
+
/>
|
|
412
|
+
<Select
|
|
413
|
+
size="small"
|
|
414
|
+
style={{ width: 180 }}
|
|
415
|
+
value={postFilter}
|
|
416
|
+
onChange={setPostFilter}
|
|
417
|
+
options={[
|
|
418
|
+
{ value: 'all', label: t('All post statuses') },
|
|
419
|
+
{ value: 'pending_approval', label: t('pending_approval') },
|
|
420
|
+
{ value: 'approved', label: t('approved') },
|
|
421
|
+
{ value: 'posted', label: t('posted') },
|
|
422
|
+
{ value: 'post_failed', label: t('post_failed') },
|
|
423
|
+
{ value: 'post_unknown', label: t('post_unknown') },
|
|
424
|
+
{ value: 'posting', label: t('posting') },
|
|
425
|
+
{ value: 'skipped', label: t('skipped') },
|
|
426
|
+
{ value: 'rejected', label: t('rejected') },
|
|
427
|
+
]}
|
|
428
|
+
/>
|
|
429
|
+
<Select
|
|
430
|
+
size="small"
|
|
431
|
+
style={{ width: 130 }}
|
|
432
|
+
value={triggerFilter}
|
|
433
|
+
onChange={setTriggerFilter}
|
|
434
|
+
options={[
|
|
435
|
+
{ value: 'all', label: t('All triggers') },
|
|
436
|
+
{ value: 'manual', label: t('Manual') },
|
|
437
|
+
{ value: 'poll', label: t('Polling') },
|
|
438
|
+
]}
|
|
439
|
+
/>
|
|
440
|
+
<Button size="small" icon={<ReloadOutlined />} onClick={reload}>
|
|
441
|
+
{t('Refresh')}
|
|
442
|
+
</Button>
|
|
443
|
+
</Space>
|
|
444
|
+
<Table
|
|
445
|
+
size="small"
|
|
446
|
+
rowKey="id"
|
|
447
|
+
loading={loading}
|
|
448
|
+
dataSource={reviews}
|
|
449
|
+
columns={columns}
|
|
450
|
+
locale={{ emptyText: <Empty description={t('No reviews yet')} /> }}
|
|
451
|
+
pagination={{ pageSize: 20 }}
|
|
452
|
+
onRow={(record) => ({
|
|
453
|
+
style: { cursor: 'pointer' },
|
|
454
|
+
onClick: () => {
|
|
455
|
+
setSelected(record);
|
|
456
|
+
setEditing(false);
|
|
457
|
+
setLegacyPost(null);
|
|
458
|
+
setEditedMarkdown(record.reviewMarkdown || '');
|
|
459
|
+
},
|
|
460
|
+
})}
|
|
461
|
+
/>
|
|
462
|
+
|
|
463
|
+
<Drawer
|
|
464
|
+
title={
|
|
465
|
+
selected ? (
|
|
466
|
+
<Space>
|
|
467
|
+
<RobotOutlined />
|
|
468
|
+
<span>{t('Code Review')}</span>
|
|
469
|
+
<Tag color={STATUS_COLOR[selected.status]}>{t(selected.status)}</Tag>
|
|
470
|
+
<Tag color={POST_STATUS_COLOR[selected.postStatus]}>{t(selected.postStatus)}</Tag>
|
|
471
|
+
</Space>
|
|
472
|
+
) : (
|
|
473
|
+
t('Code Review')
|
|
474
|
+
)
|
|
475
|
+
}
|
|
476
|
+
open={!!selected}
|
|
477
|
+
onClose={() => {
|
|
478
|
+
setSelected(null);
|
|
479
|
+
setEditing(false);
|
|
480
|
+
}}
|
|
481
|
+
width={840}
|
|
482
|
+
extra={
|
|
483
|
+
selected && (
|
|
484
|
+
<Space>
|
|
485
|
+
<Button size="small" icon={<ReloadOutlined />} onClick={() => refreshOne(selected.id)}>
|
|
486
|
+
{t('Refresh')}
|
|
487
|
+
</Button>
|
|
488
|
+
{selected.targetType === 'mr' && (
|
|
489
|
+
<Button
|
|
490
|
+
size="small"
|
|
491
|
+
icon={<ExportOutlined />}
|
|
492
|
+
onClick={() => {
|
|
493
|
+
const repo = repoMap[selected.repositoryId];
|
|
494
|
+
const url = repo?.repoUrl?.replace(/\.git$/, '');
|
|
495
|
+
if (url && selected.mrIid) {
|
|
496
|
+
window.open(`${url}/-/merge_requests/${selected.mrIid}`, '_blank');
|
|
497
|
+
}
|
|
498
|
+
}}
|
|
499
|
+
>
|
|
500
|
+
{t('Open MR')}
|
|
501
|
+
</Button>
|
|
502
|
+
)}
|
|
503
|
+
</Space>
|
|
504
|
+
)
|
|
505
|
+
}
|
|
506
|
+
>
|
|
507
|
+
{selected && (
|
|
508
|
+
<ReviewDetailView
|
|
509
|
+
review={selected}
|
|
510
|
+
editing={editing}
|
|
511
|
+
editedMarkdown={editedMarkdown}
|
|
512
|
+
onEdit={() => setEditing(true)}
|
|
513
|
+
onCancelEdit={() => {
|
|
514
|
+
setEditing(false);
|
|
515
|
+
setEditedMarkdown(selected.reviewMarkdown || '');
|
|
516
|
+
}}
|
|
517
|
+
onChangeMarkdown={setEditedMarkdown}
|
|
518
|
+
onApprove={handleApprove}
|
|
519
|
+
onReject={handleReject}
|
|
520
|
+
onRetryPost={handleRetryPost}
|
|
521
|
+
legacyPost={legacyPost?.reviewId === selected.id ? legacyPost : null}
|
|
522
|
+
onLegacyPost={handleLegacyPost}
|
|
523
|
+
reconcilingPost={reconcilingPost}
|
|
524
|
+
/>
|
|
525
|
+
)}
|
|
526
|
+
</Drawer>
|
|
527
|
+
</div>
|
|
528
|
+
);
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
const ReviewDetailView: React.FC<{
|
|
532
|
+
review: any;
|
|
533
|
+
editing: boolean;
|
|
534
|
+
editedMarkdown: string;
|
|
535
|
+
onEdit: () => void;
|
|
536
|
+
onCancelEdit: () => void;
|
|
537
|
+
onChangeMarkdown: (v: string) => void;
|
|
538
|
+
onApprove: (markdown: string) => void;
|
|
539
|
+
onReject: () => void;
|
|
540
|
+
onRetryPost: (allowResend: boolean) => void;
|
|
541
|
+
legacyPost: LegacyPostStatus | null;
|
|
542
|
+
onLegacyPost: (action: 'check' | 'retry' | 'release') => void;
|
|
543
|
+
reconcilingPost: boolean;
|
|
544
|
+
}> = ({
|
|
545
|
+
review,
|
|
546
|
+
editing,
|
|
547
|
+
editedMarkdown,
|
|
548
|
+
onEdit,
|
|
549
|
+
onCancelEdit,
|
|
550
|
+
onChangeMarkdown,
|
|
551
|
+
onApprove,
|
|
552
|
+
onReject,
|
|
553
|
+
onRetryPost,
|
|
554
|
+
legacyPost,
|
|
555
|
+
onLegacyPost,
|
|
556
|
+
reconcilingPost,
|
|
557
|
+
}) => {
|
|
558
|
+
const t = useT();
|
|
559
|
+
const { token } = useToken();
|
|
560
|
+
const app = useApp();
|
|
561
|
+
|
|
562
|
+
const canApprove =
|
|
563
|
+
!review.metadata?.workflowManaged &&
|
|
564
|
+
review.status === 'completed' &&
|
|
565
|
+
review.targetType === 'mr' &&
|
|
566
|
+
review.postStatus === 'pending_approval';
|
|
567
|
+
const canRetryPost =
|
|
568
|
+
review.metadata?.workflowManaged &&
|
|
569
|
+
review.status !== 'running' &&
|
|
570
|
+
review.targetType === 'mr' &&
|
|
571
|
+
['posting', 'post_unknown', 'post_failed', 'retrying'].includes(review.postStatus);
|
|
572
|
+
const canCheckLegacy =
|
|
573
|
+
!review.metadata?.workflowManaged &&
|
|
574
|
+
review.targetType === 'mr' &&
|
|
575
|
+
['posting', 'post_unknown', 'post_failed'].includes(review.postStatus);
|
|
576
|
+
|
|
577
|
+
return (
|
|
578
|
+
<div>
|
|
579
|
+
{review.metadata?.workflowManaged && review.postStatus === 'pending_approval' && (
|
|
580
|
+
<Alert
|
|
581
|
+
type="info"
|
|
582
|
+
showIcon
|
|
583
|
+
message={t('Use the workflow approval task for this review')}
|
|
584
|
+
action={<Button href={reviewApprovalHref(app)}>{t('Open workflow tasks')}</Button>}
|
|
585
|
+
style={{ marginBottom: 16 }}
|
|
586
|
+
/>
|
|
587
|
+
)}
|
|
588
|
+
{review.metadata?.workflowExecutionId && (
|
|
589
|
+
<Button
|
|
590
|
+
href={workflowHref(app, 'execution', review.metadata.workflowExecutionId)}
|
|
591
|
+
target="_blank"
|
|
592
|
+
rel="noreferrer"
|
|
593
|
+
style={{ marginBottom: 16 }}
|
|
594
|
+
>
|
|
595
|
+
{t('Open workflow execution')}
|
|
596
|
+
</Button>
|
|
597
|
+
)}
|
|
598
|
+
{canRetryPost && (
|
|
599
|
+
<Space wrap style={{ marginBottom: 16 }}>
|
|
600
|
+
<Button loading={reconcilingPost} onClick={() => onRetryPost(false)}>
|
|
601
|
+
{t('Check publication')}
|
|
602
|
+
</Button>
|
|
603
|
+
<Popconfirm
|
|
604
|
+
title={t('Has the previous outbound post stopped and settled?')}
|
|
605
|
+
onConfirm={() => onRetryPost(true)}
|
|
606
|
+
>
|
|
607
|
+
<Button loading={reconcilingPost}>{t('Retry publication')}</Button>
|
|
608
|
+
</Popconfirm>
|
|
609
|
+
</Space>
|
|
610
|
+
)}
|
|
611
|
+
{canCheckLegacy && (
|
|
612
|
+
<Space wrap style={{ marginBottom: 16 }}>
|
|
613
|
+
<Button loading={reconcilingPost} onClick={() => onLegacyPost('check')}>
|
|
614
|
+
{t('Check publication')}
|
|
615
|
+
</Button>
|
|
616
|
+
{legacyPost?.canRetry && (
|
|
617
|
+
<Popconfirm
|
|
618
|
+
title={t('Has the previous outbound post stopped and settled?')}
|
|
619
|
+
description={
|
|
620
|
+
legacyPost.baseUnverified && !legacyPost.baseAcknowledged
|
|
621
|
+
? t(
|
|
622
|
+
'The original review base cannot be verified. Compare the review with the current merge request before continuing.',
|
|
623
|
+
)
|
|
624
|
+
: undefined
|
|
625
|
+
}
|
|
626
|
+
onConfirm={() => onLegacyPost('retry')}
|
|
627
|
+
>
|
|
628
|
+
<Button loading={reconcilingPost}>{t('Retry publication')}</Button>
|
|
629
|
+
</Popconfirm>
|
|
630
|
+
)}
|
|
631
|
+
{legacyPost?.holdActive && (
|
|
632
|
+
<Popconfirm
|
|
633
|
+
title={t('Has the previous outbound post stopped and settled?')}
|
|
634
|
+
onConfirm={() => onLegacyPost('release')}
|
|
635
|
+
>
|
|
636
|
+
<Button loading={reconcilingPost}>{t('Release legacy publication hold')}</Button>
|
|
637
|
+
</Popconfirm>
|
|
638
|
+
)}
|
|
639
|
+
</Space>
|
|
640
|
+
)}
|
|
641
|
+
{canApprove && (
|
|
642
|
+
<Alert
|
|
643
|
+
type="warning"
|
|
644
|
+
showIcon
|
|
645
|
+
message={t(
|
|
646
|
+
'The original review base cannot be verified. Compare the review with the current merge request before continuing.',
|
|
647
|
+
)}
|
|
648
|
+
style={{ marginBottom: 16 }}
|
|
649
|
+
/>
|
|
650
|
+
)}
|
|
651
|
+
{review.status === 'running' && (
|
|
652
|
+
<Alert
|
|
653
|
+
type="info"
|
|
654
|
+
showIcon
|
|
655
|
+
message={t('Review in progress…')}
|
|
656
|
+
description={t('The AI employee is analyzing the code. This page will refresh automatically.')}
|
|
657
|
+
style={{ marginBottom: 16 }}
|
|
658
|
+
/>
|
|
659
|
+
)}
|
|
660
|
+
{review.status === 'failed' && (
|
|
661
|
+
<Alert
|
|
662
|
+
type="error"
|
|
663
|
+
showIcon
|
|
664
|
+
message={t('Review failed')}
|
|
665
|
+
description={<pre style={{ whiteSpace: 'pre-wrap', margin: 0 }}>{review.error}</pre>}
|
|
666
|
+
style={{ marginBottom: 16 }}
|
|
667
|
+
/>
|
|
668
|
+
)}
|
|
669
|
+
{review.status === 'completed' && review.postStatus === 'post_failed' && review.error && (
|
|
670
|
+
<Alert
|
|
671
|
+
type="error"
|
|
672
|
+
showIcon
|
|
673
|
+
message={t('Post Failed')}
|
|
674
|
+
description={<pre style={{ whiteSpace: 'pre-wrap', margin: 0 }}>{review.error}</pre>}
|
|
675
|
+
style={{ marginBottom: 16 }}
|
|
676
|
+
/>
|
|
677
|
+
)}
|
|
678
|
+
|
|
679
|
+
{/* Action bar */}
|
|
680
|
+
{canApprove && (
|
|
681
|
+
<Space style={{ marginBottom: 16 }} wrap>
|
|
682
|
+
{!editing ? (
|
|
683
|
+
<>
|
|
684
|
+
<Popconfirm
|
|
685
|
+
title={t(
|
|
686
|
+
'The original review base cannot be verified. Compare the review with the current merge request before continuing.',
|
|
687
|
+
)}
|
|
688
|
+
onConfirm={() => onApprove(review.reviewMarkdown)}
|
|
689
|
+
>
|
|
690
|
+
<Button type="primary" icon={<CheckOutlined />}>
|
|
691
|
+
{t('Approve & Post')}
|
|
692
|
+
</Button>
|
|
693
|
+
</Popconfirm>
|
|
694
|
+
<Button icon={<EditOutlined />} onClick={onEdit}>
|
|
695
|
+
{t('Edit & Post')}
|
|
696
|
+
</Button>
|
|
697
|
+
<Popconfirm title={t('Reject this review?')} onConfirm={onReject}>
|
|
698
|
+
<Button danger icon={<CloseOutlined />}>
|
|
699
|
+
{t('Reject')}
|
|
700
|
+
</Button>
|
|
701
|
+
</Popconfirm>
|
|
702
|
+
</>
|
|
703
|
+
) : (
|
|
704
|
+
<>
|
|
705
|
+
<Popconfirm
|
|
706
|
+
title={t(
|
|
707
|
+
'The original review base cannot be verified. Compare the review with the current merge request before continuing.',
|
|
708
|
+
)}
|
|
709
|
+
onConfirm={() => onApprove(editedMarkdown)}
|
|
710
|
+
>
|
|
711
|
+
<Button type="primary" icon={<CheckOutlined />}>
|
|
712
|
+
{t('Save & Post')}
|
|
713
|
+
</Button>
|
|
714
|
+
</Popconfirm>
|
|
715
|
+
<Button onClick={onCancelEdit}>{t('Cancel')}</Button>
|
|
716
|
+
</>
|
|
717
|
+
)}
|
|
718
|
+
</Space>
|
|
719
|
+
)}
|
|
720
|
+
|
|
721
|
+
{/* Body */}
|
|
722
|
+
<Tabs
|
|
723
|
+
defaultActiveKey="content"
|
|
724
|
+
items={[
|
|
725
|
+
{
|
|
726
|
+
key: 'content',
|
|
727
|
+
label: t('Review Content'),
|
|
728
|
+
children: editing ? (
|
|
729
|
+
<Input.TextArea
|
|
730
|
+
value={editedMarkdown}
|
|
731
|
+
onChange={(e) => onChangeMarkdown(e.target.value)}
|
|
732
|
+
autoSize={{ minRows: 16, maxRows: 40 }}
|
|
733
|
+
style={{ fontFamily: "'JetBrains Mono', 'Fira Code', Consolas, monospace", fontSize: 13 }}
|
|
734
|
+
/>
|
|
735
|
+
) : review.reviewMarkdown ? (
|
|
736
|
+
<div
|
|
737
|
+
style={{
|
|
738
|
+
background: token.colorBgLayout,
|
|
739
|
+
padding: 16,
|
|
740
|
+
borderRadius: 8,
|
|
741
|
+
maxHeight: '70vh',
|
|
742
|
+
overflowY: 'auto',
|
|
743
|
+
}}
|
|
744
|
+
>
|
|
745
|
+
<MarkdownView content={review.reviewMarkdown} />
|
|
746
|
+
</div>
|
|
747
|
+
) : (
|
|
748
|
+
<Empty description={t('No content yet')} />
|
|
749
|
+
),
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
key: 'metadata',
|
|
753
|
+
label: t('Metadata'),
|
|
754
|
+
children: (
|
|
755
|
+
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '8px 16px', fontSize: 13 }}>
|
|
756
|
+
<Meta label={t('Status')} value={review.status} />
|
|
757
|
+
<Meta label={t('Post Status')} value={review.postStatus} />
|
|
758
|
+
<Meta label={t('Trigger Type')} value={review.targetType} />
|
|
759
|
+
{review.targetType === 'folder' && <Meta label={t('Folder')} value={review.folderPath || '/'} />}
|
|
760
|
+
<Meta label={t('Triggered By')} value={review.triggeredBy} />
|
|
761
|
+
<Meta label={t('Reviewed SHA')} value={review.headSha || '—'} />
|
|
762
|
+
<Meta label={t('Latest SHA')} value={review.latestSha || '—'} />
|
|
763
|
+
<Meta label={t('Started At')} value={review.startedAt && new Date(review.startedAt).toLocaleString()} />
|
|
764
|
+
<Meta
|
|
765
|
+
label={t('Finished At')}
|
|
766
|
+
value={review.finishedAt && new Date(review.finishedAt).toLocaleString()}
|
|
767
|
+
/>
|
|
768
|
+
<Meta
|
|
769
|
+
label={t('Duration')}
|
|
770
|
+
value={review.durationMs ? `${(review.durationMs / 1000).toFixed(1)}s` : '—'}
|
|
771
|
+
/>
|
|
772
|
+
<Meta label={t('Posted Note ID')} value={review.postedNoteId || '—'} />
|
|
773
|
+
<Meta label={t('Approved By')} value={review.approvedBy || '—'} />
|
|
774
|
+
<Meta
|
|
775
|
+
label={t('Approved At')}
|
|
776
|
+
value={review.approvedAt && new Date(review.approvedAt).toLocaleString()}
|
|
777
|
+
/>
|
|
778
|
+
<Meta label={t('Session ID')} value={review.sessionId || '—'} />
|
|
779
|
+
<Meta label={t('Flow ID')} value={review.flowId || '—'} />
|
|
780
|
+
</div>
|
|
781
|
+
),
|
|
782
|
+
},
|
|
783
|
+
]}
|
|
784
|
+
/>
|
|
785
|
+
</div>
|
|
786
|
+
);
|
|
787
|
+
};
|
|
788
|
+
|
|
789
|
+
const Meta: React.FC<{ label: string; value: any }> = ({ label, value }) => (
|
|
790
|
+
<div>
|
|
791
|
+
<Text type="secondary" style={{ fontSize: 12, display: 'block' }}>
|
|
792
|
+
{label}
|
|
793
|
+
</Text>
|
|
794
|
+
<div style={{ wordBreak: 'break-all' }}>{value || '—'}</div>
|
|
795
|
+
</div>
|
|
796
|
+
);
|