plugin-git-manager 1.2.9 → 1.2.11
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/434.f82454801cf84906.js +10 -0
- package/dist/client/{878.d35dadb55d23e652.js → 878.3e7b8b27c157996c.js} +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client-v2/434.c2f944f911a56da0.js +10 -0
- package/dist/client-v2/{878.44427151f696954b.js → 878.295f09c9d77ea6d8.js} +1 -1
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +7 -7
- package/dist/server/actions/review.js +11 -10
- package/package.json +1 -1
- package/src/client/components/RepositoryConfig.tsx +25 -7
- package/src/client/context/GitManagerContext.tsx +9 -3
- package/src/client/index.tsx +61 -65
- package/src/server/actions/review.ts +1222 -1221
- package/dist/client/434.cd3129f40e8c3e7c.js +0 -10
- package/dist/client-v2/434.5bd7d0a433eaf499.js +0 -10
package/dist/client-v2/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/plugin-ai/client")):"function"==typeof define&&define.amd?define("plugin-git-manager/client-v2",["@nocobase/client-v2","react","antd","@ant-design/icons","@nocobase/plugin-ai/client"],t):"object"==typeof exports?exports["plugin-git-manager/client-v2"]=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/plugin-ai/client")):e["plugin-git-manager/client-v2"]=t(e["@nocobase/client-v2"],e.react,e.antd,e["@ant-design/icons"],e["@nocobase/plugin-ai/client"])}(self,function(e,t,n,r,o){return function(){"use strict";var i,a,u,c={375:function(e){e.exports=r},485:function(t){t.exports=e},75:function(e){e.exports=o},59:function(e){e.exports=n},155:function(e){e.exports=t}},l={};function p(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={exports:{}};return c[e].call(n.exports,n,n.exports,p),n.exports}p.m=c,p.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return p.d(t,{a:t}),t},p.d=function(e,t){for(var n in t)p.o(t,n)&&!p.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},p.f={},p.e=function(e){return Promise.all(Object.keys(p.f).reduce(function(t,n){return p.f[n](e,t),t},[]))},p.u=function(e){return""+e+"."+({326:"42b7b53651ffab3a",434:"
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/plugin-ai/client")):"function"==typeof define&&define.amd?define("plugin-git-manager/client-v2",["@nocobase/client-v2","react","antd","@ant-design/icons","@nocobase/plugin-ai/client"],t):"object"==typeof exports?exports["plugin-git-manager/client-v2"]=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/plugin-ai/client")):e["plugin-git-manager/client-v2"]=t(e["@nocobase/client-v2"],e.react,e.antd,e["@ant-design/icons"],e["@nocobase/plugin-ai/client"])}(self,function(e,t,n,r,o){return function(){"use strict";var i,a,u,c={375:function(e){e.exports=r},485:function(t){t.exports=e},75:function(e){e.exports=o},59:function(e){e.exports=n},155:function(e){e.exports=t}},l={};function p(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={exports:{}};return c[e].call(n.exports,n,n.exports,p),n.exports}p.m=c,p.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return p.d(t,{a:t}),t},p.d=function(e,t){for(var n in t)p.o(t,n)&&!p.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},p.f={},p.e=function(e){return Promise.all(Object.keys(p.f).reduce(function(t,n){return p.f[n](e,t),t},[]))},p.u=function(e){return""+e+"."+({326:"42b7b53651ffab3a",434:"c2f944f911a56da0",878:"295f09c9d77ea6d8"})[e]+".js"},p.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),p.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},f={},p.l=function(e,t,n,r){if(f[e])return void f[e].push(t);if(void 0!==n)for(var o,i,a=document.getElementsByTagName("script"),u=0;u<a.length;u++){var c=a[u];if(c.getAttribute("src")==e||c.getAttribute("data-rspack")=="plugin-git-manager/client-v2:"+n){o=c;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,p.nc&&o.setAttribute("nonce",p.nc),o.setAttribute("data-rspack","plugin-git-manager/client-v2:"+n),o.src=e),f[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(s);var r=f[e];if(delete f[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),i&&document.head.appendChild(o)},p.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},p.g.importScripts&&(s=p.g.location+"");var f,s,g=p.g.document;if(!s&&g&&(g.currentScript&&"SCRIPT"===g.currentScript.tagName.toUpperCase()&&(s=g.currentScript.src),!s)){var d=g.getElementsByTagName("script");if(d.length)for(var b=d.length-1;b>-1&&(!s||!/^http(s?):/.test(s));)s=d[b--].src}if(!s)throw Error("Automatic publicPath is not supported in this browser");p.p=s.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i={889:0},p.f.j=function(e,t){var n=p.o(i,e)?i[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=i[e]=[t,r]});t.push(n[2]=r);var o=p.p+p.u(e),a=Error();p.l(o,function(t){if(p.o(i,e)&&(0!==(n=i[e])&&(i[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;a.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",a.name="ChunkLoadError",a.type=r,a.request=o,n[1](a)}},"chunk-"+e,e)}},a=function(e,t){var n,r,o=t[0],a=t[1],u=t[2],c=0;if(o.some(function(e){return 0!==i[e]})){for(n in a)p.o(a,n)&&(p.m[n]=a[n]);u&&u(p)}for(e&&e(t);c<o.length;c++)r=o[c],p.o(i,r)&&i[r]&&i[r][0](),i[r]=0},(u=self.webpackChunkplugin_git_manager_client_v2=self.webpackChunkplugin_git_manager_client_v2||[]).forEach(a.bind(null,0)),u.push=a.bind(null,u.push.bind(u));var v={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/plugin-git-manager/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/plugin-git-manager/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",u=a.indexOf(i);e=u>=0?a.slice(0,u+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/plugin-git-manager/dist/client-v2/"}p.p=e}(),!function(){p.r(v),p.d(v,{default:function(){return u}});var e=p(485);function t(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function n(e,t,r){return(n=a()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&o(i,n.prototype),i}).apply(null,arguments)}p(155);function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e){var t="function"==typeof Map?new Map:void 0;return(i=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return n(e,arguments,r(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),o(i,e)})(e)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var u=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function i(){var e,t;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return e=i,t=arguments,e=r(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,a()?Reflect.construct(e,t||[],r(this).constructor):e.apply(this,t))}return i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&o(i,e),n=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){return this.pluginSettingsManager.addMenuItem({key:"git-manager",title:this.t("Git Manager"),icon:"BranchesOutlined"}),this.pluginSettingsManager.addPageTabItem({menuKey:"git-manager",key:"repositories",title:this.t("Repositories"),aclSnippet:"pm.plugin-git-manager.repositories",componentLoader:function(){return p.e("434").then(p.bind(p,33)).then(function(e){return{default:e.RepositoryConfig}})}}),this.pluginSettingsManager.addPageTabItem({menuKey:"git-manager",key:"manage",title:this.t("Manage"),aclSnippet:"pm.plugin-git-manager.manage",componentLoader:function(){return Promise.all([p.e("326"),p.e("878")]).then(p.bind(p,205)).then(function(e){return{default:e.GitManagerSettings}})}}),[2]})},function(){var n=this,r=arguments;return new Promise(function(o,i){var a=e.apply(n,r);function u(e){t(a,o,i,u,c,"next",e)}function c(e){t(a,o,i,u,c,"throw",e)}u(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(i.prototype,n),i}(i(e.Plugin))}(),v}()});
|
package/dist/externalVersion.js
CHANGED
|
@@ -11,13 +11,13 @@ module.exports = {
|
|
|
11
11
|
"react": "18.2.0",
|
|
12
12
|
"antd": "5.24.2",
|
|
13
13
|
"@ant-design/icons": "5.6.1",
|
|
14
|
-
"@nocobase/client": "2.1.
|
|
15
|
-
"@nocobase/plugin-acl": "2.1.
|
|
16
|
-
"@nocobase/client-v2": "2.1.
|
|
17
|
-
"@nocobase/server": "2.1.
|
|
14
|
+
"@nocobase/client": "2.1.10",
|
|
15
|
+
"@nocobase/plugin-acl": "2.1.10",
|
|
16
|
+
"@nocobase/client-v2": "2.1.10",
|
|
17
|
+
"@nocobase/server": "2.1.10",
|
|
18
18
|
"sequelize": "6.35.2",
|
|
19
19
|
"dayjs": "1.11.13",
|
|
20
|
-
"@nocobase/plugin-ai": "2.1.
|
|
21
|
-
"@nocobase/actions": "2.1.
|
|
22
|
-
"@nocobase/database": "2.1.
|
|
20
|
+
"@nocobase/plugin-ai": "2.1.10",
|
|
21
|
+
"@nocobase/actions": "2.1.10",
|
|
22
|
+
"@nocobase/database": "2.1.10"
|
|
23
23
|
};
|
|
@@ -589,7 +589,7 @@ async function reviewReject(ctx, next) {
|
|
|
589
589
|
await next();
|
|
590
590
|
}
|
|
591
591
|
async function runReview(app, args) {
|
|
592
|
-
var _a, _b, _c, _d;
|
|
592
|
+
var _a, _b, _c, _d, _e, _f;
|
|
593
593
|
const db = app.db;
|
|
594
594
|
const reviewsRepo = db.getRepository("gitCodeReviews");
|
|
595
595
|
const startedAt = /* @__PURE__ */ new Date();
|
|
@@ -678,16 +678,16 @@ async function runReview(app, args) {
|
|
|
678
678
|
const llmService = args.flow.get("llmService");
|
|
679
679
|
const model = args.flow.get("model");
|
|
680
680
|
const modelRef = llmService && model ? { llmService, model } : void 0;
|
|
681
|
-
const aiEmployee = new AIEmployee(
|
|
682
|
-
syntheticCtx,
|
|
683
|
-
employeeRecord,
|
|
681
|
+
const aiEmployee = new AIEmployee({
|
|
682
|
+
ctx: syntheticCtx,
|
|
683
|
+
employee: employeeRecord,
|
|
684
684
|
sessionId,
|
|
685
|
-
void 0,
|
|
686
|
-
void 0,
|
|
687
|
-
false,
|
|
688
|
-
modelRef,
|
|
689
|
-
false
|
|
690
|
-
);
|
|
685
|
+
systemMessage: void 0,
|
|
686
|
+
skillSettings: void 0,
|
|
687
|
+
webSearch: false,
|
|
688
|
+
model: modelRef,
|
|
689
|
+
legacy: false
|
|
690
|
+
});
|
|
691
691
|
const REVIEW_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
692
692
|
const result = await Promise.race([
|
|
693
693
|
aiEmployee.invoke({
|
|
@@ -755,6 +755,7 @@ async function runReview(app, args) {
|
|
|
755
755
|
} catch (err) {
|
|
756
756
|
const finishedAt = /* @__PURE__ */ new Date();
|
|
757
757
|
const safeMessage = (0, import_redact.redactPat)((err == null ? void 0 : err.message) || String(err));
|
|
758
|
+
(_f = (_e = app.log) == null ? void 0 : _e.error) == null ? void 0 : _f.call(_e, `git review ${args.reviewId} failed: ${safeMessage}`, err);
|
|
758
759
|
await reviewsRepo.update({
|
|
759
760
|
filterByTk: args.reviewId,
|
|
760
761
|
values: {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"displayName": "Git Manager",
|
|
4
4
|
"displayName.zh-CN": "Git 管理器",
|
|
5
5
|
"description": "Manage Git repositories with PAT authentication - pull, push, fetch, diff, file browsing",
|
|
6
|
-
"version": "1.2.
|
|
6
|
+
"version": "1.2.11",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"main": "dist/server/index.js",
|
|
9
9
|
"files": [
|
|
@@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useState } from 'react';
|
|
|
2
2
|
import { Table, Button, Modal, Form, Input, Space, Tag, Popconfirm, Switch, Tooltip, Select, message } from 'antd';
|
|
3
3
|
import { PlusOutlined, DeleteOutlined, LinkOutlined, RobotOutlined } from '@ant-design/icons';
|
|
4
4
|
import { useApp } from '@nocobase/client-v2';
|
|
5
|
-
import { useGitManager } from '../context/GitManagerContext';
|
|
5
|
+
import { GitManagerProvider, useGitManager } from '../context/GitManagerContext';
|
|
6
6
|
import { useT } from '../locale';
|
|
7
7
|
|
|
8
8
|
export const RepositoryConfig: React.FC = () => {
|
|
@@ -33,6 +33,10 @@ export const RepositoryConfig: React.FC = () => {
|
|
|
33
33
|
loadReviewFlows().catch(() => undefined);
|
|
34
34
|
}, [loadReviewFlows]);
|
|
35
35
|
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
refreshRepos().catch(() => undefined);
|
|
38
|
+
}, [refreshRepos]);
|
|
39
|
+
|
|
36
40
|
const getAutoFlowOptions = (repoId: number) =>
|
|
37
41
|
reviewFlows
|
|
38
42
|
.filter((flow) => flow.repositoryId === repoId || flow.repositoryId == null)
|
|
@@ -102,9 +106,7 @@ export const RepositoryConfig: React.FC = () => {
|
|
|
102
106
|
title: t('Repository Name'),
|
|
103
107
|
dataIndex: 'name',
|
|
104
108
|
key: 'name',
|
|
105
|
-
render: (text: string, record: any) => (
|
|
106
|
-
<a onClick={() => setSelectedRepo(record)}>{text}</a>
|
|
107
|
-
),
|
|
109
|
+
render: (text: string, record: any) => <a onClick={() => setSelectedRepo(record)}>{text}</a>,
|
|
108
110
|
},
|
|
109
111
|
{ title: t('Repository URL'), dataIndex: 'repoUrl', key: 'repoUrl', ellipsis: true },
|
|
110
112
|
{ title: t('Local Path'), dataIndex: 'localPath', key: 'localPath', ellipsis: true },
|
|
@@ -134,7 +136,8 @@ export const RepositoryConfig: React.FC = () => {
|
|
|
134
136
|
params: { filterByTk: record.id },
|
|
135
137
|
data: {
|
|
136
138
|
autoReview: checked,
|
|
137
|
-
autoReviewFlowId:
|
|
139
|
+
autoReviewFlowId:
|
|
140
|
+
checked && !record.autoReviewFlowId ? options[0]?.value ?? null : record.autoReviewFlowId,
|
|
138
141
|
},
|
|
139
142
|
});
|
|
140
143
|
await refreshRepos();
|
|
@@ -269,7 +272,12 @@ export const RepositoryConfig: React.FC = () => {
|
|
|
269
272
|
<Form.Item name="repoUrl" label={t('Repository URL')} rules={[{ required: true }]}>
|
|
270
273
|
<Input placeholder="https://gitlab.com/user/repo.git" />
|
|
271
274
|
</Form.Item>
|
|
272
|
-
<Form.Item
|
|
275
|
+
<Form.Item
|
|
276
|
+
name="username"
|
|
277
|
+
label={t('Username')}
|
|
278
|
+
rules={[{ required: true }]}
|
|
279
|
+
extra={t('GitLab username for PAT authentication')}
|
|
280
|
+
>
|
|
273
281
|
<Input placeholder="gitlab-username" />
|
|
274
282
|
</Form.Item>
|
|
275
283
|
<Form.Item name="localPath" label={t('Local Path')} rules={[{ required: true }]}>
|
|
@@ -281,7 +289,11 @@ export const RepositoryConfig: React.FC = () => {
|
|
|
281
289
|
<Form.Item name="defaultBranch" label={t('Default Branch')}>
|
|
282
290
|
<Input placeholder="main" />
|
|
283
291
|
</Form.Item>
|
|
284
|
-
<Form.Item
|
|
292
|
+
<Form.Item
|
|
293
|
+
name="autoReviewFlowId"
|
|
294
|
+
label={t('Primary Auto Review Flow')}
|
|
295
|
+
extra={t('Only flows with automatic trigger modes are shown')}
|
|
296
|
+
>
|
|
285
297
|
<Select
|
|
286
298
|
allowClear
|
|
287
299
|
placeholder={t('Select a flow')}
|
|
@@ -294,3 +306,9 @@ export const RepositoryConfig: React.FC = () => {
|
|
|
294
306
|
</div>
|
|
295
307
|
);
|
|
296
308
|
};
|
|
309
|
+
|
|
310
|
+
export const RepositoryConfigSettings: React.FC = () => (
|
|
311
|
+
<GitManagerProvider>
|
|
312
|
+
<RepositoryConfig />
|
|
313
|
+
</GitManagerProvider>
|
|
314
|
+
);
|
|
@@ -23,10 +23,14 @@ interface GitManagerContextType {
|
|
|
23
23
|
refreshBranches: () => Promise<void>;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const GitManagerContext = createContext<GitManagerContextType>(null);
|
|
26
|
+
const GitManagerContext = createContext<GitManagerContextType | null>(null);
|
|
27
27
|
|
|
28
28
|
export function useGitManager() {
|
|
29
|
-
|
|
29
|
+
const context = useContext(GitManagerContext);
|
|
30
|
+
if (!context) {
|
|
31
|
+
throw new Error('useGitManager must be used within GitManagerProvider');
|
|
32
|
+
}
|
|
33
|
+
return context;
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
export const GitManagerProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
|
@@ -79,7 +83,9 @@ export const GitManagerProvider: React.FC<{ children: React.ReactNode }> = ({ ch
|
|
|
79
83
|
}, [api]);
|
|
80
84
|
|
|
81
85
|
return (
|
|
82
|
-
<GitManagerContext.Provider
|
|
86
|
+
<GitManagerContext.Provider
|
|
87
|
+
value={{ repos, selectedRepo, loading, branches, currentBranch, setSelectedRepo, refreshRepos, refreshBranches }}
|
|
88
|
+
>
|
|
83
89
|
{children}
|
|
84
90
|
</GitManagerContext.Provider>
|
|
85
91
|
);
|
package/src/client/index.tsx
CHANGED
|
@@ -1,65 +1,61 @@
|
|
|
1
|
-
import { Plugin } from '@nocobase/client';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
import('./components/
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export default PluginGitManagerClient;
|
|
1
|
+
import { Plugin } from '@nocobase/client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { GitRepositoryWorkContext, GitMergeRequestWorkContext, GitCommitWorkContext } from './ai-context';
|
|
4
|
+
|
|
5
|
+
const GitManagerSettings = React.lazy(() =>
|
|
6
|
+
import('./components/GitManagerSettings').then((m) => ({ default: m.GitManagerSettings })),
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
const RepositoryConfig = React.lazy(() =>
|
|
10
|
+
import('./components/RepositoryConfig').then((m) => ({ default: m.RepositoryConfigSettings })),
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
import PluginACLClient from '@nocobase/plugin-acl/client';
|
|
14
|
+
import { RepositoryPermissions } from './components/RepositoryPermissions';
|
|
15
|
+
|
|
16
|
+
export class PluginGitManagerClient extends Plugin {
|
|
17
|
+
async load() {
|
|
18
|
+
// Parent group with no direct component — acts as a category in settings
|
|
19
|
+
this.app.pluginSettingsManager.add('git-manager', {
|
|
20
|
+
title: (this as any).t('Git Manager'),
|
|
21
|
+
icon: 'BranchesOutlined',
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Repositories config — separate group for ACL-granular access
|
|
25
|
+
this.app.pluginSettingsManager.add('git-manager.repositories', {
|
|
26
|
+
title: (this as any).t('Repositories'),
|
|
27
|
+
Component: RepositoryConfig,
|
|
28
|
+
aclSnippet: `pm.plugin-git-manager.repositories`,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Full management — requires full plugin permission
|
|
32
|
+
this.app.pluginSettingsManager.add('git-manager.manage', {
|
|
33
|
+
title: (this as any).t('Manage'),
|
|
34
|
+
Component: GitManagerSettings,
|
|
35
|
+
aclSnippet: `pm.plugin-git-manager.manage`,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const aiManager = ((this as any).app as any).aiManager;
|
|
39
|
+
if (aiManager?.registerWorkContext) {
|
|
40
|
+
aiManager.registerWorkContext('git-repository', GitRepositoryWorkContext);
|
|
41
|
+
aiManager.registerWorkContext('git-merge-request', GitMergeRequestWorkContext);
|
|
42
|
+
aiManager.registerWorkContext('git-commit', GitCommitWorkContext);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const aclPlugin = this.app.pm.get(PluginACLClient);
|
|
46
|
+
if (aclPlugin) {
|
|
47
|
+
aclPlugin.settingsUI.addPermissionsTab(({ t, TabLayout, activeRole }) => ({
|
|
48
|
+
key: 'git-manager',
|
|
49
|
+
label: 'Git Manager',
|
|
50
|
+
sort: 25,
|
|
51
|
+
children: (
|
|
52
|
+
<TabLayout>
|
|
53
|
+
<RepositoryPermissions activeRole={activeRole} />
|
|
54
|
+
</TabLayout>
|
|
55
|
+
),
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default PluginGitManagerClient;
|