@nocobase/plugin-multi-portal 2.2.0-alpha.11 → 2.4.0-alpha.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/README.md +14 -6
- package/dist/client-v2/354.87f18462949b5c23.js +10 -0
- package/dist/client-v2/499.245037eea4cc7266.js +10 -0
- package/dist/client-v2/556.443e73c9ca4c18b9.js +10 -0
- package/dist/client-v2/778.affaa69b23857ef2.js +10 -0
- package/dist/client-v2/993.7a1cc7aa6cec0160.js +10 -0
- package/dist/client-v2/PortalAccessBoundary.d.ts +49 -0
- package/dist/client-v2/RootLanding.d.ts +18 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/client-v2/interceptor.d.ts +13 -0
- package/dist/client-v2/layoutRegistration.d.ts +5 -7
- package/dist/client-v2/models/MultiPortalLayoutModels.d.ts +14 -0
- package/dist/client-v2/models/MultiPortalMobilePageModels.d.ts +5 -11
- package/dist/client-v2/pages/MultiPortalsPage.d.ts +13 -6
- package/dist/client-v2/pages/PortalRoutesDrawer.d.ts +13 -0
- package/dist/client-v2/permissions/MultiPortalPermissionsTab.d.ts +1 -0
- package/dist/client-v2/portalAccess.d.ts +73 -0
- package/dist/client-v2/routeRepositoryScope.d.ts +5 -2
- package/dist/client-v2/routeUrl.d.ts +1 -0
- package/dist/constants.d.ts +19 -0
- package/dist/constants.js +76 -0
- package/dist/externalVersion.js +11 -9
- package/dist/locale/en-US.json +93 -11
- package/dist/locale/zh-CN.json +113 -31
- package/dist/node_modules/tar/package.json +1 -1
- package/dist/server/collections/desktopRoutes.js +1 -0
- package/dist/server/collections/multiPortals.js +12 -11
- package/dist/server/migrations/20260730120000-fix-fixed-layout-portal-type.d.ts +13 -0
- package/dist/server/migrations/20260730120000-fix-fixed-layout-portal-type.js +73 -0
- package/dist/server/plugin.d.ts +7 -5
- package/dist/server/plugin.js +1415 -502
- package/dist/swagger/index.d.ts +152 -0
- package/dist/swagger/index.js +142 -0
- package/package.json +6 -7
- package/dist/client-v2/354.ead3e96143164cd5.js +0 -10
- package/dist/client-v2/499.ef2ff0c022687485.js +0 -10
- package/dist/client-v2/778.23ba409a924ee34a.js +0 -10
- package/dist/client-v2/845.f2b0ce44ae4be707.js +0 -10
|
@@ -0,0 +1,152 @@
|
|
|
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
|
+
declare const _default: {
|
|
10
|
+
openapi: string;
|
|
11
|
+
info: {
|
|
12
|
+
title: string;
|
|
13
|
+
version: string;
|
|
14
|
+
};
|
|
15
|
+
paths: {
|
|
16
|
+
'/roles/{roleName}/multiPortals:list': {
|
|
17
|
+
get: {
|
|
18
|
+
tags: string[];
|
|
19
|
+
summary: string;
|
|
20
|
+
description: string;
|
|
21
|
+
parameters: {
|
|
22
|
+
$ref: string;
|
|
23
|
+
}[];
|
|
24
|
+
responses: {
|
|
25
|
+
200: {
|
|
26
|
+
description: string;
|
|
27
|
+
content: {
|
|
28
|
+
'application/json': {
|
|
29
|
+
schema: {
|
|
30
|
+
type: string;
|
|
31
|
+
properties: {
|
|
32
|
+
data: {
|
|
33
|
+
type: string;
|
|
34
|
+
items: {
|
|
35
|
+
$ref: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
'/roles/{roleName}/multiPortals:add': {
|
|
47
|
+
post: {
|
|
48
|
+
tags: string[];
|
|
49
|
+
summary: string;
|
|
50
|
+
description: string;
|
|
51
|
+
parameters: {
|
|
52
|
+
$ref: string;
|
|
53
|
+
}[];
|
|
54
|
+
requestBody: {
|
|
55
|
+
required: boolean;
|
|
56
|
+
content: {
|
|
57
|
+
'application/json': {
|
|
58
|
+
schema: {
|
|
59
|
+
$ref: string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
responses: {
|
|
65
|
+
200: {
|
|
66
|
+
description: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
'/roles/{roleName}/multiPortals:remove': {
|
|
72
|
+
post: {
|
|
73
|
+
tags: string[];
|
|
74
|
+
summary: string;
|
|
75
|
+
description: string;
|
|
76
|
+
parameters: {
|
|
77
|
+
$ref: string;
|
|
78
|
+
}[];
|
|
79
|
+
requestBody: {
|
|
80
|
+
required: boolean;
|
|
81
|
+
content: {
|
|
82
|
+
'application/json': {
|
|
83
|
+
schema: {
|
|
84
|
+
$ref: string;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
responses: {
|
|
90
|
+
200: {
|
|
91
|
+
description: string;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
components: {
|
|
98
|
+
parameters: {
|
|
99
|
+
RoleNamePath: {
|
|
100
|
+
name: string;
|
|
101
|
+
in: string;
|
|
102
|
+
description: string;
|
|
103
|
+
required: boolean;
|
|
104
|
+
schema: {
|
|
105
|
+
type: string;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
schemas: {
|
|
110
|
+
PortalAccessWrite: {
|
|
111
|
+
type: string;
|
|
112
|
+
properties: {
|
|
113
|
+
values: {
|
|
114
|
+
type: string;
|
|
115
|
+
description: string;
|
|
116
|
+
items: {
|
|
117
|
+
type: string;
|
|
118
|
+
};
|
|
119
|
+
minItems: number;
|
|
120
|
+
uniqueItems: boolean;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
required: string[];
|
|
124
|
+
};
|
|
125
|
+
PortalAccessTarget: {
|
|
126
|
+
type: string;
|
|
127
|
+
additionalProperties: boolean;
|
|
128
|
+
properties: {
|
|
129
|
+
uid: {
|
|
130
|
+
type: string;
|
|
131
|
+
};
|
|
132
|
+
title: {
|
|
133
|
+
type: string;
|
|
134
|
+
};
|
|
135
|
+
portalName: {
|
|
136
|
+
type: string;
|
|
137
|
+
};
|
|
138
|
+
routePath: {
|
|
139
|
+
type: string;
|
|
140
|
+
};
|
|
141
|
+
portalType: {
|
|
142
|
+
type: string;
|
|
143
|
+
};
|
|
144
|
+
enabled: {
|
|
145
|
+
type: string;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
export default _default;
|
|
@@ -0,0 +1,142 @@
|
|
|
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
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var swagger_exports = {};
|
|
28
|
+
__export(swagger_exports, {
|
|
29
|
+
default: () => swagger_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(swagger_exports);
|
|
32
|
+
var swagger_default = {
|
|
33
|
+
openapi: "3.0.2",
|
|
34
|
+
info: {
|
|
35
|
+
title: "NocoBase API - Multi-portal plugin",
|
|
36
|
+
version: "1.0.0"
|
|
37
|
+
},
|
|
38
|
+
paths: {
|
|
39
|
+
"/roles/{roleName}/multiPortals:list": {
|
|
40
|
+
get: {
|
|
41
|
+
tags: ["roles.multiPortals"],
|
|
42
|
+
summary: "List Portals granted to a role",
|
|
43
|
+
description: "List existing custom Portals that the role is explicitly allowed to enter.",
|
|
44
|
+
parameters: [{ $ref: "#/components/parameters/RoleNamePath" }],
|
|
45
|
+
responses: {
|
|
46
|
+
200: {
|
|
47
|
+
description: "OK",
|
|
48
|
+
content: {
|
|
49
|
+
"application/json": {
|
|
50
|
+
schema: {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: {
|
|
53
|
+
data: {
|
|
54
|
+
type: "array",
|
|
55
|
+
items: { $ref: "#/components/schemas/PortalAccessTarget" }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"/roles/{roleName}/multiPortals:add": {
|
|
66
|
+
post: {
|
|
67
|
+
tags: ["roles.multiPortals"],
|
|
68
|
+
summary: "Grant Portal entry access to a role",
|
|
69
|
+
description: "Allow the role to enter one or more existing custom Portals by uid.",
|
|
70
|
+
parameters: [{ $ref: "#/components/parameters/RoleNamePath" }],
|
|
71
|
+
requestBody: {
|
|
72
|
+
required: true,
|
|
73
|
+
content: {
|
|
74
|
+
"application/json": {
|
|
75
|
+
schema: { $ref: "#/components/schemas/PortalAccessWrite" }
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
responses: {
|
|
80
|
+
200: { description: "OK" }
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"/roles/{roleName}/multiPortals:remove": {
|
|
85
|
+
post: {
|
|
86
|
+
tags: ["roles.multiPortals"],
|
|
87
|
+
summary: "Revoke Portal entry access from a role",
|
|
88
|
+
description: "Prevent the role from entering one or more existing custom Portals by uid.",
|
|
89
|
+
parameters: [{ $ref: "#/components/parameters/RoleNamePath" }],
|
|
90
|
+
requestBody: {
|
|
91
|
+
required: true,
|
|
92
|
+
content: {
|
|
93
|
+
"application/json": {
|
|
94
|
+
schema: { $ref: "#/components/schemas/PortalAccessWrite" }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
responses: {
|
|
99
|
+
200: { description: "OK" }
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
components: {
|
|
105
|
+
parameters: {
|
|
106
|
+
RoleNamePath: {
|
|
107
|
+
name: "roleName",
|
|
108
|
+
in: "path",
|
|
109
|
+
description: "Role name.",
|
|
110
|
+
required: true,
|
|
111
|
+
schema: { type: "string" }
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
schemas: {
|
|
115
|
+
PortalAccessWrite: {
|
|
116
|
+
type: "object",
|
|
117
|
+
properties: {
|
|
118
|
+
values: {
|
|
119
|
+
type: "array",
|
|
120
|
+
description: "Portal uids.",
|
|
121
|
+
items: { type: "string" },
|
|
122
|
+
minItems: 1,
|
|
123
|
+
uniqueItems: true
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
required: ["values"]
|
|
127
|
+
},
|
|
128
|
+
PortalAccessTarget: {
|
|
129
|
+
type: "object",
|
|
130
|
+
additionalProperties: true,
|
|
131
|
+
properties: {
|
|
132
|
+
uid: { type: "string" },
|
|
133
|
+
title: { type: "string" },
|
|
134
|
+
portalName: { type: "string" },
|
|
135
|
+
routePath: { type: "string" },
|
|
136
|
+
portalType: { type: "string" },
|
|
137
|
+
enabled: { type: "boolean" }
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
};
|
package/package.json
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-multi-portal",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0-alpha.1",
|
|
4
4
|
"main": "dist/server/index.js",
|
|
5
5
|
"nocobase": {
|
|
6
6
|
"supportedVersions": [
|
|
7
7
|
"2.x"
|
|
8
|
-
]
|
|
9
|
-
"editionLevel": 3
|
|
8
|
+
]
|
|
10
9
|
},
|
|
11
10
|
"displayName": "Portal manager",
|
|
12
11
|
"displayName.zh-CN": "Portal 管理",
|
|
13
|
-
"description": "Provides
|
|
14
|
-
"description.zh-CN": "
|
|
12
|
+
"description": "Provides built-in Portal registration, entry access, and route permissions for Client V2.",
|
|
13
|
+
"description.zh-CN": "为 Client V2 提供内置 Portal 注册、入口访问与路由权限管理。",
|
|
15
14
|
"devDependencies": {
|
|
16
15
|
"@ant-design/icons": "5.x",
|
|
17
|
-
"@nocobase/plugin-ui-layout": "2.
|
|
16
|
+
"@nocobase/plugin-ui-layout": "2.4.0-alpha.1",
|
|
18
17
|
"ahooks": "3.x",
|
|
19
18
|
"antd": "5.x",
|
|
20
19
|
"react": "^18.2.0",
|
|
@@ -30,5 +29,5 @@
|
|
|
30
29
|
"@nocobase/server": "2.x",
|
|
31
30
|
"@nocobase/test": "2.x"
|
|
32
31
|
},
|
|
33
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "82ecd3aed067e4cc98c32e7a0039b6e55cee76a7"
|
|
34
33
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
"use strict";(self.webpackChunk_nocobase_plugin_multi_portal_client_v2=self.webpackChunk_nocobase_plugin_multi_portal_client_v2||[]).push([["354"],{833:function(t,e,r){r.r(e),r.d(e,{MultiPortalMobileChildPageModel:function(){return _},MultiPortalMobileChildPageTabModel:function(){return R},MultiPortalMobileLayoutModel:function(){return M},MultiPortalMobileRootPageModel:function(){return m},MultiPortalMobileRootPageTabModel:function(){return k}});var n=r(485),o=r(69),u=r(133);function i(t,e,r,n,o,u,i){try{var l=t[u](i),c=l.value}catch(t){r(t);return}l.done?e(c):Promise.resolve(c).then(n,o)}function l(t,e,r){return e=p(e),function(t,e){if(e&&("object"===v(e)||"function"==typeof e))return e;if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t,d()?Reflect.construct(e,r||[],p(t).constructor):e.apply(t,r))}function c(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function f(t,e,r){return e&&a(t.prototype,e),r&&a(t,r),t}function s(t,e,r){return(s="u">typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=p(t)););return t}(t,e);if(n){var o=Object.getOwnPropertyDescriptor(n,e);return o.get?o.get.call(r||t):o.value}})(t,e,r||t)}function p(t){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function b(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&O(t,e)}function y(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),n.forEach(function(e){var n;n=r[e],e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n})}return t}function h(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e.push.apply(e,r)}return e})(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}function O(t,e){return(O=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function v(t){return t&&"u">typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function d(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(d=function(){return!!t})()}function P(t){var e,r=null==(e=t.context)?void 0:e.layout,n=null==r?void 0:r.uid;if("string"==typeof n&&n.trim())return(0,u.Cp)(n)||n}function g(t,e){if(!(t&&(void 0===t?"undefined":v(t))==="object"&&!Array.isArray(t)))return t;t.uiLayouts,t.multiPortals;var r=function(t,e){if(null==t)return{};var r,n,o,u={};if("u">typeof Reflect&&Reflect.ownKeys){for(o=0,r=Reflect.ownKeys(Object(t));o<r.length;o++)n=r[o],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(u[n]=t[n]);return u}if(u=function(t,e){if(null==t)return{};var r,n,o={},u=Object.getOwnPropertyNames(t);for(n=0;n<u.length;n++)r=u[n],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r]);return o}(t,e),Object.getOwnPropertySymbols)for(o=0,r=Object.getOwnPropertySymbols(t);o<r.length;o++)n=r[o],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(u[n]=t[n]);return u}(t,["uiLayouts","multiPortals"]);return e?h(y({},r),{multiPortals:[e]}):r}function j(t,e,r){var n,o=null==(n=e.props)?void 0:n.route;return h(y({},e),{use:r,props:h(y({},e.props),{route:g(o,P(t))})})}function w(t){t.setProps("route",g(t.props.route,P(t)))}var M=function(t){function e(){return c(this,e),l(this,e,arguments)}return b(e,t),f(e,[{key:"layout",get:function(){var t=s(p(e.prototype),"layout",this);return h(y({},t),{uid:(0,u.wj)(t.uid)})}}]),e}(o.MobileLayoutModel),m=function(t){function e(t){c(this,e);var r=l(this,e,[t]),n=r.createPageTabModelOptions.bind(r);return r.createPageTabModelOptions=function(){return j(r,n(),"MultiPortalMobileRootPageTabModel")},r}return b(e,t),e}(o.MobileRootPageModel),_=function(t){function e(t){c(this,e);var r=l(this,e,[t]),n=r.createPageTabModelOptions.bind(r);return r.createPageTabModelOptions=function(){return j(r,n(),"MultiPortalMobileChildPageTabModel")},r}return b(e,t),e}(o.MobileChildPageModel),k=function(t){function e(){return c(this,e),l(this,e,arguments)}return b(e,t),f(e,[{key:"save",value:function(){var t,r=this,n=this;return(t=function(){return function(t,e){var r,n,o,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:c(0)}),l(i,"throw",{value:c(1)}),l(i,"return",{value:c(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;function c(l){return function(c){var a=[l,c];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(u=0)),u;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,n=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=e.call(t,u)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}}(this,function(t){switch(t.label){case 0:return w(this),[4,s(p(e.prototype),"save",r).call(n)];case 1:return t.sent(),w(this),[2]}})},function(){var e=this,r=arguments;return new Promise(function(n,o){var u=t.apply(e,r);function l(t){i(u,n,o,l,c,"next",t)}function c(t){i(u,n,o,l,c,"throw",t)}l(void 0)})}).call(this)}}]),e}(n.RootPageTabModel),R=function(t){function e(){return c(this,e),l(this,e,arguments)}return b(e,t),f(e,[{key:"onInit",value:function(t){s(p(e.prototype),"onInit",this).call(this,t),w(this)}}]),e}(n.ChildPageTabModel)}}]);
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
"use strict";(self.webpackChunk_nocobase_plugin_multi_portal_client_v2=self.webpackChunk_nocobase_plugin_multi_portal_client_v2||[]).push([["499"],{918:function(t,e,n){n.r(e),n.d(e,{PortalEntryActionModel:function(){return I}});var r=n(485),i=n(694),o=n(143),a=n(337),l=n(756);function u(t){var e=null==t?void 0:t.trim();return e&&"/"!==e?"/".concat(e.replace(/^\/+/,"")):"/"}function c(t){var e=u(t).replace(/\/+$/,"");return""===e||"/"===e?"":e}function s(t,e){var n=c(t),r=u(e);return!n||r===n||r.startsWith("".concat(n,"/"))?r:"".concat(n).concat(r)}function p(t){return c((function(t){var e,n,i,o;return"function"==typeof(null==t?void 0:t.getPublicPath)?c((0,r.getV2EffectiveBasePath)({getPublicPath:t.getPublicPath,router:{getBasename:function(){var e,n,r;return(null==(n=t.router)||null==(e=n.getBasename)?void 0:e.call(n))||(null==(r=t.router)?void 0:r.basename)}}})):c((null==t||null==(n=t.router)||null==(e=n.getBasename)?void 0:e.call(n))||(null==t||null==(i=t.router)?void 0:i.basename)||(null==t||null==(o=t.getPublicPath)?void 0:o.call(t)))})(t).replace(/\/(?:apps|_app)\/[^/]+$/,"")||"")}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function y(t,e,n,r,i,o,a){try{var l=t[o](a),u=l.value}catch(t){n(t);return}l.done?e(u):Promise.resolve(u).then(r,i)}function h(t){return function(){var e=this,n=arguments;return new Promise(function(r,i){var o=t.apply(e,n);function a(t){y(o,r,i,a,l,"next",t)}function l(t){y(o,r,i,a,l,"throw",t)}a(void 0)})}}function v(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function b(t,e,n){return(b="u">typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=d(t)););return t}(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(n||t):i.value}})(t,e,n||t)}function d(t){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function P(t,e){return(P=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function m(t){return function(t){if(Array.isArray(t))return f(t)}(t)||function(t){if("u">typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t){if(t){if("string"==typeof t)return f(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);if("Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e)return Array.from(e);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return f(t,void 0)}}(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(g=function(){return!!t})()}function A(t,e){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:u(0)}),l(a,"throw",{value:u(1)}),l(a,"return",{value:u(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function u(l){return function(u){var c=[l,u];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,r=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===c[0]||2===c[0])){o=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){o.label=c[1];break}if(6===c[0]&&o.label<i[1]){o.label=i[1],i=c;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(c);break}i[2]&&o.ops.pop(),o.trys.pop();continue}c=e.call(t,o)}catch(t){c=[6,t],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var k="PartitionOutlined",T="buttonSettings",E="general";function O(t){return(null==t?void 0:t.title)||(null==t?void 0:t.routePath)}function w(t,e,n){if(t)return"main"===t.appName?(null==n?void 0:n("Main application"))||"Main":(null==e?void 0:e.title)||(null==e?void 0:e.name)||t.appName}function _(t,e,n){var r=O(t),i=w(t,e,n);return i&&r?"".concat(i," / ").concat(r):r}function j(t,e,n){var r=O(t),i=w(t,e,n);return i&&r?"".concat(i," / ").concat(r):r}function R(t){return t.entryPortalTitle||O(t.entryPortal)}function S(t,e){return t.entryPortalTargetTitle||j(t.entryPortal,t.entryPortalApp,e)||R(t)}function x(t,e){if(t)return e.portals.find(function(e){return t.appName===e.appName&&(!!t.uid&&!!e.uid&&t.uid===e.uid||t.routePath===e.routePath)})}function D(t){return m(new Set(t.filter(function(t){return!!t})))}var I=function(t){var e;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function n(){var t,e,r;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,r=arguments,e=d(e),v(t=function(t,e){var n;if(e&&("object"==((n=e)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof e))return e;if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(this,g()?Reflect.construct(e,r||[],d(this).constructor):e.apply(this,r)),"entryActionAvailability","available"),v(t,"availabilityRequest",void 0),v(t,"disposeAppPortalsReaction",void 0),v(t,"defaultProps",{type:"default",title:(0,o.MZ)("Portal"),icon:k}),v(t,"enableEditType",!1),v(t,"enableEditDanger",!1),v(t,"enableEditTitle",!0),v(t,"enableEditIconOnly",!1),t}return n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),t&&P(n,t),e=[{key:"onInit",value:function(t){b(d(n.prototype),"onInit",this).call(this,t),(0,i.define)(this,{entryActionAvailability:i.observable.ref}),this.syncEntryTitle(),this.checkEntryPortalAvailability()}},{key:"afterAddAsSubModel",value:function(){var t=this,e=this;return h(function(){return A(this,function(r){switch(r.label){case 0:return[4,b(d(n.prototype),"afterAddAsSubModel",t).call(e)];case 1:return r.sent(),this.syncEntryTitle(),[4,this.checkEntryPortalAvailability()];case 2:return r.sent(),[2]}})}).call(this)}},{key:"onMount",value:function(){var t=this;if(b(d(n.prototype),"onMount",this).call(this),!this.disposeAppPortalsReaction){var e=this.context.app;if(e){var r=(0,a.G)(e);this.disposeAppPortalsReaction=(0,i.reaction)(function(){return r.revision},function(){t.checkEntryPortalAvailability()})}}}},{key:"onUnmount",value:function(){var t;b(d(n.prototype),"onUnmount",this).call(this),null==(t=this.disposeAppPortalsReaction)||t.call(this),this.disposeAppPortalsReaction=void 0}},{key:"setProps",value:function(t,e){"string"==typeof t?b(d(n.prototype),"setProps",this).call(this,t,e):b(d(n.prototype),"setProps",this).call(this,t),this.syncEntryTitle()}},{key:"getTitle",value:function(){return b(d(n.prototype),"getTitle",this).call(this)||R(this.props)}},{key:"getTitleFieldDescription",value:function(){var t,e,n,r,i=(n=S(t=this.props,this.t),r=null==(e=t.entryPortal)?void 0:e.routePath,n&&r?"".concat(n," (").concat(r,")"):n||r);return i?"".concat(this.context.t("Target portal",(0,o.Dj)()),": ").concat(i):void 0}},{key:"isEntryActionAvailable",value:function(){return"available"===this.entryActionAvailability}},{key:"getEntryActionUnavailableMessage",value:function(){if("unavailable"===this.entryActionAvailability)return this.context.t("This entry is currently unavailable. Please check the application status.",(0,o.Dj)())}},{key:"isDefaultTitle",value:function(t){return"string"==typeof t&&[this.defaultProps.title,this.context.t("Portal",(0,o.Dj)()),"Portal"].filter(Boolean).includes(t)}},{key:"isDefaultIcon",value:function(t){return"string"==typeof t&&t===k}},{key:"isAutoTitle",value:function(t,e){return"string"==typeof t&&e.includes(t)}},{key:"syncEntryTitle",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=R(this.props),i=D([O(this.props.entryPortal),this.props.entryPortalTitle,S(this.props,this.t)].concat(m(e)));r&&(!this.props.title||this.isDefaultTitle(this.props.title)||this.isAutoTitle(this.props.title,i))&&b(d(n.prototype),"setProps",this).call(this,"title",r);var o=(null==(t=this.props.entryPortal)?void 0:t.icon)||k;o&&(!this.props.icon||this.isDefaultIcon(this.props.icon))&&b(d(n.prototype),"setProps",this).call(this,"icon",o),r&&this.syncTitleStepParams(r,o,i)}},{key:"syncTitleStepParams",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=this.getStepParams(T,E)||{},i={};(!r.title||this.isDefaultTitle(r.title)||this.isAutoTitle(r.title,n))&&(i.title=t),e&&(!r.icon||this.isDefaultIcon(r.icon))&&(i.icon=e),Object.keys(i).length&&this.setStepParams(T,E,i)}},{key:"onClick",value:function(){var t=this.props.entryPortal;if(t&&!this.hidden&&"available"===this.entryActionAvailability){var e=this.context.app,n=e?(0,a.G)(e).payload:void 0,r=n&&x(t,n)||t,i=(null==n?void 0:n.apps.find(function(t){return t.name===r.appName}))||this.props.entryPortalApp,o=function(t,e,n){if("main"===e.appName)return(c=a=e.routePath.trim(),/^[a-z][a-z\d+\-.]*:\/\//i.test(c)||c.startsWith("//"))?a:s(p(t),a);var r=u(e.routePath),i=(null==n?void 0:n.ssoEnabled)===!0,o=e.appName===((null==t?void 0:t.name)||"main");if(null==n?void 0:n.cname){var a,c,f,y=(f=n.cname,/^https?:\/\//i.test(f)||f.startsWith("//")?f:"//".concat(f));return i?"".concat(y.replace(/\/+$/,""),"/app-sso?redirect=").concat(encodeURIComponent(r)):"".concat(y.replace(/\/+$/,"")).concat(u(r))}if(o&&!i)return(0,l.u)(t,e.routePath,e.portalType);var h=i?"/apps/".concat(e.appName,"/app-sso?redirect=").concat(encodeURIComponent(r)):"/apps/".concat(e.appName).concat(r);return(null==t?void 0:t.getRouteUrl)?t.getRouteUrl(h):s(p(t),h)}(e,r,i);window.open(o,"_blank","noopener,noreferrer")}}},{key:"t",get:function(){var t=this;return function(e){return String(t.context.t(e,(0,o.Dj)()))}}},{key:"setEntryActionAvailability",value:function(t){this.entryActionAvailability!==t&&(this.entryActionAvailability=t)}},{key:"getAvailabilityForExistingPortal",value:function(t,e){var n,r,i,o,a=(n=t.appName,r=this.props.entryPortalApp,e.apps.find(function(t){return t.name===n})||((null==r?void 0:r.name)===n?r:void 0));return!(o=!(i=null==a?void 0:a.status)?[]:"string"==typeof i?[i]:Object.values(i).filter(function(t){return"string"==typeof t})).length||o.includes("running")?"available":"unavailable"}},{key:"syncCurrentPortal",value:function(t,e){var r=this.props.entryPortal,i=this.props.entryPortalApp,o=R(this.props),a=S(this.props,this.t),l=_(r,i,this.t),u=e.apps.find(function(e){return e.name===t.appName})||i,c=e.apps.length>0||D(e.portals.map(function(t){return t.appName})).length>1||o===l?_(t,u,this.t):O(t),s=j(t,u,this.t);b(d(n.prototype),"setProps",this).call(this,{entryPortal:t,entryPortalApp:u,entryPortalTitle:c,entryPortalTargetTitle:s}),this.syncEntryTitle(D([o,a,l,O(r)]))}},{key:"checkEntryPortalAvailability",value:function(){var t=this;return this.availabilityRequest||(this.availabilityRequest=this.loadEntryPortalAvailability().finally(function(){t.availabilityRequest=void 0})),this.availabilityRequest}},{key:"loadEntryPortalAvailability",value:function(){return h(function(){var t,e,n,r;return A(this,function(i){switch(i.label){case 0:if(t=this.props.entryPortal,e=this.context.app,!t||!e)return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,(0,a.G)(e).load()];case 2:return n=i.sent(),(r=x(t,n))?(this.setEntryActionAvailability(this.getAvailabilityForExistingPortal(r,n)),this.syncCurrentPortal(r,n)):this.setEntryActionAvailability("unavailable"),[3,4];case 3:return i.sent(),[2];case 4:return[2]}})}).call(this)}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(n.prototype,e),n}(r.ActionModel);I.define({label:(0,o.MZ)("Portal")})}}]);
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
"use strict";(self.webpackChunk_nocobase_plugin_multi_portal_client_v2=self.webpackChunk_nocobase_plugin_multi_portal_client_v2||[]).push([["778"],{177:function(e,t,r){r.r(t),r.d(t,{default:function(){return A}});var n=r(485),u=r(694),a=r(625),o=r(59),i=r(155),l=r.n(i),c=r(143);function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function d(e,t,r,n,u,a,o){try{var i=e[a](o),l=i.value}catch(e){r(e);return}i.done?t(l):Promise.resolve(l).then(n,u)}function f(e){return function(){var t=this,r=arguments;return new Promise(function(n,u){var a=e.apply(t,r);function o(e){d(a,n,u,o,i,"next",e)}function i(e){d(a,n,u,o,i,"throw",e)}o(void 0)})}}function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function p(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function m(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,u=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=u){var a=[],o=!0,i=!1;try{for(u=u.call(e);!(o=(r=u.next()).done)&&(a.push(r.value),!t||a.length!==t);o=!0);}catch(e){i=!0,n=e}finally{try{o||null==u.return||u.return()}finally{if(i)throw n}}return a}}(e,t)||b(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||b(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function b(e,t){if(e){if("string"==typeof e)return s(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return s(e,t)}}function g(e,t){var r,n,u,a={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:l(0)}),i(o,"throw",{value:l(1)}),i(o,"return",{value:l(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function l(i){return function(l){var c=[i,l];if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(u=2&c[0]?n.return:c[0]?n.throw||((u=n.return)&&u.call(n),0):n.next)&&!(u=u.call(n,c[1])).done)return u;switch(n=0,u&&(c=[2&c[0],u.value]),c[0]){case 0:case 1:u=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(u=(u=a.trys).length>0&&u[u.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!u||c[1]>u[0]&&c[1]<u[3])){a.label=c[1];break}if(6===c[0]&&a.label<u[1]){a.label=u[1],u=c;break}if(u&&a.label<u[2]){a.label=u[2],a.ops.push(c);break}u[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],n=0}finally{r=u=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function w(e){return e&&(void 0===e?"undefined":v(e))==="object"?{data:Array.isArray(e.data)?e.data:[]}:{}}function S(e){return Array.isArray(e)?e.flatMap(function(e){return[e.id].concat(y(S(e.children)))}):[]}function k(e){var t=new Set;return e.filter(function(e){return!t.has(e)&&(t.add(e),!0)})}function M(e,t){return"string"!=typeof e?t("Unnamed"):t(e)||t("Unnamed")}function A(e){var t,r=(0,u.useFlowContext)(),s=(0,c.kj)(),d=o.theme.useToken().token,b=e.activeRole,A="multi-portals"===e.activeKey,P=m((0,i.useState)([]),2),I=P[0],x=P[1],O=m((0,i.useState)(),2),j=O[0],C=O[1],E=m((0,i.useState)([]),2),R=E[0],N=E[1],T=m((0,i.useState)(),2),_=T[0],D=T[1],F=m((0,i.useState)(!1),2),z=F[0],U=F[1],q=m((0,i.useState)(""),2),K=q[0],L=q[1],B=(0,i.useMemo)(function(){return b?r.api.resource("roles.multiPortals",b.name):void 0},[r.api,b]),G=(0,i.useMemo)(function(){return r.api.resource("rolesMultiPortalDesktopRoutes")},[r.api]),$=(0,i.useMemo)(function(){return r.api.resource("rolesMultiPortalRoutePolicies")},[r.api]),H=(0,a.useRequest)(function(){return f(function(){var e,t;return g(this,function(n){switch(n.label){case 0:return[4,r.api.request({url:"multiPortals:listEnabled",method:"get",skipNotify:!0})];case 1:return[2,null!=(e=w(null==(t=n.sent())?void 0:t.data).data)?e:[]]}})})()},{ready:A,refreshDeps:[A]}),J=(0,a.useRequest)(function(){return f(function(){var e,t;return g(this,function(r){switch(r.label){case 0:if(!B)return[2,[]];return[4,B.list({paginate:!1})];case 1:return[2,(null!=(e=w(null==(t=r.sent())?void 0:t.data).data)?e:[]).map(function(e){return e.uid}).filter(function(e){return"string"==typeof e&&!!e})]}})})()},{ready:A&&!!B,refreshDeps:[A,null==b?void 0:b.name],onSuccess:function(e){x(e)}}),Q=(0,i.useMemo)(function(){var e;return null==(e=H.data)?void 0:e.find(function(e){return e.uid===j})},[H.data,j]),V=Q?M(Q.title,s):"",W=Q?s("Configure routes permissions for {{portal}}",{portal:V}):s("Routes permissions"),X=(0,a.useRequest)(function(){return f(function(){var e,t;return g(this,function(n){switch(n.label){case 0:if(!j)return[2,[]];return[4,r.api.request({url:"desktopRoutes:listRolePermissionTargets",method:"get",params:{portal:j},skipNotify:!0})];case 1:var u;return[2,null!=(e=(!(u=null==(t=n.sent())?void 0:t.data)||(void 0===u?"undefined":v(u))!=="object"?{}:{data:Array.isArray(u.data)?u.data:[]}).data)?e:[]]}})})()},{ready:A&&!!j,refreshDeps:[A,j]}),Y=(0,i.useMemo)(function(){return function e(t,r){return Array.isArray(t)?t.map(function(t){var n,u,a=e(t.children,t.id);return{id:t.id,title:t.title,hidden:t.hidden,routePath:"string"==typeof(u=null==(n=t.options)?void 0:n.path)&&u.trim()?u.trim():void 0,parentId:r,children:a.length?a:void 0}}):[]}(X.data)},[X.data]),Z=(0,i.useMemo)(function(){return S(Y)},[Y]),ee=(0,i.useMemo)(function(){return function e(t){return t.flatMap(function(t){var r;return[t].concat(y(e(null!=(r=t.children)?r:[])))})}(Y)},[Y]),et=(0,i.useMemo)(function(){return new Map(ee.map(function(e){return[e.id,e]}))},[ee]),er=(0,i.useMemo)(function(){return function e(t,r,n){var u=r.trim().toLowerCase();return u?t.reduce(function(t,r){var a,o,i,l=e(null!=(a=r.children)?a:[],u,n),c=M(r.title,n).toLowerCase(),s=null!=(o=null==(i=r.routePath)?void 0:i.toLowerCase())?o:"";return(c.includes(u)||s.includes(u)||l.length)&&t.push(p(h({},r),{children:l.length?l:void 0})),t},[]):t}(function e(t){return t.reduce(function(t,r){if(r.hidden)return t;var n,u=e(null!=(n=r.children)?n:[]);return t.push(p(h({},r),{children:u.length?u:void 0})),t},[])}(Y),K,s)},[Y,K,s]),en=(0,i.useMemo)(function(){return S(er)},[er]),eu=(0,i.useMemo)(function(){return function e(t,r){return Array.isArray(t)?k(t.flatMap(function(t){var n,u=null!=(n=r.get(t.id))?n:t;return[t.id].concat(y(S(u.children)),y(e(t.children,r)))})):[]}(er,et)},[et,er]),ea=(0,i.useMemo)(function(){var e=new Set(R);return en.filter(function(t){return e.has(t)}).length},[R,en]),eo=X.error?s("Failed to load routes"):K.trim()?s("No matching routes"):s("No routes"),ei=(0,a.useRequest)(function(){return f(function(){var e;return g(this,function(t){switch(t.label){case 0:if(!b||!j)return[2,[]];return[4,G.list({paginate:!1,filter:{roleName:b.name,multiPortalUid:j}})];case 1:var r;return[2,(!(r=null==(e=t.sent())?void 0:e.data)||(void 0===r?"undefined":v(r))!=="object"?[]:Array.isArray(r.data)?r.data:[]).map(function(e){return e.desktopRouteId}).filter(function(e){return"number"==typeof e})]}})})()},{ready:A&&!!b&&!!j,refreshDeps:[A,null==b?void 0:b.name,j],onSuccess:function(e){N(e)}}),el=(0,a.useRequest)(function(){return f(function(){var e;return g(this,function(t){switch(t.label){case 0:if(!b||!j)return[2,void 0];return[4,$.list({paginate:!1,filter:{roleName:b.name,multiPortalUid:j}})];case 1:return[2,function(e){if(e&&(void 0===e?"undefined":v(e))==="object")return Array.isArray(e.data)?e.data[0]:void 0}(null==(e=t.sent())?void 0:e.data)]}})})()},{ready:A&&!!b&&!!j,refreshDeps:[A,null==b?void 0:b.name,j],onSuccess:function(e){D(e),U(!!(null==e?void 0:e.allowNewMenu))}});(0,i.useEffect)(function(){C(void 0),N([]),D(void 0),U(!1),L("")},[null==b?void 0:b.name]),(0,i.useEffect)(function(){N([]),D(void 0),U(!1),L("")},[j]);var ec=(0,a.useMemoizedFn)(function(e){return f(function(){var t;return g(this,function(n){switch(n.label){case 0:var u,a;if(!B)return[2];u=new Set(I),a=new Set(e),t={add:e.filter(function(e){return!u.has(e)}),remove:I.filter(function(e){return!a.has(e)})},n.label=1;case 1:if(n.trys.push([1,7,,9]),!t.remove.length)return[3,3];return[4,B.remove({values:t.remove})];case 2:n.sent(),n.label=3;case 3:if(!t.add.length)return[3,5];return[4,B.add({values:t.add})];case 4:n.sent(),n.label=5;case 5:return[4,J.refreshAsync()];case 6:return n.sent(),x(e),r.message.success(s("Saved successfully")),[3,9];case 7:return n.sent(),[4,J.refreshAsync().catch(function(){})];case 8:return n.sent(),[3,9];case 9:return[2]}})})()}),es=(0,a.useMemoizedFn)(function(e){return f(function(){return g(this,function(t){switch(t.label){case 0:return[4,ec(I.includes(e.uid)?I.filter(function(t){return t!==e.uid}):y(I).concat([e.uid]))];case 1:return t.sent(),[2]}})})()}),ed=(0,a.useMemoizedFn)(function(t){return f(function(){var n;return g(this,function(u){switch(u.label){case 0:if(!b)return[2];u.label=1;case 1:return u.trys.push([1,3,,4]),[4,r.api.resource("roles").update({filterByTk:b.name,values:t})];case 2:return u.sent(),[3,4];case 3:return u.sent(),[2];case 4:return null==(n=e.onRoleChange)||n.call(e,h({},b,t)),r.message.success(s("Saved successfully")),[2]}})})()}),ef=(0,i.useMemo)(function(){return[{dataIndex:"title",title:s("Portal"),render:function(e){return M(e,s)}},{dataIndex:"accessible",title:s("Allow access"),render:function(e,t){var r=M(t.title,s);return l().createElement(o.Checkbox,{"aria-label":s("Allow access to {{portal}}",{portal:r}),checked:I.includes(t.uid),onChange:function(){return es(t)}})}},{dataIndex:"routePermissions",title:s("Routes permissions"),render:function(e,t){var r=M(t.title,s);return l().createElement(o.Button,{"aria-label":s("Configure routes permissions for {{portal}}",{portal:r}),type:"link",onClick:function(){return C(t.uid)}},s("Configure"))}}]},[I,s,es]),eh=(0,a.useMemoizedFn)(function(e){return f(function(){var t,n,u,a,o,i,l,c;return g(this,function(d){switch(d.label){case 0:var f,h,p,m,v;if(!b||!j)return[2];h=new Set((f={currentRouteIds:Z,nextSelectedIds:e,selectedIds:R}).currentRouteIds),p=new Set(f.selectedIds.filter(function(e){return h.has(e)})),m=new Set(f.nextSelectedIds.filter(function(e){return h.has(e)})),t={add:(v=k(y(f.currentRouteIds).concat(y(f.selectedIds),y(f.nextSelectedIds)))).filter(function(e){return h.has(e)&&m.has(e)&&!p.has(e)}),remove:v.filter(function(e){return h.has(e)&&p.has(e)&&!m.has(e)})},d.label=1;case 1:if(d.trys.push([1,13,,15]),!t.remove.length)return[3,3];return[4,G.destroy({filter:{roleName:b.name,multiPortalUid:j,desktopRouteId:t.remove}})];case 2:d.sent(),d.label=3;case 3:n=!0,u=!1,a=void 0,d.label=4;case 4:d.trys.push([4,9,10,11]),o=t.add[Symbol.iterator](),d.label=5;case 5:if(n=(i=o.next()).done)return[3,8];return l=i.value,[4,G.create({values:{roleName:b.name,multiPortalUid:j,desktopRouteId:l}})];case 6:d.sent(),d.label=7;case 7:return n=!0,[3,5];case 8:return[3,11];case 9:return c=d.sent(),u=!0,a=c,[3,11];case 10:try{n||null==o.return||o.return()}finally{if(u)throw a}return[7];case 11:return[4,ei.refreshAsync()];case 12:return d.sent(),N(e),r.message.success(s("Saved successfully")),[3,15];case 13:return d.sent(),[4,ei.refreshAsync().catch(function(){})];case 14:return d.sent(),[3,15];case 15:return[2]}})})()}),ep=(0,a.useMemoizedFn)(function(e){return f(function(){return g(this,function(t){switch(t.label){case 0:if(!b||!j)return[2];t.label=1;case 1:if(t.trys.push([1,7,,9]),!_)return[3,3];return[4,$.update({filter:{roleName:b.name,multiPortalUid:j},values:{allowNewMenu:e}})];case 2:return t.sent(),[3,5];case 3:return[4,$.create({values:{roleName:b.name,multiPortalUid:j,allowNewMenu:e}})];case 4:t.sent(),t.label=5;case 5:return[4,el.refreshAsync()];case 6:return t.sent(),U(e),r.message.success(s("Saved successfully")),[3,9];case 7:return t.sent(),[4,el.refreshAsync().catch(function(){})];case 8:return t.sent(),[3,9];case 9:return[2]}})})()}),em=(0,a.useMemoizedFn)(function(){return f(function(){var e,t;return g(this,function(r){switch(r.label){case 0:return e=new Set(R),t=new Set(en),[4,eh(en.length&&en.every(function(t){return e.has(t)})?R.filter(function(e){return!t.has(e)&&!eu.includes(e)}):k(y(R).concat(y(eu))))];case 1:return r.sent(),[2]}})})()}),ey=(0,a.useMemoizedFn)(function(e){return f(function(){var t,r,n,u,a,o,i;return g(this,function(l){switch(l.label){case 0:return r=R.includes(e.id),n=S((null!=(t=et.get(e.id))?t:e).children),u=r?R.filter(function(t){return t!==e.id&&!n.includes(t)}):k(y(R).concat([e.id],y(n))),e.parentId&&(i=null==(o=et.get(e.parentId))||null==(a=o.children)?void 0:a.some(function(e){return u.includes(e.id)}),r&&!i&&(u=u.filter(function(t){return t!==e.parentId})),r||u.includes(e.parentId)||u.push(e.parentId)),[4,eh(u)];case 1:return l.sent(),[2]}})})()}),ev=(0,i.useMemo)(function(){return[{dataIndex:"title",title:s("Route name"),render:function(e){return M(e,s)}},{dataIndex:"accessible",title:l().createElement(o.Checkbox,{checked:!!en.length&&ea===en.length,disabled:!en.length,indeterminate:ea>0&&ea<en.length,onChange:em},s("Allow access")),render:function(e,t){var r=M(t.title,s);return l().createElement(o.Checkbox,{"aria-label":s("Allow access to {{route}}",{route:r}),checked:R.includes(t.id),onChange:function(){return ey(t)}})}}]},[R,em,s,ey,en.length,ea]);return b?l().createElement(l().Fragment,null,l().createElement(o.Space,{direction:"vertical",size:d.marginSM,style:{width:"100%"}},l().createElement(o.Typography.Text,{strong:!0},s("Portals")),l().createElement(o.Checkbox,{checked:!!b.allowNewMultiPortal,onChange:function(e){ed({allowNewMultiPortal:e.target.checked})}},s("New portals are allowed to be accessed by default")),l().createElement(n.Table,{rowKey:"uid",loading:H.loading||J.loading,pagination:!1,columns:ef,dataSource:null!=(t=H.data)?t:[],locale:{emptyText:H.error?s("Failed to load portals"):s("No portals")}})),l().createElement(o.Drawer,{title:W,"aria-label":W,width:d.screenLG,open:A&&!!Q,onClose:function(){return C(void 0)}},Q?l().createElement(o.Space,{direction:"vertical",size:d.marginSM,style:{width:"100%"}},l().createElement(o.Checkbox,{checked:z,onChange:function(e){return ep(e.target.checked)}},s("New routes are allowed to be accessed by default")),l().createElement(o.Input.Search,{allowClear:!0,"aria-label":s("Search routes"),placeholder:s("Search routes"),value:K,onChange:function(e){return L(e.target.value)}}),l().createElement(n.Table,{rowKey:"id",loading:X.loading||ei.loading||el.loading,pagination:!1,expandable:{defaultExpandAllRows:!1,expandedRowKeys:K.trim()?en:void 0},columns:ev,dataSource:er,locale:{emptyText:eo}})):null)):l().createElement(o.Typography.Text,{type:"secondary"},s("Select a role to configure permissions"))}}}]);
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
"use strict";(self.webpackChunk_nocobase_plugin_multi_portal_client_v2=self.webpackChunk_nocobase_plugin_multi_portal_client_v2||[]).push([["845"],{924:function(e,t,r){r.r(t),r.d(t,{createMultiPortal:function(){return P},deleteMultiPortals:function(){return I},updateMultiPortal:function(){return T}});var n=r(375),a=r(485),l=r(694),o=r(625),i=r(59),u=r(155),c=r.n(u),s=r(337),d=r(143),p=r(756);function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t,r,n,a,l,o){try{var i=e[l](o),u=i.value}catch(e){r(e);return}i.done?t(u):Promise.resolve(u).then(n,a)}function y(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var l=e.apply(t,r);function o(e){f(l,n,a,o,i,"next",e)}function i(e){f(l,n,a,o,i,"throw",e)}o(void 0)})}}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function h(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(r=a.next()).done)&&(l.push(r.value),!t||l.length!==t);o=!0);}catch(e){i=!0,n=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw n}}return l}}(e,t)||E(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function E(e,t){if(e){if("string"==typeof e)return m(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return m(e,t)}}function S(e,t){var r,n,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:u(0)}),i(o,"throw",{value:u(1)}),i(o,"return",{value:u(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function u(i){return function(u){var c=[i,u];if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(l=0)),l;)try{if(r=1,n&&(a=2&c[0]?n.return:c[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,c[1])).done)return a;switch(n=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,n=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],n=0}finally{r=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function w(e,t){if(e&&(void 0===e?"undefined":v(e))==="object")return e[t]}function k(e){return"string"==typeof e&&e?e:void 0}function P(e){return y(function(){return S(this,function(t){switch(t.label){case 0:return[4,e.resource.create({values:e.values})];case 1:return t.sent(),e.onSubmitted(),[2]}})})()}function T(e){return y(function(){return S(this,function(t){switch(t.label){case 0:return[4,e.resource.update({filterByTk:e.filterByTk,values:e.values})];case 1:return t.sent(),e.onSubmitted(),[2]}})})()}function I(e){return y(function(){return S(this,function(t){switch(t.label){case 0:return[4,e.resource.destroy({filterByTk:e.filterByTk})];case 1:return t.sent(),e.onDeleted(),[2]}})})()}var F="no-code",O=["no-code","ai"],j="nocobase",A="main",x={portalType:F,enabled:!0},C={paddingInline:0},B={alignItems:"flex-start"},M="multi-portal-described-radio",D="\n.".concat(M," .ant-radio {\n align-self: flex-start;\n margin-top: 3px;\n}\n"),_=new Set(["__default_portal__"]),q=/^[a-z0-9_-]+$/,L=c().forwardRef(function(e,t){return c().createElement("div",{ref:t},c().createElement(a.IconPicker,e))});function N(e){var t=null==e?void 0:e.trim();if(t&&!q.test(t))return"Portal name can only contain lowercase letters, numbers, hyphens, and underscores"}function R(e){return"string"!=typeof e?null:e.trim()||null}function z(e){var t=R(e);return t&&O.some(function(e){return e===t})?t:F}function U(e){var t=R(e);return"nocobase"===t||"git"===t?t:j}function G(e){var t,r=e.portalName.trim(),n=N(r);if(n)throw Error(n);return h(b({},e),{title:e.title.trim(),uid:e.uid.trim(),portalType:z(e.portalType),portalName:r,routePath:"/".concat(r),icon:"string"!=typeof(t=e.icon)?null:t.trim()||null,options:function(e){if("ai"===z(e.portalType)){var t,r=U(e.sourceStorage);return"git"!==r?{sourceStorage:r}:{sourceStorage:r,git:{repo:(null!=(t=e.gitRepo)?t:"").trim(),branch:R(e.gitBranch)||A,path:R(e.gitPath)||""}}}}(e)})}function V(e){var t,r,n=function(e){if(e&&(void 0===e?"undefined":v(e))==="object"){var t,r,n,a=U(e.sourceStorage);return"git"!==a?h(b({},e),{sourceStorage:a}):h(b({},e),{sourceStorage:a,git:h(b({},e.git),{repo:R(null==(t=e.git)?void 0:t.repo)||"",branch:R(null==(r=e.git)?void 0:r.branch)||A,path:R(null==(n=e.git)?void 0:n.path)||""})})}}(e.options);return b({title:e.title,uid:e.uid,portalType:z(e.portalType),portalName:e.portalName,routePath:e.routePath,uiLayoutUid:e.uiLayoutUid||(null==(r=e.uiLayout)?void 0:r.uid)||"",icon:null!=(t=e.icon)?t:null,enabled:e.enabled},n?{options:n}:{})}function K(e){return h(b({},e),{defaultPortal:_.has(e.uid)})}function $(e){var t=e.record,r=e.onSubmitted,n=(0,d.kj)(),s=(0,l.useFlowContext)(),p=i.theme.useToken().token,m=i.App.useApp().notification,f=g(i.Form.useForm(),1)[0],v=g((0,u.useState)(!1),2),E=v[0],I=v[1],F=(0,u.useMemo)(function(){return s.api.resource("multiPortals")},[s.api]),O=(0,o.useRequest)(function(){return y(function(){var e,t;return S(this,function(r){switch(r.label){case 0:return[4,s.api.request({url:"uiLayouts:listEnabled",method:"get",params:{pageSize:200,sort:["uid"]},skipNotify:!0})];case 1:return[2,Array.isArray(null==(t=r.sent())||null==(e=t.data)?void 0:e.data)?t.data.data:[]]}})})()}),C=(0,u.useMemo)(function(){var e;return(null!=(e=O.data)?e:[]).map(function(e){return{value:e.uid,label:"desktop"===e.layoutType?n("Desktop"):"mobile"===e.layoutType?n("Mobile"):e.title||e.uid}})},[O.data,n]);(0,u.useEffect)(function(){if(!(t||f.getFieldValue("uiLayoutUid"))){var e,r,n=null==(e=O.data)||null==(r=e.find(function(e){return"desktop"===e.layoutType}))?void 0:r.uid;n&&f.setFieldValue("uiLayoutUid",n)}},[f,O.data,t]);var _=(0,u.useMemo)(function(){var e,r,n,a,o;return t?(o=(a=V(t)).options,h(b({},a),{sourceStorage:U(null==o?void 0:o.sourceStorage),gitRepo:(null==o||null==(e=o.git)?void 0:e.repo)||"",gitBranch:(null==o||null==(r=o.git)?void 0:r.branch)||A,gitPath:(null==o||null==(n=o.git)?void 0:n.path)||""})):h(b({},x),{uid:"portal-".concat((0,l.randomId)()),sourceStorage:j,gitBranch:A,gitPath:""})},[t]),q=(0,u.useCallback)(function(){return y(function(){var e,a;return S(this,function(l){switch(l.label){case 0:return[4,f.validateFields()];case 1:e=G.apply(void 0,[l.sent()]),I(!0),l.label=2;case 2:if(l.trys.push([2,7,8,9]),!t)return[3,4];return[4,T({resource:F,filterByTk:t.uid,values:e,onSubmitted:r})];case 3:return l.sent(),[3,6];case 4:return[4,P({resource:F,values:e,onSubmitted:r})];case 5:l.sent(),l.label=6;case 6:return[3,9];case 7:throw a=l.sent(),m.error({message:function(e){var t=w(e,"response"),r=w(t,"data"),n=w(r,"errors");if(Array.isArray(n)){var a=n.map(function(e){return k(w(e,"message"))}).filter(function(e){return!!e}).join("\n");if(a)return a}return k(w(w(r,"error"),"message"))||k(w(r,"message"))||k(w(e,"message"))}(a)||n("Failed to save portal"),role:"alert"}),a;case 8:return I(!1),[7];case 9:return[2]}})})()},[f,m,r,t,F,n]);return c().createElement(a.DrawerFormLayout,{title:t?n("Edit portal"):n("Add portal"),onSubmit:q,submitting:E,submitText:n("Submit"),cancelText:n("Cancel")},c().createElement("style",null,D),c().createElement(i.Form,{form:f,layout:"vertical",initialValues:_},c().createElement(i.Form.Item,{name:"title",label:n("Title"),rules:[{required:!0,whitespace:!0,message:n("Title field is required")}]},c().createElement(i.Input,null)),c().createElement(i.Form.Item,{name:"uid",hidden:!0,rules:[{required:!0,whitespace:!0,message:n("The field value is required")}]},c().createElement(i.Input,null)),c().createElement(i.Form.Item,{name:"portalName",label:n("Portal name"),rules:[{required:!0,whitespace:!0,message:n("The field value is required")},{validator:function(e,t){var r=N(t);return r?Promise.reject(Error(n(r))):Promise.resolve()}}]},c().createElement(i.Input,{disabled:null==t?void 0:t.defaultPortal})),c().createElement(i.Form.Item,{name:"portalType",label:n("Portal type"),htmlFor:"multi-portal-portal-type-no-code",rules:[{required:!0,message:n("The field value is required")}]},c().createElement(i.Radio.Group,{disabled:null==t?void 0:t.defaultPortal},c().createElement(i.Space,{direction:"vertical"},c().createElement(i.Radio,{className:M,id:"multi-portal-portal-type-no-code",style:B,value:"no-code"},c().createElement("span",null,n("No-code portal")),c().createElement("div",{style:{color:p.colorTextDescription,fontSize:p.fontSizeSM}},n("Create with visual configuration. AI can help adjust the configuration. Path: /v/<name>"))),c().createElement(i.Radio,{className:M,style:B,value:"ai"},c().createElement("span",null,n("AI portal")),c().createElement("div",{style:{color:p.colorTextDescription,fontSize:p.fontSizeSM}},n("Create with AI Agent and code. Users can request changes in natural language. Path: /x/<name>")))))),c().createElement(i.Form.Item,{noStyle:!0,shouldUpdate:function(e,t){return e.portalType!==t.portalType}},function(e){return"ai"===(0,e.getFieldValue)("portalType")?c().createElement(c().Fragment,null,c().createElement(i.Form.Item,{name:"sourceStorage",label:n("Source storage"),htmlFor:"multi-portal-source-storage-nocobase",rules:[{required:!0,message:n("The field value is required")}]},c().createElement(i.Radio.Group,null,c().createElement(i.Space,{direction:"vertical"},c().createElement(i.Radio,{className:M,id:"multi-portal-source-storage-nocobase",style:B,value:"nocobase"},c().createElement("span",null,n("NocoBase")),c().createElement("div",{style:{color:p.colorTextDescription,fontSize:p.fontSizeSM}},n("Manage portal source code in NocoBase."))),c().createElement(i.Radio,{className:M,style:B,value:"git"},c().createElement("span",null,n("Git")),c().createElement("div",{style:{color:p.colorTextDescription,fontSize:p.fontSizeSM}},n("Manage portal source code in a Git repository.")))))),c().createElement(i.Form.Item,{noStyle:!0,shouldUpdate:function(e,t){return e.sourceStorage!==t.sourceStorage}},function(e){return"git"===(0,e.getFieldValue)("sourceStorage")?c().createElement(c().Fragment,null,c().createElement(i.Form.Item,{name:"gitRepo",label:n("Git repository URL"),rules:[{required:!0,whitespace:!0,message:n("The field value is required")}]},c().createElement(i.Input,{placeholder:"git@github.com:nocobase/customer-portal.git"})),c().createElement(i.Form.Item,{name:"gitBranch",label:n("Git branch")},c().createElement(i.Input,{placeholder:A})),c().createElement(i.Form.Item,{name:"gitPath",label:n("Git path"),extra:n("Directory inside the Git repository for this portal. Leave empty for the root.")},c().createElement(i.Input,{placeholder:""}))):null})):null}),c().createElement(i.Form.Item,{name:"uiLayoutUid",label:n("Layout"),dependencies:["portalType"],rules:[{validator:function(e,t){return"ai"===f.getFieldValue("portalType")||t?Promise.resolve():Promise.reject(Error(n("The field value is required")))}}]},c().createElement(i.Select,{disabled:!!t||(null==t?void 0:t.defaultPortal),loading:O.loading,options:C,showSearch:!0,optionFilterProp:"label"})),c().createElement(i.Form.Item,{name:"icon",label:n("Icon")},c().createElement(L,null)),c().createElement(i.Form.Item,{name:"enabled",label:n("Enabled"),valuePropName:"checked",extra:n("When disabled, this portal will not be registered or accessible.")},c().createElement(i.Switch,null))))}L.displayName="IconPickerFormControl",t.default=function(){var e,t=(0,d.kj)(),r=(0,l.useFlowContext)(),f=i.theme.useToken().token,v=i.App.useApp(),w=v.message,k=v.modal,P=g((0,u.useState)([]),2),F=P[0],O=P[1],j=g((0,u.useState)([]),2),A=j[0],x=j[1],B=(0,u.useMemo)(function(){return r.api.resource("multiPortals")},[r.api]),M=(0,o.useRequest)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return y(function(){var t,r;return S(this,function(n){switch(n.label){case 0:return[4,B.list({page:e,pageSize:20,sort:["createdAt"],appends:["uiLayout"]})];case 1:return[2,null!=(t=null==(r=n.sent())?void 0:r.data)?t:{data:[]}]}})})()}),D=M.data,_=M.loading,q=(0,u.useMemo)(function(){return Array.isArray(null==D?void 0:D.data)?D.data.map(K):[]},[null==D?void 0:D.data]),L=(0,u.useMemo)(function(){var e,t,r,n=null==D?void 0:D.meta;return!!n&&{total:null!=(e=n.count)?e:q.length,pageSize:null!=(t=n.pageSize)?t:20,current:null!=(r=n.page)?r:1}},[null==D?void 0:D.meta,q.length]),N=(0,u.useCallback)(function(){var e,t;O([]),M.run(null!=(e=null==D||null==(t=D.meta)?void 0:t.page)?e:1)},[M,null==D||null==(e=D.meta)?void 0:e.page]),R=(0,u.useCallback)(function(){(0,s.G)(r.app).reload(r.api).catch(function(e){console.error("[NocoBase] Failed to refresh portal entry actions.",e)})},[r.api,r.app]),z=(0,u.useCallback)(function(){N(),R()},[R,N]),U=(0,u.useCallback)(function(e){r.viewer.drawer({width:f.screenMD,closable:!0,content:function(){return c().createElement($,{record:e,onSubmitted:z})}})},[r.viewer,z,f.screenMD]),G=(0,u.useCallback)(function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};k.confirm({title:t("Delete portal"),content:c().createElement(c().Fragment,null,c().createElement("div",null,r.isBatch?t("Are you sure you want to delete the selected Multi-portal records?"):t("Are you sure you want to delete it?")),c().createElement("div",null,t("The corresponding portal directory will also be deleted."))),onOk:function(){return y(function(){return S(this,function(t){switch(t.label){case 0:return[4,I({resource:B,filterByTk:e,onDeleted:z})];case 1:return t.sent(),[2]}})})()}})},[k,z,B,t]),W=(0,u.useCallback)(function(e,r){return y(function(){return S(this,function(n){switch(n.label){case 0:x(function(t){return t.includes(e.uid)?t:((function(e){if(Array.isArray(e))return m(e)})(t)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||E(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([e.uid])}),n.label=1;case 1:return n.trys.push([1,,3,4]),[4,T({resource:B,filterByTk:e.uid,values:h(b({},V(e)),{enabled:r}),onSubmitted:z})];case 2:return n.sent(),w.success(t("Updated successfully")),[3,4];case 3:return x(function(t){return t.filter(function(t){return t!==e.uid})}),[7];case 4:return[2]}})})()},[w,z,B,t]),H=(0,u.useMemo)(function(){return[{title:t("Title"),dataIndex:"title",ellipsis:!0},{title:t("Access path"),dataIndex:"routePath",ellipsis:!0,render:function(e,t){var n=(0,p.u)(r.app,t.routePath,t.portalType);return c().createElement(i.Button,{type:"link",href:n,target:"_blank",rel:"noopener noreferrer",style:C},n)}},{title:t("Portal name"),dataIndex:"portalName",ellipsis:!0},{title:t("Layout"),dataIndex:"uiLayoutUid",ellipsis:!0,render:function(e,t){var r,n,a,l=(null==(n=t.uiLayout)?void 0:n.title)||t.uiLayoutUid;return l?c().createElement(i.Tag,{color:"desktop"===(r=null==(a=t.uiLayout)?void 0:a.layoutType)?"blue":"mobile"===r?"purple":"default"},l):null}},{title:t("Enabled"),dataIndex:"enabled",render:function(e,r){return c().createElement(i.Switch,{"aria-label":t("Enabled"),checked:e,loading:A.includes(r.uid),size:"small",onChange:function(e){return y(function(){return S(this,function(t){switch(t.label){case 0:return[4,W(r,e)];case 1:return t.sent(),[2]}})})()}})}},{title:t("Actions"),render:function(e,n){return c().createElement(i.Space,{size:"small"},c().createElement(i.Button,{type:"link",href:(0,p.u)(r.app,n.routePath,n.portalType),target:"_blank",rel:"noopener noreferrer",style:C},t("View")),c().createElement(i.Button,{type:"link",style:C,onClick:function(){return U(n)}},t("Edit")),c().createElement(i.Button,{type:"link",style:C,onClick:function(){return G(n.uid)}},t("Delete")))}}]},[r.app,G,W,U,t,A]),J=(0,u.useCallback)(function(e){var t;M.run(null!=(t=e.current)?t:1)},[M]);return c().createElement(i.Card,null,c().createElement(i.Flex,{justify:"flex-end",style:{marginBottom:f.marginMD}},c().createElement(i.Space,null,c().createElement(i.Button,{icon:c().createElement(n.ReloadOutlined,null),onClick:z},t("Refresh")),c().createElement(i.Button,{icon:c().createElement(n.DeleteOutlined,null),disabled:0===F.length,onClick:function(){return G(F,{isBatch:!0})}},t("Delete")),c().createElement(i.Button,{type:"primary",icon:c().createElement(n.PlusOutlined,null),onClick:function(){return U()}},t("Add portal")))),c().createElement(a.Table,{rowKey:"uid",loading:_,dataSource:q,columns:H,pagination:L,rowSelection:{selectedRowKeys:F,onChange:function(e){return O(e)}},onChange:J}))}}}]);
|