plugin-git-manager 1.2.14 → 1.2.15

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.
Files changed (61) hide show
  1. package/dist/client/156.c27c2392746e7866.js +10 -0
  2. package/dist/client/434.1d19d4d6acc114f1.js +10 -0
  3. package/dist/client/900.ee2fa037aff389e2.js +10 -0
  4. package/dist/client/index.js +1 -1
  5. package/dist/client-v2/356.11ed4f8d56a6c08a.js +10 -0
  6. package/dist/client-v2/434.f8836ea116648de1.js +10 -0
  7. package/dist/client-v2/900.bef1c41d267e50c5.js +10 -0
  8. package/dist/client-v2/index.js +1 -1
  9. package/dist/externalVersion.js +8 -7
  10. package/dist/locale/en-US.json +73 -2
  11. package/dist/locale/vi-VN.json +72 -1
  12. package/dist/locale/zh-CN.json +49 -0
  13. package/dist/server/actions/git-actions.js +31 -15
  14. package/dist/server/actions/gitlab-api.js +46 -20
  15. package/dist/server/actions/review.js +13 -10
  16. package/dist/server/actions/subtree.js +430 -0
  17. package/dist/server/collections/gitAccounts.js +86 -0
  18. package/dist/server/collections/gitRepositories.js +11 -10
  19. package/dist/server/collections/gitSubtreeConfigs.js +67 -0
  20. package/dist/server/collections/gitSubtreeRuns.js +60 -0
  21. package/dist/server/migrations/20260712000000-add-git-accounts.js +186 -0
  22. package/dist/server/plugin.js +76 -12
  23. package/dist/server/poller.js +12 -24
  24. package/dist/server/utils/get-repo-account.js +49 -0
  25. package/package.json +1 -1
  26. package/src/client/components/CommitHistory.tsx +21 -5
  27. package/src/client/components/GitAccounts.tsx +179 -0
  28. package/src/client/components/GitManagerSettings.tsx +10 -6
  29. package/src/client/components/GitOperations.tsx +27 -18
  30. package/src/client/components/LLMModelSelect.tsx +2 -2
  31. package/src/client/components/MarkdownView.tsx +1 -4
  32. package/src/client/components/MergeRequests.tsx +238 -129
  33. package/src/client/components/PollingStatus.tsx +10 -5
  34. package/src/client/components/RepositoryConfig.tsx +32 -14
  35. package/src/client/components/RepositoryPermissions.tsx +1 -8
  36. package/src/client/index.tsx +11 -0
  37. package/src/client-v2/components/SubtreeSplits.tsx +503 -0
  38. package/src/client-v2/locale.ts +8 -0
  39. package/src/client-v2/plugin.tsx +12 -5
  40. package/src/locale/en-US.json +73 -2
  41. package/src/locale/vi-VN.json +72 -1
  42. package/src/locale/zh-CN.json +49 -0
  43. package/src/server/__tests__/smoke.test.ts +1 -1
  44. package/src/server/__tests__/subtree.test.ts +73 -0
  45. package/src/server/actions/git-actions.ts +40 -19
  46. package/src/server/actions/gitlab-api.ts +59 -28
  47. package/src/server/actions/review.ts +13 -10
  48. package/src/server/actions/role-permissions.ts +2 -1
  49. package/src/server/actions/subtree.ts +460 -0
  50. package/src/server/collections/gitAccounts.ts +56 -0
  51. package/src/server/collections/gitRepositories.ts +11 -10
  52. package/src/server/collections/gitSubtreeConfigs.ts +37 -0
  53. package/src/server/collections/gitSubtreeRuns.ts +30 -0
  54. package/src/server/migrations/20260712000000-add-git-accounts.ts +198 -0
  55. package/src/server/plugin.ts +79 -5
  56. package/src/server/poller.ts +31 -32
  57. package/src/server/utils/get-repo-account.ts +23 -0
  58. package/dist/client/434.f82454801cf84906.js +0 -10
  59. package/dist/client/900.ec1fa7f16eb8cce6.js +0 -10
  60. package/dist/client-v2/434.c2f944f911a56da0.js +0 -10
  61. package/dist/client-v2/900.7a5e80bf21feda66.js +0 -10
@@ -0,0 +1,179 @@
1
+ import React, { useCallback, useEffect, useState } from 'react';
2
+ import { Table, Button, Modal, Form, Input, Space, Tag, Popconfirm, Select, message } from 'antd';
3
+ import { PlusOutlined, DeleteOutlined } from '@ant-design/icons';
4
+ import { useApp } from '@nocobase/client-v2';
5
+ import { useT } from '../locale';
6
+
7
+ export const GitAccounts: React.FC = () => {
8
+ const t = useT();
9
+ const api = useApp().apiClient;
10
+ const [accounts, setAccounts] = useState<any[]>([]);
11
+ const [loading, setLoading] = useState(false);
12
+ const [modalOpen, setModalOpen] = useState(false);
13
+ const [editingAccount, setEditingAccount] = useState<any>(null);
14
+ const [form] = Form.useForm();
15
+
16
+ const refreshAccounts = useCallback(async () => {
17
+ setLoading(true);
18
+ try {
19
+ const { data } = await api.request({ url: 'gitAccounts:list', params: { pageSize: 100 } });
20
+ setAccounts(data?.data || []);
21
+ } finally {
22
+ setLoading(false);
23
+ }
24
+ }, [api]);
25
+
26
+ useEffect(() => {
27
+ refreshAccounts().catch(() => undefined);
28
+ }, [refreshAccounts]);
29
+
30
+ const handleSave = async () => {
31
+ const values = await form.validateFields();
32
+ if (editingAccount && (!values.pat || values.pat === '••••••••')) {
33
+ delete values.pat;
34
+ }
35
+ try {
36
+ if (editingAccount) {
37
+ await api.request({
38
+ url: 'gitAccounts:update',
39
+ method: 'post',
40
+ params: { filterByTk: editingAccount.id },
41
+ data: values,
42
+ });
43
+ message.success(t('Account updated'));
44
+ } else {
45
+ await api.request({
46
+ url: 'gitAccounts:create',
47
+ method: 'post',
48
+ data: values,
49
+ });
50
+ message.success(t('Account added'));
51
+ }
52
+ setModalOpen(false);
53
+ setEditingAccount(null);
54
+ form.resetFields();
55
+ await refreshAccounts();
56
+ } catch (err) {
57
+ message.error(err?.message || t('Failed to save'));
58
+ }
59
+ };
60
+
61
+ const handleDelete = async (id: number) => {
62
+ await api.request({ url: 'gitAccounts:destroy', method: 'post', params: { filterByTk: id } });
63
+ message.success(t('Deleted'));
64
+ await refreshAccounts();
65
+ };
66
+
67
+ const columns = [
68
+ {
69
+ title: t('Account Name'),
70
+ dataIndex: 'name',
71
+ key: 'name',
72
+ },
73
+ {
74
+ title: t('Provider'),
75
+ dataIndex: 'provider',
76
+ key: 'provider',
77
+ width: 100,
78
+ render: (provider: string) => (
79
+ <Tag color={provider === 'github' ? 'blue' : 'orange'}>{provider === 'github' ? 'GitHub' : 'GitLab'}</Tag>
80
+ ),
81
+ },
82
+ {
83
+ title: t('Base URL'),
84
+ dataIndex: 'baseUrl',
85
+ key: 'baseUrl',
86
+ ellipsis: true,
87
+ render: (url: string) => url || '-',
88
+ },
89
+ {
90
+ title: t('Username'),
91
+ dataIndex: 'username',
92
+ key: 'username',
93
+ width: 150,
94
+ },
95
+ {
96
+ title: '',
97
+ key: 'actions',
98
+ width: 120,
99
+ render: (_: any, record: any) => (
100
+ <Space size="small">
101
+ <Button
102
+ size="small"
103
+ onClick={() => {
104
+ setEditingAccount(record);
105
+ form.setFieldsValue({ ...record, pat: '' });
106
+ setModalOpen(true);
107
+ }}
108
+ >
109
+ {t('Edit')}
110
+ </Button>
111
+ <Popconfirm title={t('Delete this account?')} onConfirm={() => handleDelete(record.id)}>
112
+ <Button size="small" danger icon={<DeleteOutlined />} />
113
+ </Popconfirm>
114
+ </Space>
115
+ ),
116
+ },
117
+ ];
118
+
119
+ return (
120
+ <div>
121
+ <div style={{ marginBottom: 16 }}>
122
+ <Button
123
+ type="primary"
124
+ icon={<PlusOutlined />}
125
+ onClick={() => {
126
+ setEditingAccount(null);
127
+ form.resetFields();
128
+ setModalOpen(true);
129
+ }}
130
+ >
131
+ {t('Add Account')}
132
+ </Button>
133
+ </div>
134
+
135
+ <Table dataSource={accounts} columns={columns} rowKey="id" size="small" loading={loading} pagination={false} />
136
+
137
+ <Modal
138
+ title={editingAccount ? t('Edit Account') : t('Add Account')}
139
+ open={modalOpen}
140
+ onOk={handleSave}
141
+ onCancel={() => {
142
+ setModalOpen(false);
143
+ setEditingAccount(null);
144
+ }}
145
+ width={480}
146
+ >
147
+ <Form form={form} layout="vertical" initialValues={{ provider: 'gitlab' }}>
148
+ <Form.Item name="name" label={t('Account Name')} rules={[{ required: true }]}>
149
+ <Input placeholder={t('e.g. Company GitLab')} />
150
+ </Form.Item>
151
+ <Form.Item name="provider" label={t('Provider')} rules={[{ required: true }]}>
152
+ <Select
153
+ options={[
154
+ { value: 'gitlab', label: 'GitLab' },
155
+ { value: 'github', label: 'GitHub' },
156
+ ]}
157
+ />
158
+ </Form.Item>
159
+ <Form.Item name="baseUrl" label={t('Base URL')} extra={t('Leave empty for gitlab.com or github.com')}>
160
+ <Input placeholder="https://gitlab.company.com" />
161
+ </Form.Item>
162
+ <Form.Item
163
+ name="username"
164
+ label={t('Username')}
165
+ rules={[{ required: true }]}
166
+ extra={t('GitLab username for PAT authentication')}
167
+ >
168
+ <Input placeholder="gitlab-username" />
169
+ </Form.Item>
170
+ <Form.Item name="pat" label={t('Personal Access Token')} rules={editingAccount ? [] : [{ required: true }]}>
171
+ <Input.Password placeholder={editingAccount ? t('Leave empty to keep current') : 'glpat-xxxx...'} />
172
+ </Form.Item>
173
+ </Form>
174
+ </Modal>
175
+ </div>
176
+ );
177
+ };
178
+
179
+ export const GitAccountsSettings: React.FC = () => <GitAccounts />;
@@ -1,8 +1,15 @@
1
1
  import React, { useEffect } from 'react';
2
2
  import { Tabs, Select, Space, Typography, Tag, theme } from 'antd';
3
3
  import {
4
- BranchesOutlined, FolderOutlined, HistoryOutlined, ToolOutlined, DatabaseOutlined, MergeOutlined,
5
- RobotOutlined, AuditOutlined, ClockCircleOutlined,
4
+ BranchesOutlined,
5
+ FolderOutlined,
6
+ HistoryOutlined,
7
+ ToolOutlined,
8
+ DatabaseOutlined,
9
+ MergeOutlined,
10
+ RobotOutlined,
11
+ AuditOutlined,
12
+ ClockCircleOutlined,
6
13
  } from '@ant-design/icons';
7
14
  import { GitManagerProvider, useGitManager } from '../context/GitManagerContext';
8
15
  import { FileExplorer } from './FileExplorer';
@@ -53,10 +60,7 @@ const GitManagerContent: React.FC = () => {
53
60
  label: (
54
61
  <Space>
55
62
  {r.name}
56
- <Tag
57
- color={r.status === 'connected' ? 'green' : 'default'}
58
- style={{ fontSize: 11 }}
59
- >
63
+ <Tag color={r.status === 'connected' ? 'green' : 'default'} style={{ fontSize: 11 }}>
60
64
  {r.status === 'connected' ? t('Connected') : t('Disconnected')}
61
65
  </Tag>
62
66
  </Space>
@@ -99,12 +99,12 @@ export const GitOperations: React.FC = () => {
99
99
 
100
100
  const allChangedFiles = statusData
101
101
  ? [
102
- ...statusData.not_added?.map((f: string) => ({ file: f, status: 'not_added' })) || [],
103
- ...statusData.modified?.map((f: string) => ({ file: f, status: 'modified' })) || [],
104
- ...statusData.deleted?.map((f: string) => ({ file: f, status: 'deleted' })) || [],
105
- ...statusData.renamed?.map((f: any) => ({ file: typeof f === 'string' ? f : f.to, status: 'renamed' })) || [],
106
- ...statusData.conflicted?.map((f: string) => ({ file: f, status: 'conflicted' })) || [],
107
- ...statusData.created?.map((f: string) => ({ file: f, status: 'created' })) || [],
102
+ ...(statusData.not_added?.map((f: string) => ({ file: f, status: 'not_added' })) || []),
103
+ ...(statusData.modified?.map((f: string) => ({ file: f, status: 'modified' })) || []),
104
+ ...(statusData.deleted?.map((f: string) => ({ file: f, status: 'deleted' })) || []),
105
+ ...(statusData.renamed?.map((f: any) => ({ file: typeof f === 'string' ? f : f.to, status: 'renamed' })) || []),
106
+ ...(statusData.conflicted?.map((f: string) => ({ file: f, status: 'conflicted' })) || []),
107
+ ...(statusData.created?.map((f: string) => ({ file: f, status: 'created' })) || []),
108
108
  ]
109
109
  : [];
110
110
 
@@ -128,12 +128,7 @@ export const GitOperations: React.FC = () => {
128
128
  >
129
129
  {t('Pull')}
130
130
  </Button>
131
- <Button
132
- size="large"
133
- icon={<BranchesOutlined />}
134
- loading={actionLoading === 'status'}
135
- onClick={loadStatus}
136
- >
131
+ <Button size="large" icon={<BranchesOutlined />} loading={actionLoading === 'status'} onClick={loadStatus}>
137
132
  {t('Status')}
138
133
  </Button>
139
134
  </Space>
@@ -162,17 +157,25 @@ export const GitOperations: React.FC = () => {
162
157
  <Card title={t('Working Directory Status')} size="small">
163
158
  <Descriptions column={3} size="small" style={{ marginBottom: 16 }}>
164
159
  <Descriptions.Item label="Branch">
165
- <Tag icon={<BranchesOutlined />} color="blue">{statusData.current}</Tag>
160
+ <Tag icon={<BranchesOutlined />} color="blue">
161
+ {statusData.current}
162
+ </Tag>
166
163
  </Descriptions.Item>
167
164
  <Descriptions.Item label="Tracking">
168
165
  <Text>{statusData.tracking || 'N/A'}</Text>
169
166
  </Descriptions.Item>
170
167
  <Descriptions.Item label="Changes">
171
168
  <Space>
172
- {statusData.ahead > 0 && <Badge count={`${statusData.ahead} ahead`} style={{ backgroundColor: token.colorPrimary }} />}
173
- {statusData.behind > 0 && <Badge count={`${statusData.behind} behind`} style={{ backgroundColor: token.colorWarning }} />}
169
+ {statusData.ahead > 0 && (
170
+ <Badge count={`${statusData.ahead} ahead`} style={{ backgroundColor: token.colorPrimary }} />
171
+ )}
172
+ {statusData.behind > 0 && (
173
+ <Badge count={`${statusData.behind} behind`} style={{ backgroundColor: token.colorWarning }} />
174
+ )}
174
175
  {statusData.ahead === 0 && statusData.behind === 0 && (
175
- <Tag color="green" icon={<CheckCircleOutlined />}>Up to date</Tag>
176
+ <Tag color="green" icon={<CheckCircleOutlined />}>
177
+ Up to date
178
+ </Tag>
176
179
  )}
177
180
  </Space>
178
181
  </Descriptions.Item>
@@ -187,14 +190,20 @@ export const GitOperations: React.FC = () => {
187
190
  size="small"
188
191
  dataSource={allChangedFiles}
189
192
  renderItem={(item: any) => {
190
- const info = FILE_STATUS_MAP[item.status] || { color: 'default', icon: <QuestionCircleOutlined />, label: item.status };
193
+ const info = FILE_STATUS_MAP[item.status] || {
194
+ color: 'default',
195
+ icon: <QuestionCircleOutlined />,
196
+ label: item.status,
197
+ };
191
198
  return (
192
199
  <List.Item style={{ padding: '4px 0' }}>
193
200
  <Space>
194
201
  <Tag color={info.color} style={{ minWidth: 80, textAlign: 'center' }}>
195
202
  {info.icon} {info.label}
196
203
  </Tag>
197
- <Text code style={{ fontSize: 13 }}>{item.file}</Text>
204
+ <Text code style={{ fontSize: 13 }}>
205
+ {item.file}
206
+ </Text>
198
207
  </Space>
199
208
  </List.Item>
200
209
  );
@@ -21,7 +21,7 @@ export const LLMModelSelect: React.FC<{
21
21
  setModels([]);
22
22
  return;
23
23
  }
24
-
24
+
25
25
  setLoading(true);
26
26
  api
27
27
  .request({ url: 'ai:listModels', params: { llmService } })
@@ -36,7 +36,7 @@ export const LLMModelSelect: React.FC<{
36
36
  .finally(() => {
37
37
  if (!cancelled) setLoading(false);
38
38
  });
39
-
39
+
40
40
  return () => {
41
41
  cancelled = true;
42
42
  };
@@ -9,10 +9,7 @@ const { useToken } = theme;
9
9
  * We avoid the full plugin-field-markdown-vditor `Display` component because
10
10
  * it is tightly coupled to formily field context.
11
11
  */
12
- export const MarkdownView: React.FC<{ content?: string; maxHeight?: number | string }> = ({
13
- content,
14
- maxHeight,
15
- }) => {
12
+ export const MarkdownView: React.FC<{ content?: string; maxHeight?: number | string }> = ({ content, maxHeight }) => {
16
13
  const { token } = useToken();
17
14
  if (!content) return null;
18
15
  return (