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
|
@@ -0,0 +1,126 @@
|
|
|
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 from 'react';
|
|
11
|
+
import { cleanup, configure, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
|
|
12
|
+
import { ReviewHistory } from '../components/ReviewHistory';
|
|
13
|
+
|
|
14
|
+
const mocks = vi.hoisted(() => {
|
|
15
|
+
const request = vi.fn();
|
|
16
|
+
return {
|
|
17
|
+
request,
|
|
18
|
+
apiClient: { request },
|
|
19
|
+
success: vi.fn(),
|
|
20
|
+
warning: vi.fn(),
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
vi.mock('@nocobase/client-v2', () => ({
|
|
25
|
+
useApp: () => ({ apiClient: mocks.apiClient }),
|
|
26
|
+
getModernClientPrefix: () => 'v',
|
|
27
|
+
getRouteRuntimeVersion: () => 'legacy',
|
|
28
|
+
getV2EffectiveBasePath: () => '/v/',
|
|
29
|
+
stripModernClientPrefix: (path: string) => path.replace(/\/v\/?$/, '/'),
|
|
30
|
+
}));
|
|
31
|
+
vi.mock('../context/GitManagerContext', () => ({
|
|
32
|
+
useGitManager: () => ({ repos: [{ id: 7, name: 'review-repo', repoUrl: 'https://gitlab.test/group/project' }] }),
|
|
33
|
+
}));
|
|
34
|
+
vi.mock('../locale', () => ({ useT: () => (key: string) => key }));
|
|
35
|
+
vi.mock('../components/MarkdownView', () => ({
|
|
36
|
+
MarkdownView: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
|
37
|
+
}));
|
|
38
|
+
vi.mock('antd', async (importOriginal) => {
|
|
39
|
+
const actual = await importOriginal<typeof import('antd')>();
|
|
40
|
+
const ReactModule = await import('react');
|
|
41
|
+
return {
|
|
42
|
+
...actual,
|
|
43
|
+
Drawer: (props: { open: boolean; title: React.ReactNode; extra?: React.ReactNode; children: React.ReactNode }) =>
|
|
44
|
+
props.open
|
|
45
|
+
? ReactModule.default.createElement(
|
|
46
|
+
'div',
|
|
47
|
+
{ 'data-testid': 'review-drawer' },
|
|
48
|
+
props.title,
|
|
49
|
+
props.extra,
|
|
50
|
+
props.children,
|
|
51
|
+
)
|
|
52
|
+
: null,
|
|
53
|
+
Table: (props: {
|
|
54
|
+
dataSource?: Array<{ id: number; mrIid: number }>;
|
|
55
|
+
onRow?: (record: { id: number; mrIid: number }) => { onClick?: React.MouseEventHandler<HTMLElement> };
|
|
56
|
+
}) =>
|
|
57
|
+
ReactModule.default.createElement(
|
|
58
|
+
'div',
|
|
59
|
+
null,
|
|
60
|
+
...(props.dataSource || []).map((record) => {
|
|
61
|
+
const rowClick = props.onRow?.(record).onClick;
|
|
62
|
+
return ReactModule.default.createElement(
|
|
63
|
+
'button',
|
|
64
|
+
{ key: String(record.id), type: 'button', onClick: rowClick },
|
|
65
|
+
`Open review ${record.mrIid}`,
|
|
66
|
+
);
|
|
67
|
+
}),
|
|
68
|
+
),
|
|
69
|
+
Popconfirm: (props: { children: React.ReactElement; onConfirm?: () => void }) => {
|
|
70
|
+
const child = props.children as React.ReactElement<{ onClick?: React.MouseEventHandler<HTMLElement> }>;
|
|
71
|
+
return ReactModule.default.cloneElement(child, {
|
|
72
|
+
onClick: (event) => {
|
|
73
|
+
child.props.onClick?.(event);
|
|
74
|
+
props.onConfirm?.();
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
message: { ...actual.message, success: mocks.success, warning: mocks.warning },
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe('ReviewHistory legacy approval outcome', () => {
|
|
83
|
+
const review = {
|
|
84
|
+
id: 301,
|
|
85
|
+
repositoryId: 7,
|
|
86
|
+
targetType: 'mr',
|
|
87
|
+
mrIid: 42,
|
|
88
|
+
status: 'completed',
|
|
89
|
+
postStatus: 'pending_approval',
|
|
90
|
+
reviewMarkdown: '## Existing review',
|
|
91
|
+
createdAt: '2026-11-10T00:00:00.000Z',
|
|
92
|
+
triggeredBy: 'manual',
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
beforeEach(() => {
|
|
96
|
+
vi.clearAllMocks();
|
|
97
|
+
configure({ asyncUtilTimeout: 1500 });
|
|
98
|
+
mocks.request.mockImplementation(async ({ url }: { url: string }) => {
|
|
99
|
+
if (url === 'gitCodeReviews:list' || url === 'gitCodeReviews:get') {
|
|
100
|
+
return { data: { data: url.endsWith(':list') ? [review] : review } };
|
|
101
|
+
}
|
|
102
|
+
if (url === 'gitManager:reviewApprovePost') return { data: { data: { status: 'observed' } } };
|
|
103
|
+
return { data: { data: [] } };
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
afterEach(cleanup);
|
|
108
|
+
|
|
109
|
+
it('reports an observed matching note without claiming the review was posted', async () => {
|
|
110
|
+
render(<ReviewHistory />);
|
|
111
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Open review 42' }));
|
|
112
|
+
const drawer = await screen.findByTestId('review-drawer');
|
|
113
|
+
const approveLabel = within(drawer).getByText('Approve & Post', { exact: true });
|
|
114
|
+
fireEvent.click(approveLabel);
|
|
115
|
+
|
|
116
|
+
await waitFor(() => {
|
|
117
|
+
expect(mocks.warning).toHaveBeenCalledWith('A matching comment was found, but its attempt cannot be confirmed');
|
|
118
|
+
});
|
|
119
|
+
expect(mocks.success).not.toHaveBeenCalledWith('Review posted to merge request');
|
|
120
|
+
expect(mocks.request).toHaveBeenCalledWith({
|
|
121
|
+
url: 'gitManager:reviewApprovePost',
|
|
122
|
+
method: 'post',
|
|
123
|
+
data: { reviewId: 301, editedMarkdown: '## Existing review', baseConfirmation: 'LEGACY_BASE_UNVERIFIED' },
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
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 from 'react';
|
|
11
|
+
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
12
|
+
import { RunReviewButton } from '../components/RunReviewButton';
|
|
13
|
+
|
|
14
|
+
const mocks = vi.hoisted(() => {
|
|
15
|
+
const request = vi.fn();
|
|
16
|
+
return { request, apiClient: { request }, getPlugin: vi.fn(), triggerTask: vi.fn() };
|
|
17
|
+
});
|
|
18
|
+
vi.mock('@nocobase/client-v2', () => ({
|
|
19
|
+
useApp: () => ({ apiClient: mocks.apiClient, pm: { get: mocks.getPlugin } }),
|
|
20
|
+
}));
|
|
21
|
+
vi.mock('../locale', () => ({ useT: () => (key: string) => key }));
|
|
22
|
+
// Any accidental runtime import of the AI package must fail this suite.
|
|
23
|
+
vi.mock('@nocobase/plugin-ai', () => {
|
|
24
|
+
throw new Error('Unexpected legacy AI import');
|
|
25
|
+
});
|
|
26
|
+
vi.mock('@nocobase/plugin-ai/client-v2', () => {
|
|
27
|
+
throw new Error('Unexpected direct AI client import');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe('RunReviewButton managed review queue', () => {
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
vi.clearAllMocks();
|
|
33
|
+
mocks.request.mockImplementation(async ({ url }: { url: string }) => {
|
|
34
|
+
if (url === 'gitReviewFlows:list') {
|
|
35
|
+
return { data: { data: [{ id: 1, name: 'Security', aiEmployeeUsername: 'reviewer', repositoryId: 7 }] } };
|
|
36
|
+
}
|
|
37
|
+
if (url === 'gitManager:triggerReview') return { data: { data: { reviewId: 123 } } };
|
|
38
|
+
return { data: { data: [] } };
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
afterEach(cleanup);
|
|
42
|
+
|
|
43
|
+
it('exposes managed review actions without a direct AI chat action', async () => {
|
|
44
|
+
render(<RunReviewButton target={{ type: 'branch', repositoryId: 7, branch: 'main' }} />);
|
|
45
|
+
fireEvent.click(screen.getByRole('button', { name: /Code Review/ }));
|
|
46
|
+
|
|
47
|
+
expect(await screen.findByRole('menuitem', { name: /Run automated review/ })).toBeInTheDocument();
|
|
48
|
+
expect(screen.queryByRole('menuitem', { name: /Ask AI Employee/ })).not.toBeInTheDocument();
|
|
49
|
+
expect(mocks.getPlugin).not.toHaveBeenCalled();
|
|
50
|
+
expect(mocks.triggerTask).not.toHaveBeenCalled();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('queues a review and reports the returned review id without direct AI invocation', async () => {
|
|
54
|
+
const onTriggered = vi.fn();
|
|
55
|
+
render(
|
|
56
|
+
<RunReviewButton
|
|
57
|
+
target={{ type: 'mr', repositoryId: 7, mrIid: 42, title: 'Fix permissions' }}
|
|
58
|
+
onTriggered={onTriggered}
|
|
59
|
+
/>,
|
|
60
|
+
);
|
|
61
|
+
fireEvent.click(screen.getByRole('button', { name: /Code Review/ }));
|
|
62
|
+
fireEvent.click(await screen.findByRole('menuitem', { name: /Run automated review/ }));
|
|
63
|
+
await screen.findByText('Security — @reviewer');
|
|
64
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Start Review' }));
|
|
65
|
+
|
|
66
|
+
await waitFor(() => {
|
|
67
|
+
expect(mocks.request).toHaveBeenCalledWith(
|
|
68
|
+
expect.objectContaining({
|
|
69
|
+
url: 'gitManager:triggerReview',
|
|
70
|
+
method: 'post',
|
|
71
|
+
data: expect.objectContaining({
|
|
72
|
+
repositoryId: 7,
|
|
73
|
+
targetType: 'mr',
|
|
74
|
+
flowId: 1,
|
|
75
|
+
mrIid: 42,
|
|
76
|
+
}),
|
|
77
|
+
}),
|
|
78
|
+
);
|
|
79
|
+
expect(onTriggered).toHaveBeenCalledWith(123);
|
|
80
|
+
});
|
|
81
|
+
expect(mocks.getPlugin).not.toHaveBeenCalled();
|
|
82
|
+
expect(mocks.triggerTask).not.toHaveBeenCalled();
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
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 { reviewApprovalHref, workflowHref } from '../workflowRoutes';
|
|
11
|
+
|
|
12
|
+
type RouteWindow = Window & {
|
|
13
|
+
__nocobase_modern_client_prefix__?: string;
|
|
14
|
+
__nocobase_public_path__?: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const routeWindow = window as RouteWindow;
|
|
18
|
+
const createApp = (publicPath: string, basename?: string) =>
|
|
19
|
+
({
|
|
20
|
+
getPublicPath: () => publicPath,
|
|
21
|
+
router: { getBasename: () => basename },
|
|
22
|
+
}) as unknown as Parameters<typeof workflowHref>[0];
|
|
23
|
+
|
|
24
|
+
describe('Git review workflow route resolution', () => {
|
|
25
|
+
let originalPath: string;
|
|
26
|
+
let originalPublicPath: string | undefined;
|
|
27
|
+
let originalModernPrefix: string | undefined;
|
|
28
|
+
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
originalPath = window.location.pathname;
|
|
31
|
+
originalPublicPath = routeWindow.__nocobase_public_path__;
|
|
32
|
+
originalModernPrefix = routeWindow.__nocobase_modern_client_prefix__;
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
afterEach(() => {
|
|
36
|
+
window.history.replaceState({}, '', originalPath);
|
|
37
|
+
if (originalPublicPath === undefined) delete routeWindow.__nocobase_public_path__;
|
|
38
|
+
else routeWindow.__nocobase_public_path__ = originalPublicPath;
|
|
39
|
+
if (originalModernPrefix === undefined) delete routeWindow.__nocobase_modern_client_prefix__;
|
|
40
|
+
else routeWindow.__nocobase_modern_client_prefix__ = originalModernPrefix;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('keeps workflow links in the legacy shell and sends approval tasks through the modern prefix', () => {
|
|
44
|
+
routeWindow.__nocobase_modern_client_prefix__ = 'v3-custom';
|
|
45
|
+
routeWindow.__nocobase_public_path__ = '/tenant/app/v3-custom/';
|
|
46
|
+
window.history.replaceState({}, '', '/tenant/app/admin/settings/workflow');
|
|
47
|
+
const app = createApp('/tenant/app/v3-custom/');
|
|
48
|
+
|
|
49
|
+
expect(workflowHref(app, 'workflow', 'flow/42')).toBe('/tenant/app/admin/settings/workflow/workflows/flow%2F42');
|
|
50
|
+
expect(workflowHref(app, 'execution', 73)).toBe('/tenant/app/admin/settings/workflow/executions/73');
|
|
51
|
+
expect(reviewApprovalHref(app)).toBe('/tenant/app/v3-custom/admin/workflow/tasks/git-review-approval/pending');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('uses the effective modern basename and custom modern prefix for v2 workflow links', () => {
|
|
55
|
+
routeWindow.__nocobase_modern_client_prefix__ = 'ops-ui';
|
|
56
|
+
routeWindow.__nocobase_public_path__ = '/org/portal/ops-ui/';
|
|
57
|
+
window.history.replaceState({}, '', '/org/portal/ops-ui/admin/workflow');
|
|
58
|
+
const app = createApp('/org/portal/ops-ui/', '/org/portal/ops-ui/');
|
|
59
|
+
|
|
60
|
+
expect(workflowHref(app, 'workflow', 'review flow')).toBe(
|
|
61
|
+
'/org/portal/ops-ui/admin/workflow/workflows/review%20flow',
|
|
62
|
+
);
|
|
63
|
+
expect(reviewApprovalHref(app)).toBe('/org/portal/ops-ui/admin/workflow/tasks/git-review-approval/pending');
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -1,114 +1,114 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Space } from 'antd';
|
|
3
|
-
import { BranchesOutlined, MergeOutlined, NodeIndexOutlined } from '@ant-design/icons';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* WorkContext options exported as plain objects so we can register them
|
|
7
|
-
* regardless of whether plugin-ai is installed at compile time. The plugin
|
|
8
|
-
* checks `app.aiManager` at runtime before registering.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export const GitRepositoryWorkContext: any = {
|
|
12
|
-
name: 'git-repository',
|
|
13
|
-
menu: {
|
|
14
|
-
icon: <BranchesOutlined />,
|
|
15
|
-
Component: () => <span>Git Repository</span>,
|
|
16
|
-
},
|
|
17
|
-
tag: {
|
|
18
|
-
Component: ({ item }: any) => (
|
|
19
|
-
<Space size={4}>
|
|
20
|
-
<BranchesOutlined />
|
|
21
|
-
<span>{item?.title || `Repo #${item?.uid}`}</span>
|
|
22
|
-
</Space>
|
|
23
|
-
),
|
|
24
|
-
},
|
|
25
|
-
getContent: async (app: any, { uid }: any) => {
|
|
26
|
-
const response = await app.apiClient.request({
|
|
27
|
-
url: 'gitRepositories:get',
|
|
28
|
-
params: { filterByTk: uid },
|
|
29
|
-
});
|
|
30
|
-
const repo = response?.data?.data;
|
|
31
|
-
if (!repo) return null;
|
|
32
|
-
return {
|
|
33
|
-
type: 'git-repository',
|
|
34
|
-
repositoryId: repo.id,
|
|
35
|
-
name: repo.name,
|
|
36
|
-
repoUrl: repo.repoUrl,
|
|
37
|
-
defaultBranch: repo.defaultBranch,
|
|
38
|
-
status: repo.status,
|
|
39
|
-
};
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const GitMergeRequestWorkContext: any = {
|
|
44
|
-
name: 'git-merge-request',
|
|
45
|
-
menu: {
|
|
46
|
-
icon: <MergeOutlined />,
|
|
47
|
-
Component: () => <span>Git Merge Request</span>,
|
|
48
|
-
},
|
|
49
|
-
tag: {
|
|
50
|
-
Component: ({ item }: any) => (
|
|
51
|
-
<Space size={4}>
|
|
52
|
-
<MergeOutlined />
|
|
53
|
-
<span>{item?.title || `MR ${item?.uid}`}</span>
|
|
54
|
-
</Space>
|
|
55
|
-
),
|
|
56
|
-
},
|
|
57
|
-
getContent: async (app: any, { uid }: any) => {
|
|
58
|
-
// uid format: "<repositoryId>:<mrIid>"
|
|
59
|
-
const [repoIdStr, mrIidStr] = String(uid || '').split(':');
|
|
60
|
-
const repositoryId = Number(repoIdStr);
|
|
61
|
-
const mrIid = Number(mrIidStr);
|
|
62
|
-
if (!repositoryId || !mrIid) return null;
|
|
63
|
-
const response = await app.apiClient.request({
|
|
64
|
-
url: 'gitManager:mergeRequestDetail',
|
|
65
|
-
params: { repositoryId, mrIid },
|
|
66
|
-
});
|
|
67
|
-
const data = response?.data?.data;
|
|
68
|
-
return {
|
|
69
|
-
type: 'git-merge-request',
|
|
70
|
-
repositoryId,
|
|
71
|
-
mrIid,
|
|
72
|
-
title: data?.title,
|
|
73
|
-
sourceBranch: data?.sourceBranch,
|
|
74
|
-
targetBranch: data?.targetBranch,
|
|
75
|
-
author: data?.author,
|
|
76
|
-
changes: data?.changes,
|
|
77
|
-
description: data?.description,
|
|
78
|
-
webUrl: data?.webUrl,
|
|
79
|
-
};
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export const GitCommitWorkContext: any = {
|
|
84
|
-
name: 'git-commit',
|
|
85
|
-
menu: {
|
|
86
|
-
icon: <NodeIndexOutlined />,
|
|
87
|
-
Component: () => <span>Git Commit</span>,
|
|
88
|
-
},
|
|
89
|
-
tag: {
|
|
90
|
-
Component: ({ item }: any) => (
|
|
91
|
-
<Space size={4}>
|
|
92
|
-
<NodeIndexOutlined />
|
|
93
|
-
<span>{item?.title || `Commit ${item?.uid}`}</span>
|
|
94
|
-
</Space>
|
|
95
|
-
),
|
|
96
|
-
},
|
|
97
|
-
getContent: async (app: any, { uid }: any) => {
|
|
98
|
-
// uid format: "<repositoryId>:<commitSha>"
|
|
99
|
-
const [repoIdStr, commitSha] = String(uid || '').split(':');
|
|
100
|
-
const repositoryId = Number(repoIdStr);
|
|
101
|
-
if (!repositoryId || !commitSha) return null;
|
|
102
|
-
const response = await app.apiClient.request({
|
|
103
|
-
url: 'gitManager:commitDetail',
|
|
104
|
-
params: { repositoryId, commitHash: commitSha },
|
|
105
|
-
});
|
|
106
|
-
const data = response?.data?.data;
|
|
107
|
-
return {
|
|
108
|
-
type: 'git-commit',
|
|
109
|
-
repositoryId,
|
|
110
|
-
commitSha,
|
|
111
|
-
...data,
|
|
112
|
-
};
|
|
113
|
-
},
|
|
114
|
-
};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Space } from 'antd';
|
|
3
|
+
import { BranchesOutlined, MergeOutlined, NodeIndexOutlined } from '@ant-design/icons';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* WorkContext options exported as plain objects so we can register them
|
|
7
|
+
* regardless of whether plugin-ai is installed at compile time. The plugin
|
|
8
|
+
* checks `app.aiManager` at runtime before registering.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export const GitRepositoryWorkContext: any = {
|
|
12
|
+
name: 'git-repository',
|
|
13
|
+
menu: {
|
|
14
|
+
icon: <BranchesOutlined />,
|
|
15
|
+
Component: () => <span>Git Repository</span>,
|
|
16
|
+
},
|
|
17
|
+
tag: {
|
|
18
|
+
Component: ({ item }: any) => (
|
|
19
|
+
<Space size={4}>
|
|
20
|
+
<BranchesOutlined />
|
|
21
|
+
<span>{item?.title || `Repo #${item?.uid}`}</span>
|
|
22
|
+
</Space>
|
|
23
|
+
),
|
|
24
|
+
},
|
|
25
|
+
getContent: async (app: any, { uid }: any) => {
|
|
26
|
+
const response = await app.apiClient.request({
|
|
27
|
+
url: 'gitRepositories:get',
|
|
28
|
+
params: { filterByTk: uid },
|
|
29
|
+
});
|
|
30
|
+
const repo = response?.data?.data;
|
|
31
|
+
if (!repo) return null;
|
|
32
|
+
return {
|
|
33
|
+
type: 'git-repository',
|
|
34
|
+
repositoryId: repo.id,
|
|
35
|
+
name: repo.name,
|
|
36
|
+
repoUrl: repo.repoUrl,
|
|
37
|
+
defaultBranch: repo.defaultBranch,
|
|
38
|
+
status: repo.status,
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const GitMergeRequestWorkContext: any = {
|
|
44
|
+
name: 'git-merge-request',
|
|
45
|
+
menu: {
|
|
46
|
+
icon: <MergeOutlined />,
|
|
47
|
+
Component: () => <span>Git Merge Request</span>,
|
|
48
|
+
},
|
|
49
|
+
tag: {
|
|
50
|
+
Component: ({ item }: any) => (
|
|
51
|
+
<Space size={4}>
|
|
52
|
+
<MergeOutlined />
|
|
53
|
+
<span>{item?.title || `MR ${item?.uid}`}</span>
|
|
54
|
+
</Space>
|
|
55
|
+
),
|
|
56
|
+
},
|
|
57
|
+
getContent: async (app: any, { uid }: any) => {
|
|
58
|
+
// uid format: "<repositoryId>:<mrIid>"
|
|
59
|
+
const [repoIdStr, mrIidStr] = String(uid || '').split(':');
|
|
60
|
+
const repositoryId = Number(repoIdStr);
|
|
61
|
+
const mrIid = Number(mrIidStr);
|
|
62
|
+
if (!repositoryId || !mrIid) return null;
|
|
63
|
+
const response = await app.apiClient.request({
|
|
64
|
+
url: 'gitManager:mergeRequestDetail',
|
|
65
|
+
params: { repositoryId, mrIid },
|
|
66
|
+
});
|
|
67
|
+
const data = response?.data?.data;
|
|
68
|
+
return {
|
|
69
|
+
type: 'git-merge-request',
|
|
70
|
+
repositoryId,
|
|
71
|
+
mrIid,
|
|
72
|
+
title: data?.title,
|
|
73
|
+
sourceBranch: data?.sourceBranch,
|
|
74
|
+
targetBranch: data?.targetBranch,
|
|
75
|
+
author: data?.author,
|
|
76
|
+
changes: data?.changes,
|
|
77
|
+
description: data?.description,
|
|
78
|
+
webUrl: data?.webUrl,
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const GitCommitWorkContext: any = {
|
|
84
|
+
name: 'git-commit',
|
|
85
|
+
menu: {
|
|
86
|
+
icon: <NodeIndexOutlined />,
|
|
87
|
+
Component: () => <span>Git Commit</span>,
|
|
88
|
+
},
|
|
89
|
+
tag: {
|
|
90
|
+
Component: ({ item }: any) => (
|
|
91
|
+
<Space size={4}>
|
|
92
|
+
<NodeIndexOutlined />
|
|
93
|
+
<span>{item?.title || `Commit ${item?.uid}`}</span>
|
|
94
|
+
</Space>
|
|
95
|
+
),
|
|
96
|
+
},
|
|
97
|
+
getContent: async (app: any, { uid }: any) => {
|
|
98
|
+
// uid format: "<repositoryId>:<commitSha>"
|
|
99
|
+
const [repoIdStr, commitSha] = String(uid || '').split(':');
|
|
100
|
+
const repositoryId = Number(repoIdStr);
|
|
101
|
+
if (!repositoryId || !commitSha) return null;
|
|
102
|
+
const response = await app.apiClient.request({
|
|
103
|
+
url: 'gitManager:commitDetail',
|
|
104
|
+
params: { repositoryId, commitHash: commitSha },
|
|
105
|
+
});
|
|
106
|
+
const data = response?.data?.data;
|
|
107
|
+
return {
|
|
108
|
+
type: 'git-commit',
|
|
109
|
+
repositoryId,
|
|
110
|
+
commitSha,
|
|
111
|
+
...data,
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
};
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { Select } from 'antd';
|
|
3
|
-
import { useApp } from '@nocobase/client-v2';
|
|
4
|
-
|
|
5
|
-
interface AIEmployeeOption {
|
|
6
|
-
username: string;
|
|
7
|
-
nickname?: string;
|
|
8
|
-
avatar?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Select dropdown listing AI employees the current user has access to.
|
|
13
|
-
* Calls `aiEmployees:listByUser` from plugin-ai.
|
|
14
|
-
*/
|
|
15
|
-
export const AIEmployeeSelect: React.FC<{
|
|
16
|
-
value?: string;
|
|
17
|
-
onChange?: (value: string) => void;
|
|
18
|
-
allowClear?: boolean;
|
|
19
|
-
size?: 'small' | 'middle' | 'large';
|
|
20
|
-
style?: React.CSSProperties;
|
|
21
|
-
placeholder?: string;
|
|
22
|
-
}> = ({ value, onChange, allowClear = true, size, style, placeholder }) => {
|
|
23
|
-
const api = useApp().apiClient;
|
|
24
|
-
const [employees, setEmployees] = useState<AIEmployeeOption[]>([]);
|
|
25
|
-
const [loading, setLoading] = useState(false);
|
|
26
|
-
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
let cancelled = false;
|
|
29
|
-
setLoading(true);
|
|
30
|
-
api
|
|
31
|
-
.request({ url: 'aiEmployees:listByUser' })
|
|
32
|
-
.then((res) => {
|
|
33
|
-
if (cancelled) return;
|
|
34
|
-
const list = res?.data?.data || [];
|
|
35
|
-
setEmployees(Array.isArray(list) ? list : []);
|
|
36
|
-
})
|
|
37
|
-
.catch(() => undefined)
|
|
38
|
-
.finally(() => {
|
|
39
|
-
if (!cancelled) setLoading(false);
|
|
40
|
-
});
|
|
41
|
-
return () => {
|
|
42
|
-
cancelled = true;
|
|
43
|
-
};
|
|
44
|
-
}, [api]);
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<Select
|
|
48
|
-
value={value}
|
|
49
|
-
onChange={onChange}
|
|
50
|
-
allowClear={allowClear}
|
|
51
|
-
loading={loading}
|
|
52
|
-
size={size}
|
|
53
|
-
style={style}
|
|
54
|
-
placeholder={placeholder || 'Select AI employee'}
|
|
55
|
-
options={employees.map((e) => ({
|
|
56
|
-
value: e.username,
|
|
57
|
-
label: `${e.nickname || e.username} (@${e.username})`,
|
|
58
|
-
}))}
|
|
59
|
-
showSearch
|
|
60
|
-
optionFilterProp="label"
|
|
61
|
-
/>
|
|
62
|
-
);
|
|
63
|
-
};
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Select } from 'antd';
|
|
3
|
+
import { useApp } from '@nocobase/client-v2';
|
|
4
|
+
|
|
5
|
+
interface AIEmployeeOption {
|
|
6
|
+
username: string;
|
|
7
|
+
nickname?: string;
|
|
8
|
+
avatar?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Select dropdown listing AI employees the current user has access to.
|
|
13
|
+
* Calls `aiEmployees:listByUser` from plugin-ai.
|
|
14
|
+
*/
|
|
15
|
+
export const AIEmployeeSelect: React.FC<{
|
|
16
|
+
value?: string;
|
|
17
|
+
onChange?: (value: string) => void;
|
|
18
|
+
allowClear?: boolean;
|
|
19
|
+
size?: 'small' | 'middle' | 'large';
|
|
20
|
+
style?: React.CSSProperties;
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
}> = ({ value, onChange, allowClear = true, size, style, placeholder }) => {
|
|
23
|
+
const api = useApp().apiClient;
|
|
24
|
+
const [employees, setEmployees] = useState<AIEmployeeOption[]>([]);
|
|
25
|
+
const [loading, setLoading] = useState(false);
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
let cancelled = false;
|
|
29
|
+
setLoading(true);
|
|
30
|
+
api
|
|
31
|
+
.request({ url: 'aiEmployees:listByUser' })
|
|
32
|
+
.then((res) => {
|
|
33
|
+
if (cancelled) return;
|
|
34
|
+
const list = res?.data?.data || [];
|
|
35
|
+
setEmployees(Array.isArray(list) ? list : []);
|
|
36
|
+
})
|
|
37
|
+
.catch(() => undefined)
|
|
38
|
+
.finally(() => {
|
|
39
|
+
if (!cancelled) setLoading(false);
|
|
40
|
+
});
|
|
41
|
+
return () => {
|
|
42
|
+
cancelled = true;
|
|
43
|
+
};
|
|
44
|
+
}, [api]);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<Select
|
|
48
|
+
value={value}
|
|
49
|
+
onChange={onChange}
|
|
50
|
+
allowClear={allowClear}
|
|
51
|
+
loading={loading}
|
|
52
|
+
size={size}
|
|
53
|
+
style={style}
|
|
54
|
+
placeholder={placeholder || 'Select AI employee'}
|
|
55
|
+
options={employees.map((e) => ({
|
|
56
|
+
value: e.username,
|
|
57
|
+
label: `${e.nickname || e.username} (@${e.username})`,
|
|
58
|
+
}))}
|
|
59
|
+
showSearch
|
|
60
|
+
optionFilterProp="label"
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
};
|