@nocobase/plugin-multi-app-manager 0.9.3-alpha.1 → 0.9.4-alpha.2
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/lib/client/AppManager.js +10 -2
- package/lib/client/index.js +23 -13
- package/lib/client/locale/es-ES.d.ts +10 -0
- package/lib/client/locale/es-ES.js +16 -0
- package/lib/client/locale/zh-CN.d.ts +2 -0
- package/lib/client/locale/zh-CN.js +3 -1
- package/lib/client/settings/schemas/applications.d.ts +10 -0
- package/lib/client/settings/schemas/applications.js +20 -0
- package/lib/server/server.js +79 -12
- package/package.json +3 -3
package/lib/client/AppManager.js
CHANGED
|
@@ -28,12 +28,20 @@ function _react() {
|
|
|
28
28
|
var _applications = require("./settings/schemas/applications");
|
|
29
29
|
var _utils = require("./utils");
|
|
30
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
const
|
|
31
|
+
const useLink = () => {
|
|
32
|
+
var _record$options;
|
|
32
33
|
const record = (0, _client().useRecord)();
|
|
34
|
+
if (((_record$options = record.options) === null || _record$options === void 0 ? void 0 : _record$options.standaloneDeployment) && record.cname) {
|
|
35
|
+
return `//${record.cname}`;
|
|
36
|
+
}
|
|
37
|
+
return `/apps/${record.name}/admin/`;
|
|
38
|
+
};
|
|
39
|
+
const AppVisitor = () => {
|
|
33
40
|
const _usePluginUtils = (0, _utils.usePluginUtils)(),
|
|
34
41
|
t = _usePluginUtils.t;
|
|
42
|
+
const link = useLink();
|
|
35
43
|
return _react().default.createElement("a", {
|
|
36
|
-
href:
|
|
44
|
+
href: link,
|
|
37
45
|
target: '_blank',
|
|
38
46
|
rel: "noreferrer"
|
|
39
47
|
}, t('View', {
|
package/lib/client/index.js
CHANGED
|
@@ -56,23 +56,33 @@ const MultiAppManager = () => {
|
|
|
56
56
|
run = _useRequest.run;
|
|
57
57
|
const _usePluginUtils = (0, _utils.usePluginUtils)(),
|
|
58
58
|
t = _usePluginUtils.t;
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
}, app.displayName || app.name);
|
|
66
|
-
}), ((data === null || data === void 0 ? void 0 : data.data) || []).length > 0 && _react().default.createElement(_antd().Menu.Divider, null), _react().default.createElement(_antd().Menu.Item, {
|
|
67
|
-
onClick: () => {
|
|
68
|
-
history.push('/admin/settings/multi-app-manager/applications');
|
|
59
|
+
const items = [...((data === null || data === void 0 ? void 0 : data.data) || []).map(app => {
|
|
60
|
+
var _app$options;
|
|
61
|
+
let link = `/apps/${app.name}/admin/`;
|
|
62
|
+
if (((_app$options = app.options) === null || _app$options === void 0 ? void 0 : _app$options.standaloneDeployment) && app.cname) {
|
|
63
|
+
link = `//${app.cname}`;
|
|
69
64
|
}
|
|
70
|
-
|
|
65
|
+
return {
|
|
66
|
+
key: app.name,
|
|
67
|
+
label: _react().default.createElement("a", {
|
|
68
|
+
href: link,
|
|
69
|
+
target: "_blank",
|
|
70
|
+
rel: "noopener noreferrer"
|
|
71
|
+
}, app.displayName || app.name)
|
|
72
|
+
};
|
|
73
|
+
}), {
|
|
74
|
+
key: '.manager',
|
|
75
|
+
label: _react().default.createElement(_reactRouterDom().Link, {
|
|
76
|
+
to: "/admin/settings/multi-app-manager/applications"
|
|
77
|
+
}, t('Manage applications'))
|
|
78
|
+
}];
|
|
71
79
|
return _react().default.createElement(_antd().Dropdown, {
|
|
72
|
-
|
|
80
|
+
onOpenChange: visible => {
|
|
73
81
|
run();
|
|
74
82
|
},
|
|
75
|
-
|
|
83
|
+
menu: {
|
|
84
|
+
items
|
|
85
|
+
}
|
|
76
86
|
}, _react().default.createElement(_antd().Button, {
|
|
77
87
|
title: 'Apps',
|
|
78
88
|
icon: _react().default.createElement(_client().Icon, {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
"Multi-app manager": "Gestor de aplicaciones múltiples",
|
|
9
|
+
"Applications": "Aplicaciones",
|
|
10
|
+
"App display name": "Mostrar nombre de aplicación",
|
|
11
|
+
"App ID": "ID de aplicación",
|
|
12
|
+
"Pin to menu": " Fijar al menú",
|
|
13
|
+
"Custom domain": "Dominio personalizado",
|
|
14
|
+
"Manage applications": "Gestionar aplicaciones"
|
|
15
|
+
};
|
|
16
|
+
exports.default = _default;
|
|
@@ -35,6 +35,16 @@ export declare const tableActionColumnSchema: {
|
|
|
35
35
|
'x-component': string;
|
|
36
36
|
'x-decorator': string;
|
|
37
37
|
};
|
|
38
|
+
'options.standaloneDeployment': {
|
|
39
|
+
'x-component': string;
|
|
40
|
+
'x-decorator': string;
|
|
41
|
+
'x-content': string;
|
|
42
|
+
};
|
|
43
|
+
'options.autoStart': {
|
|
44
|
+
'x-component': string;
|
|
45
|
+
'x-decorator': string;
|
|
46
|
+
'x-content': string;
|
|
47
|
+
};
|
|
38
48
|
cname: {
|
|
39
49
|
title: string;
|
|
40
50
|
'x-component': string;
|
|
@@ -152,6 +152,16 @@ const tableActionColumnSchema = {
|
|
|
152
152
|
'x-component': 'CollectionField',
|
|
153
153
|
'x-decorator': 'FormItem'
|
|
154
154
|
},
|
|
155
|
+
'options.standaloneDeployment': {
|
|
156
|
+
'x-component': 'Checkbox',
|
|
157
|
+
'x-decorator': 'FormItem',
|
|
158
|
+
'x-content': (0, _utils.i18nText)('Standalone deployment')
|
|
159
|
+
},
|
|
160
|
+
'options.autoStart': {
|
|
161
|
+
'x-component': 'Checkbox',
|
|
162
|
+
'x-decorator': 'FormItem',
|
|
163
|
+
'x-content': (0, _utils.i18nText)('Auto start')
|
|
164
|
+
},
|
|
155
165
|
cname: {
|
|
156
166
|
title: (0, _utils.i18nText)('Custom domain'),
|
|
157
167
|
'x-component': 'Input',
|
|
@@ -280,6 +290,16 @@ const schema = {
|
|
|
280
290
|
'x-component': 'CollectionField',
|
|
281
291
|
'x-decorator': 'FormItem'
|
|
282
292
|
},
|
|
293
|
+
'options.standaloneDeployment': {
|
|
294
|
+
'x-component': 'Checkbox',
|
|
295
|
+
'x-decorator': 'FormItem',
|
|
296
|
+
'x-content': (0, _utils.i18nText)('Standalone deployment')
|
|
297
|
+
},
|
|
298
|
+
'options.autoStart': {
|
|
299
|
+
'x-component': 'Checkbox',
|
|
300
|
+
'x-decorator': 'FormItem',
|
|
301
|
+
'x-content': (0, _utils.i18nText)('Auto start')
|
|
302
|
+
},
|
|
283
303
|
cname: {
|
|
284
304
|
title: (0, _utils.i18nText)('Custom domain'),
|
|
285
305
|
'x-component': 'Input',
|
package/lib/server/server.js
CHANGED
|
@@ -205,6 +205,11 @@ class PluginMultiAppManager extends _server().Plugin {
|
|
|
205
205
|
name
|
|
206
206
|
}
|
|
207
207
|
});
|
|
208
|
+
const instanceOptions = applicationRecord.get('options');
|
|
209
|
+
// skip standalone deployment application
|
|
210
|
+
if ((instanceOptions === null || instanceOptions === void 0 ? void 0 : instanceOptions.standaloneDeployment) && appManager.runningMode !== 'single') {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
208
213
|
if (!applicationRecord) {
|
|
209
214
|
return;
|
|
210
215
|
}
|
|
@@ -220,17 +225,79 @@ class PluginMultiAppManager extends _server().Plugin {
|
|
|
220
225
|
return _ref5.apply(this, arguments);
|
|
221
226
|
};
|
|
222
227
|
}());
|
|
228
|
+
_this.app.on('afterStart', /*#__PURE__*/function () {
|
|
229
|
+
var _ref6 = _asyncToGenerator(function* (app) {
|
|
230
|
+
const repository = _this.db.getRepository('applications');
|
|
231
|
+
const appManager = _this.app.appManager;
|
|
232
|
+
if (appManager.runningMode == 'single') {
|
|
233
|
+
// If the sub application is running in single mode, register the application automatically
|
|
234
|
+
try {
|
|
235
|
+
const subApp = yield repository.findOne({
|
|
236
|
+
filter: {
|
|
237
|
+
name: appManager.singleAppName
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
const registeredApp = yield subApp.registerToMainApp(_this.app, {
|
|
241
|
+
appOptionsFactory: _this.appOptionsFactory
|
|
242
|
+
});
|
|
243
|
+
yield registeredApp.load();
|
|
244
|
+
} catch (err) {
|
|
245
|
+
console.error('Auto register sub application in single mode failed: ', appManager.singleAppName, err);
|
|
246
|
+
}
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
try {
|
|
250
|
+
const subApps = yield repository.find({
|
|
251
|
+
filter: {
|
|
252
|
+
'options.autoStart': true
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
var _iterator = _createForOfIteratorHelper(subApps),
|
|
256
|
+
_step;
|
|
257
|
+
try {
|
|
258
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
259
|
+
const subApp = _step.value;
|
|
260
|
+
const registeredApp = yield subApp.registerToMainApp(_this.app, {
|
|
261
|
+
appOptionsFactory: _this.appOptionsFactory
|
|
262
|
+
});
|
|
263
|
+
yield registeredApp.load();
|
|
264
|
+
}
|
|
265
|
+
} catch (err) {
|
|
266
|
+
_iterator.e(err);
|
|
267
|
+
} finally {
|
|
268
|
+
_iterator.f();
|
|
269
|
+
}
|
|
270
|
+
} catch (err) {
|
|
271
|
+
console.error('Auto register sub applications failed: ', err);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
return function (_x7) {
|
|
275
|
+
return _ref6.apply(this, arguments);
|
|
276
|
+
};
|
|
277
|
+
}());
|
|
223
278
|
_this.app.on('afterUpgrade', /*#__PURE__*/function () {
|
|
224
|
-
var
|
|
279
|
+
var _ref7 = _asyncToGenerator(function* (app, options) {
|
|
225
280
|
const cliArgs = options === null || options === void 0 ? void 0 : options.cliArgs;
|
|
226
281
|
const repository = _this.db.getRepository('applications');
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
282
|
+
const findOptions = {};
|
|
283
|
+
const appManager = _this.app.appManager;
|
|
284
|
+
if (appManager.runningMode == 'single') {
|
|
285
|
+
findOptions['filter'] = {
|
|
286
|
+
name: appManager.singleAppName
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
const instances = yield repository.find(findOptions);
|
|
290
|
+
var _iterator2 = _createForOfIteratorHelper(instances),
|
|
291
|
+
_step2;
|
|
230
292
|
try {
|
|
231
|
-
for (
|
|
232
|
-
const instance =
|
|
233
|
-
const
|
|
293
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
294
|
+
const instance = _step2.value;
|
|
295
|
+
const instanceOptions = instance.get('options');
|
|
296
|
+
// skip standalone deployment application
|
|
297
|
+
if ((instanceOptions === null || instanceOptions === void 0 ? void 0 : instanceOptions.standaloneDeployment) && appManager.runningMode !== 'single') {
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
const subApp = yield appManager.getApplication(instance.name, {
|
|
234
301
|
upgrading: true
|
|
235
302
|
});
|
|
236
303
|
try {
|
|
@@ -248,13 +315,13 @@ class PluginMultiAppManager extends _server().Plugin {
|
|
|
248
315
|
}
|
|
249
316
|
}
|
|
250
317
|
} catch (err) {
|
|
251
|
-
|
|
318
|
+
_iterator2.e(err);
|
|
252
319
|
} finally {
|
|
253
|
-
|
|
320
|
+
_iterator2.f();
|
|
254
321
|
}
|
|
255
322
|
});
|
|
256
|
-
return function (
|
|
257
|
-
return
|
|
323
|
+
return function (_x8, _x9) {
|
|
324
|
+
return _ref7.apply(this, arguments);
|
|
258
325
|
};
|
|
259
326
|
}());
|
|
260
327
|
_this.app.resourcer.registerActionHandlers({
|
|
@@ -267,7 +334,7 @@ class PluginMultiAppManager extends _server().Plugin {
|
|
|
267
334
|
});
|
|
268
335
|
ctx.body = items;
|
|
269
336
|
});
|
|
270
|
-
function applicationsListPinned(
|
|
337
|
+
function applicationsListPinned(_x10, _x11) {
|
|
271
338
|
return _applicationsListPinned.apply(this, arguments);
|
|
272
339
|
}
|
|
273
340
|
return applicationsListPinned;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-multi-app-manager",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4-alpha.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/server": "0.9.
|
|
9
|
+
"@nocobase/server": "0.9.4-alpha.2"
|
|
10
10
|
},
|
|
11
|
-
"gitHead": "
|
|
11
|
+
"gitHead": "2bc19a85bf9425aa220b6c467315c8087f333a7e"
|
|
12
12
|
}
|