plugin-git-manager 1.2.27 → 1.2.28
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 +133 -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/900.a48beac7e2ebee7d.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/900.e6155002a9c97e7f.js +10 -0
- package/dist/client-v2/928.bba701b5a1ece58e.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +9 -8
- package/dist/locale/en-US.json +307 -297
- package/dist/locale/vi-VN.json +295 -292
- package/dist/locale/zh-CN.json +61 -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.js +20 -10
- package/dist/server/plugin.js +6 -4
- package/dist/server/poller.js +46 -45
- package/dist/server/request-method-policy.js +75 -0
- package/dist/server/services/registry-content-service.js +4 -3
- 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__/RunReviewButton.test.tsx +73 -0
- package/src/client/ai-context.tsx +114 -114
- package/src/client/components/AIEmployeeSelect.tsx +63 -63
- package/src/client/components/CommitHistory.tsx +374 -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 +303 -303
- package/src/client/components/ReviewHistory.tsx +566 -566
- package/src/client/components/RunReviewButton.tsx +63 -55
- 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-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 +307 -297
- package/src/locale/vi-VN.json +295 -292
- package/src/locale/zh-CN.json +61 -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 +752 -752
- package/src/server/__tests__/review.test.ts +137 -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.ts +1388 -1369
- package/src/server/actions/role-permissions.ts +321 -321
- package/src/server/actions/subtree.ts +508 -508
- package/src/server/ai-tools.ts +319 -319
- package/src/server/collections/gitAccounts.ts +56 -56
- package/src/server/collections/gitCodeReviews.ts +199 -199
- package/src/server/collections/gitRepositories.ts +87 -87
- package/src/server/collections/gitReviewFlows.ts +108 -108
- package/src/server/collections/gitSubtreeConfigs.ts +38 -38
- package/src/server/collections/gitSubtreeRuns.ts +30 -30
- package/src/server/index.ts +2 -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 +372 -361
- package/src/server/poller.ts +351 -352
- package/src/server/repository-access.ts +773 -773
- package/src/server/request-method-policy.ts +55 -0
- package/src/server/services/__tests__/registry-content-service.test.ts +359 -345
- package/src/server/services/registry-content-service.ts +495 -484
- 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
|
@@ -73,7 +73,8 @@ const REGISTRY_GIT_FILE_NOT_FOUND = "REGISTRY_GIT_FILE_NOT_FOUND";
|
|
|
73
73
|
const REGISTRY_GIT_CONTENT_CONTRACT_VERSION = 2;
|
|
74
74
|
const REGISTRY_GIT_CONTENT_CAPABILITIES = [
|
|
75
75
|
"registry-content-with-actor",
|
|
76
|
-
"registry-content-authorize-source"
|
|
76
|
+
"registry-content-authorize-source",
|
|
77
|
+
"registry-content-tree-limits"
|
|
77
78
|
];
|
|
78
79
|
const SKILL_HUB_GIT_CONTENT_CONTRACT_VERSION = 2;
|
|
79
80
|
const SKILL_HUB_GIT_CONTENT_CAPABILITIES = ["skill-hub-content-with-actor"];
|
|
@@ -292,11 +293,11 @@ class GitContentService {
|
|
|
292
293
|
const output = await runGitBuffer(
|
|
293
294
|
localPath,
|
|
294
295
|
["ls-tree", "-l", ...input.recursive ? ["-r"] : [], target],
|
|
295
|
-
this.limits.maxTreeOutputBytes,
|
|
296
|
+
boundedPositive(input.maxTreeOutputBytes, this.limits.maxTreeOutputBytes, this.limits.maxTreeOutputBytes),
|
|
296
297
|
DEFAULT_GIT_TIMEOUT_MS
|
|
297
298
|
);
|
|
298
299
|
const lines = output.toString("utf8").trim().split("\n").filter(Boolean);
|
|
299
|
-
if (lines.length > this.limits.maxTreeEntries) {
|
|
300
|
+
if (lines.length > boundedPositive(input.maxTreeEntries, this.limits.maxTreeEntries, this.limits.maxTreeEntries)) {
|
|
300
301
|
throw new RegistryContentLimitError("Git tree contains too many entries for registry export.");
|
|
301
302
|
}
|
|
302
303
|
return lines.map((line) => parseTreeLine(line, rootPath)).filter((entry) => entry !== null).sort((left, right) => left.path.localeCompare(right.path));
|
|
@@ -38,12 +38,13 @@ async function getRepoAccount(db, repo) {
|
|
|
38
38
|
});
|
|
39
39
|
if (!account) return null;
|
|
40
40
|
const baseUrl = (account.get("baseUrl") || "").trim() || null;
|
|
41
|
-
|
|
41
|
+
const provider = (account.get("provider") || "gitlab").trim();
|
|
42
|
+
(0, import_url_security.assertAccountRepositoryUrl)(String(repo.get("repoUrl") || ""), baseUrl, provider);
|
|
42
43
|
return {
|
|
43
44
|
pat: (account.get("pat") || "").trim(),
|
|
44
45
|
username: (account.get("username") || "").trim(),
|
|
45
46
|
baseUrl,
|
|
46
|
-
provider
|
|
47
|
+
provider
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -27,6 +27,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
27
27
|
var url_security_exports = {};
|
|
28
28
|
__export(url_security_exports, {
|
|
29
29
|
URL_USERINFO_NOT_ALLOWED: () => URL_USERINFO_NOT_ALLOWED,
|
|
30
|
+
assertAccountRepositoryUrl: () => assertAccountRepositoryUrl,
|
|
30
31
|
assertUrlHasNoUserInfo: () => assertUrlHasNoUserInfo,
|
|
31
32
|
containsCredentialBearingUrlField: () => containsCredentialBearingUrlField,
|
|
32
33
|
hasUrlUserInfo: () => hasUrlUserInfo,
|
|
@@ -34,6 +35,28 @@ __export(url_security_exports, {
|
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(url_security_exports);
|
|
36
37
|
const URL_USERINFO_NOT_ALLOWED = "Credential-bearing URLs are not allowed";
|
|
38
|
+
function assertAccountRepositoryUrl(repoUrl, baseUrl, provider) {
|
|
39
|
+
assertUrlHasNoUserInfo(repoUrl);
|
|
40
|
+
const trustedUrl = baseUrl || (provider === "github" ? "https://github.com" : "https://gitlab.com");
|
|
41
|
+
assertUrlHasNoUserInfo(trustedUrl);
|
|
42
|
+
let repository;
|
|
43
|
+
let account;
|
|
44
|
+
try {
|
|
45
|
+
repository = new URL(repoUrl);
|
|
46
|
+
account = new URL(trustedUrl);
|
|
47
|
+
} catch {
|
|
48
|
+
throw new Error("Invalid repository or account URL");
|
|
49
|
+
}
|
|
50
|
+
if (repository.protocol !== "https:" || account.protocol !== "https:") {
|
|
51
|
+
throw new Error("Only HTTPS repository and account URLs are allowed");
|
|
52
|
+
}
|
|
53
|
+
if (repository.origin !== account.origin) {
|
|
54
|
+
throw new Error("Repository URL must match the Git account origin");
|
|
55
|
+
}
|
|
56
|
+
if (provider === "github" && repository.origin !== "https://github.com") {
|
|
57
|
+
throw new Error("GitHub accounts currently require github.com");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
37
60
|
function pathSegments(value) {
|
|
38
61
|
return value.split(/[.[\],:/()=\s'"]+/);
|
|
39
62
|
}
|
|
@@ -102,6 +125,7 @@ function redactUrlUserInfo(value) {
|
|
|
102
125
|
// Annotate the CommonJS export names for ESM import in node:
|
|
103
126
|
0 && (module.exports = {
|
|
104
127
|
URL_USERINFO_NOT_ALLOWED,
|
|
128
|
+
assertAccountRepositoryUrl,
|
|
105
129
|
assertUrlHasNoUserInfo,
|
|
106
130
|
containsCredentialBearingUrlField,
|
|
107
131
|
hasUrlUserInfo,
|
package/package.json
CHANGED
|
@@ -1,43 +1,61 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "plugin-git-manager",
|
|
3
|
-
"displayName": "Git Manager",
|
|
4
|
-
"displayName.zh-CN": "Git 管理器",
|
|
5
|
-
"description": "Manage Git repositories with PAT authentication - pull, push, fetch, diff, file browsing",
|
|
6
|
-
"version": "1.2.
|
|
7
|
-
"license": "Apache-2.0",
|
|
8
|
-
"main": "dist/server/index.js",
|
|
9
|
-
"files": [
|
|
10
|
-
"dist",
|
|
11
|
-
"src",
|
|
12
|
-
"client.js",
|
|
13
|
-
"server.js",
|
|
14
|
-
"client.d.ts",
|
|
15
|
-
"server.d.ts",
|
|
16
|
-
"client-v2.js",
|
|
17
|
-
"client-v2.d.ts"
|
|
18
|
-
],
|
|
19
|
-
"nocobase": {
|
|
20
|
-
"supportedVersions": [
|
|
21
|
-
"2.x"
|
|
22
|
-
],
|
|
23
|
-
"editionLevel": 0
|
|
24
|
-
},
|
|
25
|
-
"peerDependencies": {
|
|
26
|
-
"@nocobase/client": "2.x",
|
|
27
|
-
"@nocobase/server": "2.x",
|
|
28
|
-
"@nocobase/database": "2.x",
|
|
29
|
-
"@nocobase/test": "2.x",
|
|
30
|
-
"@nocobase/client-v2": "2.x",
|
|
31
|
-
"@nocobase/flow-engine": "2.x"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"@nocobase/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "plugin-git-manager",
|
|
3
|
+
"displayName": "Git Manager",
|
|
4
|
+
"displayName.zh-CN": "Git 管理器",
|
|
5
|
+
"description": "Manage Git repositories with PAT authentication - pull, push, fetch, diff, file browsing",
|
|
6
|
+
"version": "1.2.28",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"main": "dist/server/index.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"src",
|
|
12
|
+
"client.js",
|
|
13
|
+
"server.js",
|
|
14
|
+
"client.d.ts",
|
|
15
|
+
"server.d.ts",
|
|
16
|
+
"client-v2.js",
|
|
17
|
+
"client-v2.d.ts"
|
|
18
|
+
],
|
|
19
|
+
"nocobase": {
|
|
20
|
+
"supportedVersions": [
|
|
21
|
+
"2.x"
|
|
22
|
+
],
|
|
23
|
+
"editionLevel": 0
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@nocobase/client": "2.x",
|
|
27
|
+
"@nocobase/server": "2.x",
|
|
28
|
+
"@nocobase/database": "2.x",
|
|
29
|
+
"@nocobase/test": "2.x",
|
|
30
|
+
"@nocobase/client-v2": "2.x",
|
|
31
|
+
"@nocobase/flow-engine": "2.x",
|
|
32
|
+
"@nocobase/ai": "2.x",
|
|
33
|
+
"@nocobase/plugin-ai": "2.x",
|
|
34
|
+
"@nocobase/plugin-field-markdown-vditor": "2.x"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"simple-git": "^3.27.0"
|
|
38
|
+
},
|
|
39
|
+
"keywords": "System management",
|
|
40
|
+
"peerDependenciesMeta": {
|
|
41
|
+
"@nocobase/ai": {
|
|
42
|
+
"optional": true
|
|
43
|
+
},
|
|
44
|
+
"@nocobase/plugin-ai": {
|
|
45
|
+
"optional": true
|
|
46
|
+
},
|
|
47
|
+
"@nocobase/plugin-field-markdown-vditor": {
|
|
48
|
+
"optional": true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/OrgGem/nocobase-beta.git",
|
|
54
|
+
"directory": "packages/plugins/plugin-git-manager"
|
|
55
|
+
},
|
|
56
|
+
"gitHead": "4c1fe95b5f725713505c59944232259eb386bcf7",
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public",
|
|
59
|
+
"registry": "https://registry.npmjs.org/"
|
|
60
|
+
}
|
|
61
|
+
}
|
package/server.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './dist/server';
|
|
2
|
-
export { default } from './dist/server';
|
|
1
|
+
export * from './dist/server';
|
|
2
|
+
export { default } from './dist/server';
|
package/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('./dist/server/index.js');
|
|
1
|
+
module.exports = require('./dist/server/index.js');
|
|
@@ -0,0 +1,73 @@
|
|
|
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(() => ({ request: vi.fn(), getPlugin: vi.fn(), triggerTask: vi.fn() }));
|
|
15
|
+
vi.mock('@nocobase/client-v2', () => ({
|
|
16
|
+
useApp: () => ({ apiClient: { request: mocks.request }, pm: { get: mocks.getPlugin } }),
|
|
17
|
+
}));
|
|
18
|
+
vi.mock('../locale', () => ({ useT: () => (key: string) => key }));
|
|
19
|
+
// Any accidental runtime import of the optional AI package must fail this suite.
|
|
20
|
+
vi.mock('@nocobase/plugin-ai', () => {
|
|
21
|
+
throw new Error('Unexpected legacy AI import');
|
|
22
|
+
});
|
|
23
|
+
vi.mock('@nocobase/plugin-ai/client-v2', () => {
|
|
24
|
+
throw new Error('Unexpected mandatory AI import');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe('RunReviewButton optional AI integration', () => {
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
vi.clearAllMocks();
|
|
30
|
+
mocks.getPlugin.mockReturnValue(undefined);
|
|
31
|
+
mocks.request.mockImplementation(async ({ url }: { url: string }) => ({
|
|
32
|
+
data: {
|
|
33
|
+
data: url === 'gitReviewFlows:list' ? [{ id: 1, name: 'Security', aiEmployeeUsername: 'reviewer' }] : [],
|
|
34
|
+
},
|
|
35
|
+
}));
|
|
36
|
+
});
|
|
37
|
+
afterEach(cleanup);
|
|
38
|
+
|
|
39
|
+
it('renders Git review controls without the AI plugin and disables only chat', async () => {
|
|
40
|
+
render(<RunReviewButton target={{ type: 'branch', repositoryId: 7, branch: 'main' }} />);
|
|
41
|
+
fireEvent.click(screen.getByRole('button', { name: /Code Review/ }));
|
|
42
|
+
const chat = await screen.findByRole('menuitem', { name: /Ask AI Employee/ });
|
|
43
|
+
expect(chat.getAttribute('aria-disabled')).toBe('true');
|
|
44
|
+
expect(screen.getByRole('menuitem', { name: /Run automated review/ }).getAttribute('aria-disabled')).not.toBe(
|
|
45
|
+
'true',
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('opens a contextual task through the installed AI manager', async () => {
|
|
50
|
+
mocks.getPlugin.mockReturnValue({ aiManager: { triggerTask: mocks.triggerTask } });
|
|
51
|
+
render(<RunReviewButton target={{ type: 'mr', repositoryId: 7, mrIid: 42, title: 'Fix permissions' }} />);
|
|
52
|
+
fireEvent.click(screen.getByRole('button', { name: /Code Review/ }));
|
|
53
|
+
fireEvent.click(await screen.findByRole('menuitem', { name: /Ask AI Employee/ }));
|
|
54
|
+
await waitFor(() => expect(mocks.triggerTask).toHaveBeenCalledTimes(1));
|
|
55
|
+
expect(mocks.triggerTask).toHaveBeenCalledWith({
|
|
56
|
+
aiEmployee: 'reviewer',
|
|
57
|
+
tasks: [
|
|
58
|
+
expect.objectContaining({
|
|
59
|
+
autoSend: false,
|
|
60
|
+
message: expect.objectContaining({
|
|
61
|
+
workContext: [
|
|
62
|
+
expect.objectContaining({
|
|
63
|
+
type: 'git-merge-request',
|
|
64
|
+
content: { repositoryId: 7, mrIid: 42, title: 'Fix permissions' },
|
|
65
|
+
}),
|
|
66
|
+
],
|
|
67
|
+
}),
|
|
68
|
+
}),
|
|
69
|
+
],
|
|
70
|
+
});
|
|
71
|
+
expect(mocks.getPlugin).toHaveBeenCalledWith('ai');
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -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
|
+
};
|