plugin-git-manager 1.0.3
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/client.d.ts +3 -0
- package/client.js +1 -0
- package/dist/client/100.e08d760e0b01997c.js +10 -0
- package/dist/client/components/CommitHistory.d.ts +2 -0
- package/dist/client/components/FileExplorer.d.ts +2 -0
- package/dist/client/components/GitManagerSettings.d.ts +2 -0
- package/dist/client/components/GitOperations.d.ts +2 -0
- package/dist/client/components/RepositoryConfig.d.ts +2 -0
- package/dist/client/context/GitManagerContext.d.ts +24 -0
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.js +10 -0
- package/dist/client/locale.d.ts +2 -0
- package/dist/externalVersion.js +18 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +48 -0
- package/dist/locale/en-US.json +45 -0
- package/dist/locale/vi-VN.json +45 -0
- package/dist/node_modules/simple-git/dist/cjs/index.js +7399 -0
- package/dist/node_modules/simple-git/dist/esm/index.js +4745 -0
- package/dist/node_modules/simple-git/dist/esm/package.json +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/api.d.ts +13 -0
- package/dist/node_modules/simple-git/dist/src/lib/args/log-format.d.ts +9 -0
- package/dist/node_modules/simple-git/dist/src/lib/errors/git-construct-error.d.ts +15 -0
- package/dist/node_modules/simple-git/dist/src/lib/errors/git-error.d.ts +30 -0
- package/dist/node_modules/simple-git/dist/src/lib/errors/git-plugin-error.d.ts +7 -0
- package/dist/node_modules/simple-git/dist/src/lib/errors/git-response-error.d.ts +32 -0
- package/dist/node_modules/simple-git/dist/src/lib/errors/task-configuration-error.d.ts +12 -0
- package/dist/node_modules/simple-git/dist/src/lib/git-factory.d.ts +15 -0
- package/dist/node_modules/simple-git/dist/src/lib/git-logger.d.ts +21 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-branch-delete.d.ts +5 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-branch.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-commit.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-diff-summary.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-fetch.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-list-log-summary.d.ts +6 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-merge.d.ts +11 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-move.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-pull.d.ts +6 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-push.d.ts +4 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-remote-messages.d.ts +5 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-remote-objects.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/abort-plugin.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/block-unsafe-operations-plugin.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/command-config-prefixing-plugin.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/completion-detection.plugin.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/custom-binary.plugin.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/error-detection.plugin.d.ts +7 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/index.d.ts +11 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/plugin-store.d.ts +11 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/progress-monitor-plugin.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/simple-git-plugin.d.ts +48 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/spawn-options-plugin.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/suffix-paths.plugin.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/timout-plugin.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/BranchDeleteSummary.d.ts +12 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/BranchSummary.d.ts +14 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/CheckIgnore.d.ts +4 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/CleanSummary.d.ts +9 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/ConfigList.d.ts +13 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/DiffSummary.d.ts +10 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/FileStatusSummary.d.ts +9 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/GetRemoteSummary.d.ts +11 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/InitSummary.d.ts +9 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/MergeSummary.d.ts +16 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/PullSummary.d.ts +25 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/StatusSummary.d.ts +19 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/TagList.d.ts +7 -0
- package/dist/node_modules/simple-git/dist/src/lib/runners/git-executor-chain.d.ts +25 -0
- package/dist/node_modules/simple-git/dist/src/lib/runners/git-executor.d.ts +14 -0
- package/dist/node_modules/simple-git/dist/src/lib/runners/promise-wrapped.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/runners/scheduler.d.ts +11 -0
- package/dist/node_modules/simple-git/dist/src/lib/runners/tasks-pending-queue.d.ts +23 -0
- package/dist/node_modules/simple-git/dist/src/lib/simple-git-api.d.ts +20 -0
- package/dist/node_modules/simple-git/dist/src/lib/task-callback.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/apply-patch.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/branch.d.ts +7 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/change-working-directory.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/check-ignore.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/check-is-repo.d.ts +9 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/checkout.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/clean.d.ts +25 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/clone.d.ts +9 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/commit.d.ts +4 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/config.d.ts +8 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/count-objects.d.ts +12 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/diff-name-status.d.ts +12 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/diff.d.ts +5 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/fetch.d.ts +4 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/first-commit.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/grep.d.ts +12 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/hash-object.d.ts +5 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/init.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/log.d.ts +32 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/merge.d.ts +4 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/move.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/pull.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/push.d.ts +9 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/remote.d.ts +8 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/reset.d.ts +11 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/show.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/stash-list.d.ts +4 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/status.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/sub-module.d.ts +5 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/tag.d.ts +18 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/task.d.ts +14 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/version.d.ts +9 -0
- package/dist/node_modules/simple-git/dist/src/lib/types/handlers.d.ts +21 -0
- package/dist/node_modules/simple-git/dist/src/lib/types/index.d.ts +136 -0
- package/dist/node_modules/simple-git/dist/src/lib/types/tasks.d.ts +19 -0
- package/dist/node_modules/simple-git/dist/src/lib/utils/argument-filters.d.ts +14 -0
- package/dist/node_modules/simple-git/dist/src/lib/utils/exit-codes.d.ts +10 -0
- package/dist/node_modules/simple-git/dist/src/lib/utils/git-output-streams.d.ts +7 -0
- package/dist/node_modules/simple-git/dist/src/lib/utils/index.d.ts +8 -0
- package/dist/node_modules/simple-git/dist/src/lib/utils/line-parser.d.ts +15 -0
- package/dist/node_modules/simple-git/dist/src/lib/utils/simple-git-options.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/utils/task-options.d.ts +13 -0
- package/dist/node_modules/simple-git/dist/src/lib/utils/task-parser.d.ts +5 -0
- package/dist/node_modules/simple-git/dist/src/lib/utils/util.d.ts +47 -0
- package/dist/node_modules/simple-git/dist/typings/errors.d.ts +5 -0
- package/dist/node_modules/simple-git/dist/typings/index.d.ts +14 -0
- package/dist/node_modules/simple-git/dist/typings/response.d.ts +556 -0
- package/dist/node_modules/simple-git/dist/typings/simple-git.d.ts +1033 -0
- package/dist/node_modules/simple-git/dist/typings/types.d.ts +22 -0
- package/dist/node_modules/simple-git/node_modules/debug/package.json +64 -0
- package/dist/node_modules/simple-git/node_modules/debug/src/browser.js +272 -0
- package/dist/node_modules/simple-git/node_modules/debug/src/common.js +292 -0
- package/dist/node_modules/simple-git/node_modules/debug/src/index.js +10 -0
- package/dist/node_modules/simple-git/node_modules/debug/src/node.js +263 -0
- package/dist/node_modules/simple-git/package.json +1 -0
- package/dist/node_modules/simple-git/promise.js +17 -0
- package/dist/server/actions/git-actions.d.ts +13 -0
- package/dist/server/actions/git-actions.js +354 -0
- package/dist/server/collections/gitRepositories.d.ts +2 -0
- package/dist/server/collections/gitRepositories.js +75 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +48 -0
- package/dist/server/plugin.d.ts +6 -0
- package/dist/server/plugin.js +120 -0
- package/package.json +32 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
- package/src/client/components/CommitHistory.tsx +326 -0
- package/src/client/components/FileExplorer.tsx +329 -0
- package/src/client/components/GitManagerSettings.tsx +123 -0
- package/src/client/components/GitOperations.tsx +195 -0
- package/src/client/components/RepositoryConfig.tsx +188 -0
- package/src/client/context/GitManagerContext.tsx +84 -0
- package/src/client/index.tsx +19 -0
- package/src/client/locale.ts +9 -0
- package/src/index.ts +2 -0
- package/src/locale/en-US.json +45 -0
- package/src/locale/vi-VN.json +45 -0
- package/src/server/actions/git-actions.ts +346 -0
- package/src/server/collections/gitRepositories.ts +45 -0
- package/src/server/index.ts +2 -0
- package/src/server/plugin.ts +81 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Table, Button, Modal, Form, Input, Space, Tag, Popconfirm, message } from 'antd';
|
|
3
|
+
import { PlusOutlined, DeleteOutlined, LinkOutlined } from '@ant-design/icons';
|
|
4
|
+
import { useAPIClient } from '@nocobase/client';
|
|
5
|
+
import { useGitManager } from '../context/GitManagerContext';
|
|
6
|
+
import { useT } from '../locale';
|
|
7
|
+
|
|
8
|
+
export const RepositoryConfig: React.FC = () => {
|
|
9
|
+
const t = useT();
|
|
10
|
+
const api = useAPIClient();
|
|
11
|
+
const { repos, refreshRepos, selectedRepo, setSelectedRepo } = useGitManager();
|
|
12
|
+
const [modalOpen, setModalOpen] = useState(false);
|
|
13
|
+
const [editingRepo, setEditingRepo] = useState<any>(null);
|
|
14
|
+
const [form] = Form.useForm();
|
|
15
|
+
const [actionLoading, setActionLoading] = useState<string | null>(null);
|
|
16
|
+
|
|
17
|
+
const handleSave = async () => {
|
|
18
|
+
const values = await form.validateFields();
|
|
19
|
+
// Don't send PAT if it's empty or the masked placeholder
|
|
20
|
+
if (editingRepo && (!values.pat || values.pat === '••••••••')) {
|
|
21
|
+
delete values.pat;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
if (editingRepo) {
|
|
25
|
+
await api.request({
|
|
26
|
+
url: 'gitRepositories:update',
|
|
27
|
+
method: 'post',
|
|
28
|
+
params: { filterByTk: editingRepo.id },
|
|
29
|
+
data: values,
|
|
30
|
+
});
|
|
31
|
+
message.success(t('Repository updated'));
|
|
32
|
+
} else {
|
|
33
|
+
await api.request({
|
|
34
|
+
url: 'gitRepositories:create',
|
|
35
|
+
method: 'post',
|
|
36
|
+
data: values,
|
|
37
|
+
});
|
|
38
|
+
message.success(t('Repository added'));
|
|
39
|
+
}
|
|
40
|
+
setModalOpen(false);
|
|
41
|
+
setEditingRepo(null);
|
|
42
|
+
form.resetFields();
|
|
43
|
+
await refreshRepos();
|
|
44
|
+
} catch (err) {
|
|
45
|
+
message.error(err?.message || t('Failed to save'));
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const handleDelete = async (id: number) => {
|
|
50
|
+
await api.request({ url: 'gitRepositories:destroy', method: 'post', params: { filterByTk: id } });
|
|
51
|
+
if (selectedRepo?.id === id) setSelectedRepo(null);
|
|
52
|
+
message.success(t('Deleted'));
|
|
53
|
+
await refreshRepos();
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const handleClone = async (repo: any) => {
|
|
57
|
+
setActionLoading(`clone-${repo.id}`);
|
|
58
|
+
try {
|
|
59
|
+
await api.request({
|
|
60
|
+
url: 'gitManager:clone',
|
|
61
|
+
method: 'post',
|
|
62
|
+
params: { repositoryId: repo.id },
|
|
63
|
+
});
|
|
64
|
+
message.success(t('Clone successful'));
|
|
65
|
+
await refreshRepos();
|
|
66
|
+
} catch (err) {
|
|
67
|
+
message.error(err?.response?.data?.errors?.[0]?.message || t('Clone failed'));
|
|
68
|
+
} finally {
|
|
69
|
+
setActionLoading(null);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const columns = [
|
|
74
|
+
{
|
|
75
|
+
title: t('Repository Name'),
|
|
76
|
+
dataIndex: 'name',
|
|
77
|
+
key: 'name',
|
|
78
|
+
render: (text: string, record: any) => (
|
|
79
|
+
<a onClick={() => setSelectedRepo(record)}>{text}</a>
|
|
80
|
+
),
|
|
81
|
+
},
|
|
82
|
+
{ title: t('Repository URL'), dataIndex: 'repoUrl', key: 'repoUrl', ellipsis: true },
|
|
83
|
+
{ title: t('Local Path'), dataIndex: 'localPath', key: 'localPath', ellipsis: true },
|
|
84
|
+
{ title: t('Default Branch'), dataIndex: 'defaultBranch', key: 'defaultBranch', width: 120 },
|
|
85
|
+
{
|
|
86
|
+
title: t('Status'),
|
|
87
|
+
dataIndex: 'status',
|
|
88
|
+
key: 'status',
|
|
89
|
+
width: 120,
|
|
90
|
+
render: (status: string) => {
|
|
91
|
+
const statusMap: Record<string, { color: string; label: string }> = {
|
|
92
|
+
connected: { color: 'green', label: t('Connected') },
|
|
93
|
+
error: { color: 'red', label: t('Error') },
|
|
94
|
+
};
|
|
95
|
+
const info = statusMap[status] || { color: 'default', label: t('Disconnected') };
|
|
96
|
+
return <Tag color={info.color}>{info.label}</Tag>;
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
title: '',
|
|
101
|
+
key: 'actions',
|
|
102
|
+
width: 200,
|
|
103
|
+
render: (_: any, record: any) => (
|
|
104
|
+
<Space size="small">
|
|
105
|
+
{record.status !== 'connected' && (
|
|
106
|
+
<Button
|
|
107
|
+
size="small"
|
|
108
|
+
icon={<LinkOutlined />}
|
|
109
|
+
loading={actionLoading === `clone-${record.id}`}
|
|
110
|
+
onClick={() => handleClone(record)}
|
|
111
|
+
>
|
|
112
|
+
{t('Clone')}
|
|
113
|
+
</Button>
|
|
114
|
+
)}
|
|
115
|
+
<Button
|
|
116
|
+
size="small"
|
|
117
|
+
onClick={() => {
|
|
118
|
+
setEditingRepo(record);
|
|
119
|
+
form.setFieldsValue({ ...record, pat: '' });
|
|
120
|
+
setModalOpen(true);
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
{t('Edit')}
|
|
124
|
+
</Button>
|
|
125
|
+
<Popconfirm title={t('Delete this repository?')} onConfirm={() => handleDelete(record.id)}>
|
|
126
|
+
<Button size="small" danger icon={<DeleteOutlined />} />
|
|
127
|
+
</Popconfirm>
|
|
128
|
+
</Space>
|
|
129
|
+
),
|
|
130
|
+
},
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<div>
|
|
135
|
+
<div style={{ marginBottom: 16 }}>
|
|
136
|
+
<Button
|
|
137
|
+
type="primary"
|
|
138
|
+
icon={<PlusOutlined />}
|
|
139
|
+
onClick={() => {
|
|
140
|
+
setEditingRepo(null);
|
|
141
|
+
form.resetFields();
|
|
142
|
+
setModalOpen(true);
|
|
143
|
+
}}
|
|
144
|
+
>
|
|
145
|
+
{t('Add Repository')}
|
|
146
|
+
</Button>
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
<Table
|
|
150
|
+
dataSource={repos}
|
|
151
|
+
columns={columns}
|
|
152
|
+
rowKey="id"
|
|
153
|
+
size="small"
|
|
154
|
+
pagination={false}
|
|
155
|
+
rowClassName={(record) => (selectedRepo?.id === record.id ? 'ant-table-row-selected' : '')}
|
|
156
|
+
/>
|
|
157
|
+
|
|
158
|
+
<Modal
|
|
159
|
+
title={editingRepo ? t('Edit Repository') : t('Add Repository')}
|
|
160
|
+
open={modalOpen}
|
|
161
|
+
onOk={handleSave}
|
|
162
|
+
onCancel={() => {
|
|
163
|
+
setModalOpen(false);
|
|
164
|
+
setEditingRepo(null);
|
|
165
|
+
}}
|
|
166
|
+
width={520}
|
|
167
|
+
>
|
|
168
|
+
<Form form={form} layout="vertical" initialValues={{ defaultBranch: 'main' }}>
|
|
169
|
+
<Form.Item name="name" label={t('Repository Name')} rules={[{ required: true }]}>
|
|
170
|
+
<Input placeholder="my-project" />
|
|
171
|
+
</Form.Item>
|
|
172
|
+
<Form.Item name="repoUrl" label={t('Repository URL')} rules={[{ required: true }]}>
|
|
173
|
+
<Input placeholder="https://github.com/user/repo.git" />
|
|
174
|
+
</Form.Item>
|
|
175
|
+
<Form.Item name="localPath" label={t('Local Path')} rules={[{ required: true }]}>
|
|
176
|
+
<Input placeholder="my-project" />
|
|
177
|
+
</Form.Item>
|
|
178
|
+
<Form.Item name="pat" label={t('Personal Access Token')} rules={editingRepo ? [] : [{ required: true }]}>
|
|
179
|
+
<Input.Password placeholder={editingRepo ? 'Leave empty to keep current' : 'ghp_xxxx...'} />
|
|
180
|
+
</Form.Item>
|
|
181
|
+
<Form.Item name="defaultBranch" label={t('Default Branch')}>
|
|
182
|
+
<Input placeholder="main" />
|
|
183
|
+
</Form.Item>
|
|
184
|
+
</Form>
|
|
185
|
+
</Modal>
|
|
186
|
+
</div>
|
|
187
|
+
);
|
|
188
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React, { createContext, useContext, useState, useCallback, useRef } from 'react';
|
|
2
|
+
import { useAPIClient } from '@nocobase/client';
|
|
3
|
+
|
|
4
|
+
interface Repository {
|
|
5
|
+
id: number;
|
|
6
|
+
name: string;
|
|
7
|
+
repoUrl: string;
|
|
8
|
+
localPath: string;
|
|
9
|
+
defaultBranch: string;
|
|
10
|
+
status: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface GitManagerContextType {
|
|
14
|
+
repos: Repository[];
|
|
15
|
+
selectedRepo: Repository | null;
|
|
16
|
+
loading: boolean;
|
|
17
|
+
branches: string[];
|
|
18
|
+
currentBranch: string;
|
|
19
|
+
setSelectedRepo: (repo: Repository | null) => void;
|
|
20
|
+
refreshRepos: () => Promise<void>;
|
|
21
|
+
refreshBranches: () => Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const GitManagerContext = createContext<GitManagerContextType>(null);
|
|
25
|
+
|
|
26
|
+
export function useGitManager() {
|
|
27
|
+
return useContext(GitManagerContext);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const GitManagerProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
|
31
|
+
const api = useAPIClient();
|
|
32
|
+
const [repos, setRepos] = useState<Repository[]>([]);
|
|
33
|
+
const [selectedRepo, setSelectedRepo] = useState<Repository | null>(null);
|
|
34
|
+
const [loading, setLoading] = useState(false);
|
|
35
|
+
const [branches, setBranches] = useState<string[]>([]);
|
|
36
|
+
const [currentBranch, setCurrentBranch] = useState('');
|
|
37
|
+
const selectedRepoRef = useRef(selectedRepo);
|
|
38
|
+
selectedRepoRef.current = selectedRepo;
|
|
39
|
+
|
|
40
|
+
const refreshBranches = useCallback(async () => {
|
|
41
|
+
const repo = selectedRepoRef.current;
|
|
42
|
+
if (!repo || repo.status !== 'connected') {
|
|
43
|
+
setBranches([]);
|
|
44
|
+
setCurrentBranch('');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const { data } = await api.request({
|
|
49
|
+
url: 'gitManager:branches',
|
|
50
|
+
params: { repositoryId: repo.id },
|
|
51
|
+
});
|
|
52
|
+
const responseData = data?.data?.data || data?.data;
|
|
53
|
+
if (responseData) {
|
|
54
|
+
setBranches(responseData.all || []);
|
|
55
|
+
setCurrentBranch(responseData.current || '');
|
|
56
|
+
}
|
|
57
|
+
} catch {
|
|
58
|
+
setBranches([]);
|
|
59
|
+
setCurrentBranch('');
|
|
60
|
+
}
|
|
61
|
+
}, [api]);
|
|
62
|
+
|
|
63
|
+
const refreshRepos = useCallback(async () => {
|
|
64
|
+
setLoading(true);
|
|
65
|
+
try {
|
|
66
|
+
const { data } = await api.request({ url: 'gitRepositories:list', params: { pageSize: 100 } });
|
|
67
|
+
const list = data?.data || [];
|
|
68
|
+
setRepos(list);
|
|
69
|
+
const current = selectedRepoRef.current;
|
|
70
|
+
if (current) {
|
|
71
|
+
const updated = list.find((r: Repository) => r.id === current.id);
|
|
72
|
+
if (updated) setSelectedRepo(updated);
|
|
73
|
+
}
|
|
74
|
+
} finally {
|
|
75
|
+
setLoading(false);
|
|
76
|
+
}
|
|
77
|
+
}, [api]);
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<GitManagerContext.Provider value={{ repos, selectedRepo, loading, branches, currentBranch, setSelectedRepo, refreshRepos, refreshBranches }}>
|
|
81
|
+
{children}
|
|
82
|
+
</GitManagerContext.Provider>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Plugin } from '@nocobase/client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const GitManagerSettings = React.lazy(() =>
|
|
5
|
+
import('./components/GitManagerSettings').then((m) => ({ default: m.GitManagerSettings })),
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
export class PluginGitManagerClient extends Plugin {
|
|
9
|
+
async load() {
|
|
10
|
+
this.app.pluginSettingsManager.add('git-manager', {
|
|
11
|
+
title: this.t('Git Manager'),
|
|
12
|
+
icon: 'BranchesOutlined',
|
|
13
|
+
Component: GitManagerSettings,
|
|
14
|
+
aclSnippet: 'pm.plugin-git-manager',
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default PluginGitManagerClient;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useApp } from '@nocobase/client';
|
|
2
|
+
|
|
3
|
+
export const namespace = 'plugin-git-manager';
|
|
4
|
+
|
|
5
|
+
export function useT() {
|
|
6
|
+
const app = useApp();
|
|
7
|
+
return (str: string, options?: any): string =>
|
|
8
|
+
app.i18n.t(str, { ns: [namespace, 'client'], ...options }) as unknown as string;
|
|
9
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Git Manager": "Git Manager",
|
|
3
|
+
"Repositories": "Repositories",
|
|
4
|
+
"File Explorer": "File Explorer",
|
|
5
|
+
"History": "History",
|
|
6
|
+
"Operations": "Operations",
|
|
7
|
+
"Repository Name": "Repository Name",
|
|
8
|
+
"Repository URL": "Repository URL",
|
|
9
|
+
"Local Path": "Local Path",
|
|
10
|
+
"Personal Access Token": "Personal Access Token",
|
|
11
|
+
"Default Branch": "Default Branch",
|
|
12
|
+
"Add Repository": "Add Repository",
|
|
13
|
+
"Edit Repository": "Edit Repository",
|
|
14
|
+
"Clone": "Clone",
|
|
15
|
+
"Pull": "Pull",
|
|
16
|
+
"Push": "Push",
|
|
17
|
+
"Fetch": "Fetch",
|
|
18
|
+
"Status": "Status",
|
|
19
|
+
"Commit": "Commit",
|
|
20
|
+
"Author": "Author",
|
|
21
|
+
"Date": "Date",
|
|
22
|
+
"Message": "Message",
|
|
23
|
+
"Files Changed": "Files Changed",
|
|
24
|
+
"No repository selected": "No repository selected",
|
|
25
|
+
"Select a repository": "Select a repository",
|
|
26
|
+
"Connected": "Connected",
|
|
27
|
+
"Disconnected": "Disconnected",
|
|
28
|
+
"Error": "Error",
|
|
29
|
+
"Loading...": "Loading...",
|
|
30
|
+
"View Diff": "View Diff",
|
|
31
|
+
"File Content": "File Content",
|
|
32
|
+
"Edit": "Edit",
|
|
33
|
+
"Deleted": "Deleted",
|
|
34
|
+
"Repository updated": "Repository updated",
|
|
35
|
+
"Repository added": "Repository added",
|
|
36
|
+
"Failed to save": "Failed to save",
|
|
37
|
+
"Clone successful": "Clone successful",
|
|
38
|
+
"Clone failed": "Clone failed",
|
|
39
|
+
"Delete this repository?": "Delete this repository?",
|
|
40
|
+
"Repository not cloned yet": "Repository not cloned yet",
|
|
41
|
+
"Working Directory Status": "Working Directory Status",
|
|
42
|
+
"{{action}} completed successfully": "{{action}} completed successfully",
|
|
43
|
+
"{{action}} completed": "{{action}} completed",
|
|
44
|
+
"{{action}} failed": "{{action}} failed"
|
|
45
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Git Manager": "Quản lý Git",
|
|
3
|
+
"Repositories": "Kho mã nguồn",
|
|
4
|
+
"File Explorer": "Trình duyệt tệp",
|
|
5
|
+
"History": "Lịch sử",
|
|
6
|
+
"Operations": "Thao tác",
|
|
7
|
+
"Repository Name": "Tên kho",
|
|
8
|
+
"Repository URL": "URL kho",
|
|
9
|
+
"Local Path": "Đường dẫn cục bộ",
|
|
10
|
+
"Personal Access Token": "Mã truy cập cá nhân",
|
|
11
|
+
"Default Branch": "Nhánh mặc định",
|
|
12
|
+
"Add Repository": "Thêm kho",
|
|
13
|
+
"Edit Repository": "Sửa kho",
|
|
14
|
+
"Clone": "Sao chép",
|
|
15
|
+
"Pull": "Kéo về",
|
|
16
|
+
"Push": "Đẩy lên",
|
|
17
|
+
"Fetch": "Lấy về",
|
|
18
|
+
"Status": "Trạng thái",
|
|
19
|
+
"Commit": "Commit",
|
|
20
|
+
"Author": "Tác giả",
|
|
21
|
+
"Date": "Ngày",
|
|
22
|
+
"Message": "Tin nhắn",
|
|
23
|
+
"Files Changed": "Tệp thay đổi",
|
|
24
|
+
"No repository selected": "Chưa chọn kho mã nguồn",
|
|
25
|
+
"Select a repository": "Chọn một kho mã nguồn",
|
|
26
|
+
"Connected": "Đã kết nối",
|
|
27
|
+
"Disconnected": "Chưa kết nối",
|
|
28
|
+
"Error": "Lỗi",
|
|
29
|
+
"Loading...": "Đang tải...",
|
|
30
|
+
"View Diff": "Xem khác biệt",
|
|
31
|
+
"File Content": "Nội dung tệp",
|
|
32
|
+
"Edit": "Sửa",
|
|
33
|
+
"Deleted": "Đã xóa",
|
|
34
|
+
"Repository updated": "Đã cập nhật kho",
|
|
35
|
+
"Repository added": "Đã thêm kho",
|
|
36
|
+
"Failed to save": "Lưu thất bại",
|
|
37
|
+
"Clone successful": "Sao chép thành công",
|
|
38
|
+
"Clone failed": "Sao chép thất bại",
|
|
39
|
+
"Delete this repository?": "Xóa kho này?",
|
|
40
|
+
"Repository not cloned yet": "Kho chưa được sao chép",
|
|
41
|
+
"Working Directory Status": "Trạng thái thư mục làm việc",
|
|
42
|
+
"{{action}} completed successfully": "{{action}} hoàn tất thành công",
|
|
43
|
+
"{{action}} completed": "{{action}} hoàn tất",
|
|
44
|
+
"{{action}} failed": "{{action}} thất bại"
|
|
45
|
+
}
|