plugin-git-manager 1.3.3 → 1.4.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/dist/client/{156.c27c2392746e7866.js → 156.8e36af3e2cee173e.js} +1 -1
- package/dist/client/317.e7b1d59371812c30.js +10 -0
- package/dist/client/434.05d0ba2b821105dc.js +10 -0
- package/dist/client/453.cdcba6d2d0c9522b.js +10 -0
- package/dist/client/454.625da741a7e1161f.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client-v2/317.4e116f84ed9081b6.js +10 -0
- package/dist/client-v2/434.764113d20743a45b.js +10 -0
- package/dist/client-v2/453.5ab80c06d8e61a7e.js +10 -0
- package/dist/client-v2/454.b885b1d35ef7ff72.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +10 -9
- package/dist/locale/en-US.json +38 -1
- package/dist/locale/vi-VN.json +38 -1
- package/dist/locale/zh-CN.json +41 -1
- package/dist/node_modules/simple-git/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/actions/chat-context.js +282 -0
- package/dist/server/actions/git-actions.js +387 -80
- package/dist/server/actions/gitlab-api.js +101 -15
- package/dist/server/actions/subtree.js +20 -10
- package/dist/server/chat-context-admission.js +187 -0
- package/dist/server/plugin.js +142 -10
- package/dist/server/repository-access.js +2 -2
- package/dist/server/request-method-policy.js +4 -1
- package/dist/server/services/review-source.js +2 -1
- package/dist/server/utils/cluster-git.js +181 -0
- package/package.json +2 -2
- package/src/client/__tests__/FileExplorerAndManage.test.tsx +236 -0
- package/src/client/__tests__/GitContextPicker.test.tsx +120 -0
- package/src/client/__tests__/ai-context.test.tsx +119 -0
- package/src/client/__tests__/workflowRoutes.test.ts +3 -1
- package/src/client/ai-context.tsx +3 -113
- package/src/client/components/CommitHistory.tsx +19 -7
- package/src/client/components/FileExplorer.tsx +80 -34
- package/src/client/components/GitManagerSettings.tsx +21 -5
- package/src/client/components/GitOperations.tsx +25 -4
- package/src/client/components/GitRuntimeBanner.tsx +97 -0
- package/src/client/components/RepositoryConfig.tsx +28 -6
- package/src/client/context/GitManagerContext.tsx +174 -15
- package/src/client/index.tsx +3 -5
- package/src/client/workflowRoutes.ts +11 -0
- package/src/client-v2/ai-context.tsx +135 -72
- package/src/client-v2/components/GitContextPicker.tsx +418 -0
- package/src/client-v2/git-context-api.ts +59 -0
- package/src/client-v2/plugin.tsx +2 -4
- package/src/locale/en-US.json +38 -1
- package/src/locale/vi-VN.json +38 -1
- package/src/locale/zh-CN.json +41 -1
- package/src/server/__tests__/chat-context-admission.test.ts +276 -0
- package/src/server/__tests__/chat-context-options.test.ts +144 -0
- package/src/server/__tests__/git-actions.test.ts +329 -4
- package/src/server/__tests__/git-chat-context.test.ts +138 -0
- package/src/server/__tests__/git-security.test.ts +52 -0
- package/src/server/__tests__/smoke.test.ts +232 -1
- package/src/server/actions/chat-context.ts +302 -0
- package/src/server/actions/git-actions.ts +428 -89
- package/src/server/actions/gitlab-api.ts +113 -14
- package/src/server/actions/subtree.ts +23 -6
- package/src/server/chat-context-admission.ts +182 -0
- package/src/server/plugin.ts +163 -3
- package/src/server/repository-access.ts +2 -2
- package/src/server/request-method-policy.ts +3 -0
- package/src/server/services/review-source.ts +3 -2
- package/src/server/utils/cluster-git.ts +209 -0
- package/dist/client/317.17ed0018e3e7db00.js +0 -10
- package/dist/client/434.b2eeaaef33aae6e0.js +0 -10
- package/dist/client/453.fc3042c9740d8fab.js +0 -10
- package/dist/client-v2/317.d2466574d00f94d0.js +0 -10
- package/dist/client-v2/434.19c7579c06b9077c.js +0 -10
- package/dist/client-v2/453.5e507c94c59277b1.js +0 -10
|
@@ -1,3 +1,12 @@
|
|
|
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
|
+
|
|
1
10
|
import React, { useEffect, useState, useCallback, useMemo, useRef } from 'react';
|
|
2
11
|
import { Tree, Empty, Spin, Typography, Select, Space, Breadcrumb, Input, theme } from 'antd';
|
|
3
12
|
import {
|
|
@@ -78,24 +87,30 @@ export const FileExplorer: React.FC = () => {
|
|
|
78
87
|
const t = useT();
|
|
79
88
|
const { token } = useToken();
|
|
80
89
|
const api = useApp().apiClient;
|
|
81
|
-
const { selectedRepo, branches: branchList,
|
|
90
|
+
const { selectedRepo, branches: branchList, refreshBranches, gitRuntime, refreshRuntimeStatus } = useGitManager();
|
|
91
|
+
const selectedRepoId = selectedRepo?.id;
|
|
92
|
+
const selectedRepoStatus = selectedRepo?.status;
|
|
93
|
+
const gitAvailable = gitRuntime?.gitAvailable !== false;
|
|
82
94
|
const [treeData, setTreeData] = useState<TreeNode[]>([]);
|
|
83
95
|
const [loading, setLoading] = useState(false);
|
|
84
96
|
const [fileContent, setFileContent] = useState<string | null>(null);
|
|
85
97
|
const [selectedFile, setSelectedFile] = useState<string | null>(null);
|
|
86
98
|
const [selectedFolder, setSelectedFolder] = useState<string | null>(null);
|
|
87
99
|
const [currentRef, setCurrentRef] = useState('HEAD');
|
|
100
|
+
const currentRefRef = useRef(currentRef);
|
|
101
|
+
currentRefRef.current = currentRef;
|
|
88
102
|
const [searchText, setSearchText] = useState('');
|
|
89
103
|
const [debouncedSearch, setDebouncedSearch] = useState('');
|
|
90
104
|
const [contentLoading, setContentLoading] = useState(false);
|
|
91
105
|
|
|
92
106
|
const loadTree = useCallback(
|
|
93
|
-
async (treePath = '', ref
|
|
94
|
-
|
|
107
|
+
async (treePath = '', ref?: string) => {
|
|
108
|
+
const effectiveRef = ref ?? currentRefRef.current;
|
|
109
|
+
if (!selectedRepoId || !gitAvailable) return [];
|
|
95
110
|
try {
|
|
96
111
|
const { data } = await api.request({
|
|
97
112
|
url: 'gitManager:fileTree',
|
|
98
|
-
params: { repositoryId:
|
|
113
|
+
params: { repositoryId: selectedRepoId, ref: effectiveRef, treePath },
|
|
99
114
|
});
|
|
100
115
|
const responseData = data?.data || data || [];
|
|
101
116
|
const list = Array.isArray(responseData)
|
|
@@ -104,7 +119,7 @@ export const FileExplorer: React.FC = () => {
|
|
|
104
119
|
? responseData.data
|
|
105
120
|
: [];
|
|
106
121
|
|
|
107
|
-
return list.map((item:
|
|
122
|
+
return list.map((item: { path: string; name: string; type: string; size: number }) => ({
|
|
108
123
|
key: item.path,
|
|
109
124
|
title: (
|
|
110
125
|
<Text style={{ fontSize: 13 }}>
|
|
@@ -123,47 +138,65 @@ export const FileExplorer: React.FC = () => {
|
|
|
123
138
|
}));
|
|
124
139
|
} catch (error) {
|
|
125
140
|
console.warn('Failed to load file tree:', error);
|
|
141
|
+
refreshRuntimeStatus?.();
|
|
126
142
|
return [];
|
|
127
143
|
}
|
|
128
144
|
},
|
|
129
|
-
[api,
|
|
145
|
+
[api, selectedRepoId, gitAvailable, refreshRuntimeStatus],
|
|
130
146
|
);
|
|
131
147
|
|
|
132
|
-
const loadRoot = useCallback(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
148
|
+
const loadRoot = useCallback(
|
|
149
|
+
async (refToLoad: string) => {
|
|
150
|
+
setLoading(true);
|
|
151
|
+
try {
|
|
152
|
+
const nodes = await loadTree('', refToLoad);
|
|
153
|
+
setTreeData(nodes);
|
|
154
|
+
} finally {
|
|
155
|
+
setLoading(false);
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
[loadTree],
|
|
159
|
+
);
|
|
141
160
|
|
|
142
161
|
useEffect(() => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
162
|
+
let cancelled = false;
|
|
163
|
+
setFileContent(null);
|
|
164
|
+
setSelectedFile(null);
|
|
165
|
+
setSelectedFolder(null);
|
|
166
|
+
setCurrentRef('HEAD');
|
|
167
|
+
|
|
168
|
+
if (!selectedRepoId || selectedRepoStatus !== 'connected' || !gitAvailable) {
|
|
149
169
|
setTreeData([]);
|
|
170
|
+
return () => {
|
|
171
|
+
cancelled = true;
|
|
172
|
+
};
|
|
150
173
|
}
|
|
151
|
-
}, [selectedRepo]);
|
|
152
174
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
175
|
+
const initializeRepositoryView = async () => {
|
|
176
|
+
setLoading(true);
|
|
177
|
+
try {
|
|
178
|
+
const resolvedBranch = await refreshBranches();
|
|
179
|
+
if (cancelled) return;
|
|
180
|
+
const nextRef = resolvedBranch || 'HEAD';
|
|
181
|
+
setCurrentRef(nextRef);
|
|
182
|
+
const nodes = await loadTree('', nextRef);
|
|
183
|
+
if (!cancelled) {
|
|
184
|
+
setTreeData(nodes);
|
|
185
|
+
}
|
|
186
|
+
} finally {
|
|
187
|
+
if (!cancelled) {
|
|
188
|
+
setLoading(false);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
};
|
|
159
192
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
}, [
|
|
193
|
+
initializeRepositoryView();
|
|
194
|
+
return () => {
|
|
195
|
+
cancelled = true;
|
|
196
|
+
};
|
|
197
|
+
}, [selectedRepoId, selectedRepoStatus, gitAvailable, refreshBranches, loadTree]);
|
|
165
198
|
|
|
166
|
-
const onLoadData = async (node:
|
|
199
|
+
const onLoadData = async (node: TreeNode) => {
|
|
167
200
|
if (node.children) return;
|
|
168
201
|
const children = await loadTree(node.filePath, currentRef);
|
|
169
202
|
setTreeData((prev) => updateTreeData(prev, node.key, children));
|
|
@@ -217,6 +250,18 @@ export const FileExplorer: React.FC = () => {
|
|
|
217
250
|
return <Empty description={t('Repository not cloned yet')} />;
|
|
218
251
|
}
|
|
219
252
|
|
|
253
|
+
if (!gitAvailable) {
|
|
254
|
+
return (
|
|
255
|
+
<Empty
|
|
256
|
+
description={t(
|
|
257
|
+
gitRuntime?.clusterManager.status === 'running'
|
|
258
|
+
? 'Installing Git via Cluster Manager...'
|
|
259
|
+
: 'Git CLI is not installed on this node yet',
|
|
260
|
+
)}
|
|
261
|
+
/>
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
|
|
220
265
|
const filteredTree = debouncedSearch ? filterTree(treeData, debouncedSearch.toLowerCase()) : treeData;
|
|
221
266
|
|
|
222
267
|
return (
|
|
@@ -243,6 +288,7 @@ export const FileExplorer: React.FC = () => {
|
|
|
243
288
|
setFileContent(null);
|
|
244
289
|
setSelectedFile(null);
|
|
245
290
|
setSelectedFolder(null);
|
|
291
|
+
loadRoot(val);
|
|
246
292
|
}}
|
|
247
293
|
options={branchList.map((b) => ({ label: b, value: b }))}
|
|
248
294
|
placeholder="Branch"
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
|
|
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, { useEffect, useId } from 'react';
|
|
2
11
|
import { Tabs, Select, Space, Typography, Tag, theme } from 'antd';
|
|
3
12
|
import {
|
|
4
|
-
BranchesOutlined,
|
|
5
13
|
FolderOutlined,
|
|
6
14
|
HistoryOutlined,
|
|
7
15
|
ToolOutlined,
|
|
@@ -19,6 +27,7 @@ import { GitOperations } from './GitOperations';
|
|
|
19
27
|
import { ReviewFlows } from './ReviewFlows';
|
|
20
28
|
import { ReviewHistory } from './ReviewHistory';
|
|
21
29
|
import { PollingStatus } from './PollingStatus';
|
|
30
|
+
import { GitRuntimeBanner } from './GitRuntimeBanner';
|
|
22
31
|
import { useT } from '../locale';
|
|
23
32
|
|
|
24
33
|
const { Text } = Typography;
|
|
@@ -27,14 +36,17 @@ const { useToken } = theme;
|
|
|
27
36
|
const GitManagerContent: React.FC = () => {
|
|
28
37
|
const t = useT();
|
|
29
38
|
const { token } = useToken();
|
|
39
|
+
const repoLabelId = useId();
|
|
40
|
+
const repoSelectId = useId();
|
|
30
41
|
const { repos, selectedRepo, setSelectedRepo, refreshRepos } = useGitManager();
|
|
31
42
|
|
|
32
43
|
useEffect(() => {
|
|
33
44
|
refreshRepos();
|
|
34
|
-
}, []);
|
|
45
|
+
}, [refreshRepos]);
|
|
35
46
|
|
|
36
47
|
return (
|
|
37
48
|
<div style={{ height: '100%' }}>
|
|
49
|
+
<GitRuntimeBanner />
|
|
38
50
|
{/* Repository selector bar */}
|
|
39
51
|
<div
|
|
40
52
|
style={{
|
|
@@ -46,9 +58,13 @@ const GitManagerContent: React.FC = () => {
|
|
|
46
58
|
borderBottom: `1px solid ${token.colorBorderSecondary}`,
|
|
47
59
|
}}
|
|
48
60
|
>
|
|
49
|
-
<DatabaseOutlined style={{ fontSize: 16 }} />
|
|
50
|
-
<
|
|
61
|
+
<DatabaseOutlined aria-hidden="true" style={{ fontSize: 16 }} />
|
|
62
|
+
<label id={repoLabelId} htmlFor={repoSelectId}>
|
|
63
|
+
<Text strong>{t('Repository')}:</Text>
|
|
64
|
+
</label>
|
|
51
65
|
<Select
|
|
66
|
+
id={repoSelectId}
|
|
67
|
+
aria-labelledby={repoLabelId}
|
|
52
68
|
style={{ minWidth: 250 }}
|
|
53
69
|
placeholder={t('Select a repository')}
|
|
54
70
|
value={selectedRepo?.id}
|
|
@@ -1,3 +1,12 @@
|
|
|
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
|
+
|
|
1
10
|
import React, { useState, useCallback, useEffect } from 'react';
|
|
2
11
|
import { Button, Space, Card, Typography, Tag, Empty, message, Spin, Descriptions, List, Badge, theme } from 'antd';
|
|
3
12
|
import {
|
|
@@ -31,13 +40,14 @@ export const GitOperations: React.FC = () => {
|
|
|
31
40
|
const t = useT();
|
|
32
41
|
const { token } = useToken();
|
|
33
42
|
const api = useApp().apiClient;
|
|
34
|
-
const { selectedRepo, refreshRepos } = useGitManager();
|
|
43
|
+
const { selectedRepo, refreshRepos, gitRuntime } = useGitManager();
|
|
44
|
+
const gitAvailable = gitRuntime?.gitAvailable !== false;
|
|
35
45
|
const [actionLoading, setActionLoading] = useState<string | null>(null);
|
|
36
46
|
const [statusData, setStatusData] = useState<any>(null);
|
|
37
47
|
const [lastResult, setLastResult] = useState<{ action: string; success: boolean; message: string } | null>(null);
|
|
38
48
|
|
|
39
49
|
const loadStatus = useCallback(async () => {
|
|
40
|
-
if (!selectedRepo || selectedRepo.status !== 'connected') {
|
|
50
|
+
if (!selectedRepo || selectedRepo.status !== 'connected' || !gitAvailable) {
|
|
41
51
|
setStatusData(null);
|
|
42
52
|
return;
|
|
43
53
|
}
|
|
@@ -56,7 +66,7 @@ export const GitOperations: React.FC = () => {
|
|
|
56
66
|
} finally {
|
|
57
67
|
setActionLoading(null);
|
|
58
68
|
}
|
|
59
|
-
}, [api, selectedRepo]);
|
|
69
|
+
}, [api, selectedRepo, gitAvailable]);
|
|
60
70
|
|
|
61
71
|
useEffect(() => {
|
|
62
72
|
loadStatus();
|
|
@@ -87,7 +97,7 @@ export const GitOperations: React.FC = () => {
|
|
|
87
97
|
setActionLoading(null);
|
|
88
98
|
}
|
|
89
99
|
},
|
|
90
|
-
[api, selectedRepo, refreshRepos, loadStatus],
|
|
100
|
+
[api, selectedRepo, refreshRepos, loadStatus, t],
|
|
91
101
|
);
|
|
92
102
|
|
|
93
103
|
if (!selectedRepo) {
|
|
@@ -96,6 +106,17 @@ export const GitOperations: React.FC = () => {
|
|
|
96
106
|
if (selectedRepo.status !== 'connected') {
|
|
97
107
|
return <Empty description={t('Repository not cloned yet')} />;
|
|
98
108
|
}
|
|
109
|
+
if (!gitAvailable) {
|
|
110
|
+
return (
|
|
111
|
+
<Empty
|
|
112
|
+
description={t(
|
|
113
|
+
gitRuntime?.clusterManager.status === 'running'
|
|
114
|
+
? 'Installing Git via Cluster Manager...'
|
|
115
|
+
: 'Git CLI is not installed on this node yet',
|
|
116
|
+
)}
|
|
117
|
+
/>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
99
120
|
|
|
100
121
|
const allChangedFiles = statusData
|
|
101
122
|
? [
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Alert, Button, Progress, Space, message } from 'antd';
|
|
5
|
+
import { CloudDownloadOutlined, ReloadOutlined } from '@ant-design/icons';
|
|
6
|
+
import { useApp } from '@nocobase/client-v2';
|
|
7
|
+
import { useGitManager } from '../context/GitManagerContext';
|
|
8
|
+
import { useT } from '../locale';
|
|
9
|
+
import { clusterPackageInstallerHref } from '../workflowRoutes';
|
|
10
|
+
|
|
11
|
+
export const GitRuntimeBanner: React.FC = () => {
|
|
12
|
+
const t = useT();
|
|
13
|
+
const app = useApp();
|
|
14
|
+
const { gitRuntime, installingGit, installGitViaCluster, refreshRuntimeStatus } = useGitManager();
|
|
15
|
+
|
|
16
|
+
if (!gitRuntime?.checked || gitRuntime.gitAvailable) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const { clusterManager } = gitRuntime;
|
|
21
|
+
const isInstalling = clusterManager.status === 'running' || installingGit;
|
|
22
|
+
|
|
23
|
+
const handleInstall = async () => {
|
|
24
|
+
const ok = await installGitViaCluster();
|
|
25
|
+
if (ok) {
|
|
26
|
+
message.info(t('Git installation dispatched via Cluster Manager'));
|
|
27
|
+
} else {
|
|
28
|
+
message.error(t('Failed to start Git installation via Cluster Manager'));
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div role="status" aria-live="polite" style={{ marginBottom: 16 }}>
|
|
34
|
+
{isInstalling ? (
|
|
35
|
+
<Alert
|
|
36
|
+
type="info"
|
|
37
|
+
showIcon
|
|
38
|
+
message={t('Installing Git via Cluster Manager...')}
|
|
39
|
+
description={
|
|
40
|
+
<div>
|
|
41
|
+
<div>
|
|
42
|
+
{t(
|
|
43
|
+
'Local Git operations will unlock automatically as soon as Cluster Manager finishes installing git on this node.',
|
|
44
|
+
)}
|
|
45
|
+
</div>
|
|
46
|
+
{clusterManager.progressPercent > 0 && (
|
|
47
|
+
<Progress
|
|
48
|
+
percent={clusterManager.progressPercent}
|
|
49
|
+
size="small"
|
|
50
|
+
style={{ marginTop: 8, maxWidth: 360 }}
|
|
51
|
+
/>
|
|
52
|
+
)}
|
|
53
|
+
</div>
|
|
54
|
+
}
|
|
55
|
+
action={
|
|
56
|
+
<Button size="small" icon={<ReloadOutlined />} onClick={() => refreshRuntimeStatus()}>
|
|
57
|
+
{t('Refresh')}
|
|
58
|
+
</Button>
|
|
59
|
+
}
|
|
60
|
+
/>
|
|
61
|
+
) : (
|
|
62
|
+
<Alert
|
|
63
|
+
type="warning"
|
|
64
|
+
showIcon
|
|
65
|
+
message={t('Git CLI is not installed on this node yet')}
|
|
66
|
+
description={
|
|
67
|
+
clusterManager.available
|
|
68
|
+
? t(
|
|
69
|
+
'Git is managed separately via Cluster Manager. Install git now to enable File Explorer, Commit History, Operations, and Clone.',
|
|
70
|
+
)
|
|
71
|
+
: t('Install git in the app/worker container or set GIT_BINARY_PATH to use local repository features.')
|
|
72
|
+
}
|
|
73
|
+
action={
|
|
74
|
+
clusterManager.available ? (
|
|
75
|
+
<Space wrap>
|
|
76
|
+
<Button
|
|
77
|
+
type="primary"
|
|
78
|
+
size="small"
|
|
79
|
+
icon={<CloudDownloadOutlined />}
|
|
80
|
+
loading={installingGit}
|
|
81
|
+
onClick={handleInstall}
|
|
82
|
+
>
|
|
83
|
+
{t('Install Git via Cluster Manager')}
|
|
84
|
+
</Button>
|
|
85
|
+
<a href={clusterPackageInstallerHref(app)}>{t('Open Cluster Package Installer')}</a>
|
|
86
|
+
</Space>
|
|
87
|
+
) : (
|
|
88
|
+
<Button size="small" icon={<ReloadOutlined />} onClick={() => refreshRuntimeStatus()}>
|
|
89
|
+
{t('Refresh')}
|
|
90
|
+
</Button>
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
/>
|
|
94
|
+
)}
|
|
95
|
+
</div>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
@@ -1,14 +1,27 @@
|
|
|
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
|
+
|
|
1
10
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
11
|
import { Table, Button, Modal, Form, Input, Space, Tag, Popconfirm, Switch, Tooltip, Select, message } from 'antd';
|
|
3
12
|
import { PlusOutlined, DeleteOutlined, LinkOutlined, RobotOutlined } from '@ant-design/icons';
|
|
4
13
|
import { useApp } from '@nocobase/client-v2';
|
|
5
14
|
import { GitManagerProvider, useGitManager } from '../context/GitManagerContext';
|
|
15
|
+
import { GitRuntimeBanner } from './GitRuntimeBanner';
|
|
16
|
+
import { gitManagerManageHref } from '../workflowRoutes';
|
|
6
17
|
import { useT } from '../locale';
|
|
7
18
|
|
|
8
19
|
export const RepositoryConfig: React.FC = () => {
|
|
9
20
|
const t = useT();
|
|
10
|
-
const
|
|
11
|
-
const
|
|
21
|
+
const app = useApp();
|
|
22
|
+
const api = app.apiClient;
|
|
23
|
+
const { repos, refreshRepos, selectedRepo, setSelectedRepo, gitRuntime, refreshRuntimeStatus } = useGitManager();
|
|
24
|
+
const gitAvailable = gitRuntime?.gitAvailable !== false;
|
|
12
25
|
const [modalOpen, setModalOpen] = useState(false);
|
|
13
26
|
const [editingRepo, setEditingRepo] = useState<any>(null);
|
|
14
27
|
const [form] = Form.useForm();
|
|
@@ -98,7 +111,10 @@ export const RepositoryConfig: React.FC = () => {
|
|
|
98
111
|
message.success(t('Clone successful'));
|
|
99
112
|
await refreshRepos();
|
|
100
113
|
} catch (err) {
|
|
101
|
-
|
|
114
|
+
const apiError = (err as { response?: { data?: { errors?: Array<{ message?: string }> } } })?.response?.data
|
|
115
|
+
?.errors?.[0]?.message;
|
|
116
|
+
message.error(apiError || t('Clone failed'));
|
|
117
|
+
refreshRuntimeStatus?.();
|
|
102
118
|
} finally {
|
|
103
119
|
setActionLoading(null);
|
|
104
120
|
}
|
|
@@ -109,7 +125,9 @@ export const RepositoryConfig: React.FC = () => {
|
|
|
109
125
|
title: t('Repository Name'),
|
|
110
126
|
dataIndex: 'name',
|
|
111
127
|
key: 'name',
|
|
112
|
-
render: (text: string, record:
|
|
128
|
+
render: (text: string, record: { id: number; name: string }) => (
|
|
129
|
+
<a href={gitManagerManageHref(app, record.id)}>{text}</a>
|
|
130
|
+
),
|
|
113
131
|
},
|
|
114
132
|
{ title: t('Repository URL'), dataIndex: 'repoUrl', key: 'repoUrl', ellipsis: true },
|
|
115
133
|
{
|
|
@@ -214,12 +232,14 @@ export const RepositoryConfig: React.FC = () => {
|
|
|
214
232
|
title: '',
|
|
215
233
|
key: 'actions',
|
|
216
234
|
width: 200,
|
|
217
|
-
render: (_:
|
|
235
|
+
render: (_: unknown, record: { id: number; name: string; status: string }) => (
|
|
218
236
|
<Space size="small">
|
|
219
237
|
{record.status !== 'connected' && (
|
|
220
238
|
<Button
|
|
221
239
|
size="small"
|
|
222
240
|
icon={<LinkOutlined />}
|
|
241
|
+
disabled={!gitAvailable}
|
|
242
|
+
aria-label={`${t('Clone')} ${record.name}`}
|
|
223
243
|
loading={actionLoading === `clone-${record.id}`}
|
|
224
244
|
onClick={() => handleClone(record)}
|
|
225
245
|
>
|
|
@@ -228,6 +248,7 @@ export const RepositoryConfig: React.FC = () => {
|
|
|
228
248
|
)}
|
|
229
249
|
<Button
|
|
230
250
|
size="small"
|
|
251
|
+
aria-label={`${t('Edit')} ${record.name}`}
|
|
231
252
|
onClick={() => {
|
|
232
253
|
setEditingRepo(record);
|
|
233
254
|
form.setFieldsValue(record);
|
|
@@ -237,7 +258,7 @@ export const RepositoryConfig: React.FC = () => {
|
|
|
237
258
|
{t('Edit')}
|
|
238
259
|
</Button>
|
|
239
260
|
<Popconfirm title={t('Delete this repository?')} onConfirm={() => handleDelete(record.id)}>
|
|
240
|
-
<Button size="small" danger icon={<DeleteOutlined />} />
|
|
261
|
+
<Button size="small" danger icon={<DeleteOutlined />} aria-label={`${t('Delete')} ${record.name}`} />
|
|
241
262
|
</Popconfirm>
|
|
242
263
|
</Space>
|
|
243
264
|
),
|
|
@@ -246,6 +267,7 @@ export const RepositoryConfig: React.FC = () => {
|
|
|
246
267
|
|
|
247
268
|
return (
|
|
248
269
|
<div>
|
|
270
|
+
<GitRuntimeBanner />
|
|
249
271
|
<div style={{ marginBottom: 16 }}>
|
|
250
272
|
<Button
|
|
251
273
|
type="primary"
|