@nocobase/plugin-ui-templates 2.1.0-beta.9 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/client-v2.d.ts +2 -0
  2. package/client-v2.js +1 -0
  3. package/dist/client/220.346d5c8edaa0cd0c.js +10 -0
  4. package/dist/client/285.b1fb1c5e753da51b.js +10 -0
  5. package/dist/client/643.047c34d491bb5ac0.js +10 -0
  6. package/dist/client/682.72134d5030608646.js +10 -0
  7. package/dist/client/934.5dd36051e3d71be1.js +10 -0
  8. package/dist/client/945.3cf235750267b089.js +10 -0
  9. package/dist/client/index.js +1 -1
  10. package/dist/client/legacyV2Bridge.d.ts +13 -0
  11. package/dist/client/openViewActionExtensions.d.ts +1 -2
  12. package/dist/client-v2/220.ebe24d52f9f5a0df.js +10 -0
  13. package/dist/client-v2/643.df78038aa6e1b397.js +10 -0
  14. package/dist/client-v2/945.e06ae2942a1afaa4.js +10 -0
  15. package/dist/client-v2/components/FlowModelTemplatesPage.d.ts +65 -0
  16. package/dist/{client → client-v2}/components/TemplateSelectOption.d.ts +1 -1
  17. package/dist/{client/components/FlowModelTemplatesPage.d.ts → client-v2/index.d.ts} +2 -4
  18. package/dist/client-v2/index.js +10 -0
  19. package/dist/{client → client-v2}/locale.d.ts +6 -4
  20. package/dist/{client → client-v2}/menuExtensions.d.ts +1 -1
  21. package/dist/{client → client-v2}/models/ReferenceBlockModel.d.ts +1 -1
  22. package/dist/{client → client-v2}/models/SubModelTemplateImporterModel.d.ts +1 -1
  23. package/dist/{client/schemas/flowModelTemplates.d.ts → client-v2/models/index.d.ts} +3 -3
  24. package/dist/client-v2/openViewActionExtensions.d.ts +42 -0
  25. package/dist/client-v2/pages/BlockTemplatesPage.d.ts +9 -0
  26. package/dist/client-v2/pages/PopupTemplatesPage.d.ts +9 -0
  27. package/dist/client-v2/plugin.d.ts +14 -0
  28. package/dist/client-v2/utils/replaceGridLayoutUid.d.ts +10 -0
  29. package/dist/externalVersion.js +9 -10
  30. package/dist/locale/en-US.json +3 -2
  31. package/dist/locale/zh-CN.json +3 -2
  32. package/dist/server/collections/flowModelTemplateUsages.js +1 -0
  33. package/dist/server/collections/flowModelTemplates.js +1 -0
  34. package/dist/server/plugin.js +22 -10
  35. package/dist/server/resources/flowModelTemplates.js +12 -0
  36. package/package.json +3 -3
  37. package/dist/client/collections/flowModelTemplates.d.ts +0 -67
  38. package/dist/client/hooks/useFlowModelTemplateActions.d.ts +0 -24
  39. /package/dist/{client → client-v2}/constants.d.ts +0 -0
  40. /package/dist/{client → client-v2}/models/ReferenceFormGridModel.d.ts +0 -0
  41. /package/dist/{client → client-v2}/models/referenceShared.d.ts +0 -0
  42. /package/dist/{client → client-v2}/utils/infiniteSelect.d.ts +0 -0
  43. /package/dist/{client → client-v2}/utils/templateCompatibility.d.ts +0 -0
  44. /package/dist/{client → client-v2}/utils/templateCopy.d.ts +0 -0
@@ -6,6 +6,6 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- import { ISchema } from '@nocobase/client';
10
- export declare const flowModelTemplateEditActionSchema: ISchema;
11
- export declare const createFlowModelTemplatesSchema: (filter?: Record<string, any>) => ISchema;
9
+ export * from './ReferenceBlockModel';
10
+ export * from './ReferenceFormGridModel';
11
+ export * from './SubModelTemplateImporterModel';
@@ -0,0 +1,42 @@
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
+ import React from 'react';
10
+ import type { FlowEngine } from '@nocobase/flow-engine';
11
+ export type TemplateRow = {
12
+ uid: string;
13
+ name?: string;
14
+ description?: string;
15
+ targetUid?: string;
16
+ useModel?: string;
17
+ type?: string;
18
+ dataSourceKey?: string;
19
+ collectionName?: string;
20
+ associationName?: string;
21
+ filterByTk?: string;
22
+ sourceId?: string;
23
+ };
24
+ type ExpectedResourceInfo = {
25
+ dataSourceKey?: string;
26
+ collectionName?: string;
27
+ associationName?: string;
28
+ };
29
+ export type PopupTemplateSelectOption = {
30
+ label: React.ReactNode;
31
+ value: string;
32
+ raw?: TemplateRow;
33
+ description?: string;
34
+ disabled?: boolean;
35
+ disabledReason?: string;
36
+ rawName?: string;
37
+ __idx?: number;
38
+ };
39
+ export declare function appendPopupTemplateOptions(prev: PopupTemplateSelectOption[], next: PopupTemplateSelectOption[]): PopupTemplateSelectOption[];
40
+ export declare function buildPopupTemplateListFilter(expected: ExpectedResourceInfo): Record<string, any>;
41
+ export declare function registerOpenViewPopupTemplateAction(flowEngine: FlowEngine): void;
42
+ export {};
@@ -0,0 +1,9 @@
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
+ export { BlockTemplatesPage as default } from '../components/FlowModelTemplatesPage';
@@ -0,0 +1,9 @@
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
+ export { PopupTemplatesPage as default } from '../components/FlowModelTemplatesPage';
@@ -0,0 +1,14 @@
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
+ import type { Application } from '@nocobase/client-v2';
10
+ import { Plugin } from '@nocobase/client-v2';
11
+ export declare class PluginUiTemplatesClientV2 extends Plugin<Record<string, never>, Application> {
12
+ load(): Promise<void>;
13
+ }
14
+ export default PluginUiTemplatesClientV2;
@@ -0,0 +1,10 @@
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
+ import { type FlowModel } from '@nocobase/flow-engine';
10
+ export declare function replaceGridLayoutUid(parent: FlowModel, fromUid: string, toUid: string): boolean;
@@ -8,17 +8,16 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.1.0-beta.9",
12
- "@nocobase/flow-engine": "2.1.0-beta.9",
11
+ "@nocobase/client": "2.1.0",
12
+ "@nocobase/flow-engine": "2.1.0",
13
13
  "react": "18.2.0",
14
14
  "antd": "5.24.2",
15
15
  "@ant-design/icons": "5.6.1",
16
- "lodash": "4.17.21",
17
- "@formily/react": "2.3.7",
18
- "@nocobase/server": "2.1.0-beta.9",
19
- "@nocobase/plugin-flow-engine": "2.1.0-beta.9",
20
- "@nocobase/utils": "2.1.0-beta.9",
21
- "@formily/core": "2.3.7",
22
- "@nocobase/database": "2.1.0-beta.9",
23
- "@nocobase/actions": "2.1.0-beta.9"
16
+ "lodash": "4.18.1",
17
+ "@nocobase/client-v2": "2.1.0",
18
+ "@nocobase/server": "2.1.0",
19
+ "@nocobase/plugin-flow-engine": "2.1.0",
20
+ "@nocobase/utils": "2.1.0",
21
+ "@nocobase/database": "2.1.0",
22
+ "@nocobase/actions": "2.1.0"
24
23
  };
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "UI templates": "UI templates",
3
- "Block templates (v2)": "Block templates (v2)",
4
- "Popup templates (v2)": "Popup templates (v2)",
5
3
  "Actions": "Actions",
4
+ "Collection": "Collection",
5
+ "Data source": "Data source",
6
6
  "Are you sure you want to delete this item? This action cannot be undone.": "Are you sure you want to delete this item? This action cannot be undone.",
7
7
  "Block UID": "Block UID",
8
8
  "Block UID is already set and cannot be modified": "Block UID is already set and cannot be modified",
@@ -14,6 +14,7 @@
14
14
  "Edit": "Edit",
15
15
  "Edit template": "Edit template",
16
16
  "Mode": "Mode",
17
+ "Operation failed": "Operation failed",
17
18
  "Other blocks": "Other blocks",
18
19
  "Please configure target block": "Please configure target block",
19
20
  "Reference": "Reference",
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "UI templates": "UI 模板",
3
- "Block templates (v2)": "区块模板 (v2)",
4
- "Popup templates (v2)": "弹窗模板 (v2)",
5
3
  "Actions": "操作",
4
+ "Collection": "数据表",
5
+ "Data source": "数据源",
6
6
  "Are you sure you want to delete this item? This action cannot be undone.": "确定要删除此项吗?此操作不可撤销。",
7
7
  "Block UID": "区块 UID",
8
8
  "Block UID is already set and cannot be modified": "当前已经指定区块UID,不允许修改",
@@ -15,6 +15,7 @@
15
15
  "Edit": "编辑",
16
16
  "Edit template": "编辑模板",
17
17
  "Mode": "模式",
18
+ "Operation failed": "操作失败",
18
19
  "Other blocks": "其他区块",
19
20
  "Please configure target block": "请先配置目标区块",
20
21
  "Reference": "引用",
@@ -33,6 +33,7 @@ var flowModelTemplateUsages_default = {
33
33
  dumpRules: "required",
34
34
  migrationRules: ["overwrite", "schema-only"],
35
35
  name: "flowModelTemplateUsages",
36
+ dataCategory: "system",
36
37
  autoGenId: false,
37
38
  timestamps: true,
38
39
  fields: [
@@ -33,6 +33,7 @@ var flowModelTemplates_default = {
33
33
  dumpRules: "required",
34
34
  migrationRules: ["overwrite", "schema-only"],
35
35
  name: "flowModelTemplates",
36
+ dataCategory: "system",
36
37
  autoGenId: false,
37
38
  timestamps: true,
38
39
  fields: [
@@ -142,17 +142,33 @@ class PluginBlockReferenceServer extends import_server.Plugin {
142
142
  });
143
143
  }
144
144
  };
145
- const removeUsagesByInstance = async (instanceUid, _options, { transaction } = {}) => {
145
+ const removeUsagesByInstances = async (instanceUids, { transaction } = {}) => {
146
146
  const usageRepo = this.db.getRepository("flowModelTemplateUsages");
147
- await usageRepo.destroy({ filter: { modelUid: instanceUid }, transaction });
147
+ const uids = import_lodash.default.uniq(instanceUids.map(String).filter(Boolean));
148
+ for (const chunk of import_lodash.default.chunk(uids, 500)) {
149
+ await usageRepo.destroy({
150
+ filter: {
151
+ modelUid: {
152
+ $in: chunk
153
+ }
154
+ },
155
+ transaction
156
+ });
157
+ }
148
158
  };
149
159
  this.db.on("flowModels.afterDestroy", async (instance, { transaction } = {}) => {
150
- var _a2, _b;
160
+ var _a2;
151
161
  const instanceUid = ((_a2 = instance == null ? void 0 : instance.get) == null ? void 0 : _a2.call(instance, "uid")) || (instance == null ? void 0 : instance.uid);
152
162
  if (!instanceUid) return;
153
- const options = parseOptions(((_b = instance == null ? void 0 : instance.get) == null ? void 0 : _b.call(instance, "options")) || (instance == null ? void 0 : instance.options));
154
- await removeUsagesByInstance(instanceUid, options, { transaction });
163
+ await removeUsagesByInstances([instanceUid], { transaction });
155
164
  });
165
+ this.db.on(
166
+ "flowModels.beforeRemoveTree",
167
+ async ({ uids } = {}, options = {}) => {
168
+ if (!(uids == null ? void 0 : uids.length)) return;
169
+ await removeUsagesByInstances(uids, { transaction: options == null ? void 0 : options.transaction });
170
+ }
171
+ );
156
172
  const handleFlowModelSave = async (instance, { transaction } = {}) => {
157
173
  var _a2, _b;
158
174
  const instanceUid = ((_a2 = instance == null ? void 0 : instance.get) == null ? void 0 : _a2.call(instance, "uid")) || (instance == null ? void 0 : instance.uid);
@@ -203,11 +219,7 @@ class PluginBlockReferenceServer extends import_server.Plugin {
203
219
  for (const node of nodes) {
204
220
  const instanceUid = node == null ? void 0 : node.uid;
205
221
  if (!instanceUid) continue;
206
- const options = parseOptions((node == null ? void 0 : node.options) || {});
207
- if ((node == null ? void 0 : node.parent) && !(options == null ? void 0 : options.parentId)) {
208
- options.parentId = node.parent;
209
- }
210
- await removeUsagesByInstance(instanceUid, options, { transaction: ctx.transaction });
222
+ await removeUsagesByInstances([instanceUid], { transaction: ctx.transaction });
211
223
  }
212
224
  return;
213
225
  }
@@ -237,6 +237,7 @@ var flowModelTemplates_default = {
237
237
  }
238
238
  },
239
239
  async destroy(ctx, next) {
240
+ var _a;
240
241
  const templateUid = resolveTemplateUid(ctx);
241
242
  if (!templateUid) {
242
243
  return ctx.throw(400, "template uid is required");
@@ -255,6 +256,13 @@ var flowModelTemplates_default = {
255
256
  data: { usageCount }
256
257
  });
257
258
  }
259
+ const templateRepo = ctx.db.getRepository("flowModelTemplates");
260
+ const template = await templateRepo.findOne({
261
+ filter: { uid: templateUid },
262
+ transaction: ctx.transaction,
263
+ context: ctx
264
+ });
265
+ const targetUid = ((_a = template == null ? void 0 : template.get) == null ? void 0 : _a.call(template, "targetUid")) || (template == null ? void 0 : template.targetUid);
258
266
  await import_actions.default.destroy(ctx, next);
259
267
  await usageRepo.destroy({
260
268
  filter: {
@@ -262,6 +270,10 @@ var flowModelTemplates_default = {
262
270
  },
263
271
  context: ctx
264
272
  });
273
+ if (targetUid) {
274
+ const flowRepo = ctx.db.getRepository("flowModels");
275
+ await flowRepo.remove(targetUid, { transaction: ctx.transaction });
276
+ }
265
277
  }
266
278
  }
267
279
  };
package/package.json CHANGED
@@ -4,17 +4,17 @@
4
4
  "displayName.zh-CN": "UI 模板",
5
5
  "description": "Provides block templates and popup templates for UI reuse.",
6
6
  "description.zh-CN": "提供区块模板和弹窗模板复用的能力。",
7
- "version": "2.1.0-beta.9",
7
+ "version": "2.1.0",
8
8
  "license": "Apache-2.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "types": "./dist/index.d.ts",
11
11
  "devDependencies": {
12
- "@formily/shared": "2.x",
13
12
  "antd": "5.x",
14
13
  "react": "^18.2.0"
15
14
  },
16
15
  "peerDependencies": {
17
16
  "@nocobase/client": "2.x",
17
+ "@nocobase/client-v2": "2.x",
18
18
  "@nocobase/flow-engine": "2.x",
19
19
  "@nocobase/plugin-flow-engine": "2.x",
20
20
  "@nocobase/server": "2.x",
@@ -33,5 +33,5 @@
33
33
  "block",
34
34
  "popup"
35
35
  ],
36
- "gitHead": "c3a2875e4cbbb43b1f2361e6f9f5f84a7d3f3c3c"
36
+ "gitHead": "9373212dd0f22cd985be1e23674d6b454944b9ee"
37
37
  }
@@ -1,67 +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
- export declare const flowModelTemplatesCollection: {
10
- name: string;
11
- filterTargetKey: string;
12
- fields: ({
13
- type: string;
14
- name: string;
15
- interface: string;
16
- uiSchema: {
17
- type: string;
18
- title: string;
19
- required: boolean;
20
- 'x-component': string;
21
- 'x-component-props'?: undefined;
22
- 'x-disabled'?: undefined;
23
- 'x-hidden'?: undefined;
24
- };
25
- } | {
26
- type: string;
27
- name: string;
28
- interface: string;
29
- uiSchema: {
30
- type: string;
31
- title: string;
32
- 'x-component': string;
33
- 'x-component-props': {
34
- rows: number;
35
- };
36
- required?: undefined;
37
- 'x-disabled'?: undefined;
38
- 'x-hidden'?: undefined;
39
- };
40
- } | {
41
- type: string;
42
- name: string;
43
- interface: string;
44
- uiSchema: {
45
- type: string;
46
- title: string;
47
- 'x-component': string;
48
- 'x-disabled': boolean;
49
- required?: undefined;
50
- 'x-component-props'?: undefined;
51
- 'x-hidden'?: undefined;
52
- };
53
- } | {
54
- type: string;
55
- name: string;
56
- interface: string;
57
- uiSchema: {
58
- type: string;
59
- title: string;
60
- 'x-component': string;
61
- 'x-disabled': boolean;
62
- 'x-hidden': boolean;
63
- required?: undefined;
64
- 'x-component-props'?: undefined;
65
- };
66
- })[];
67
- };
@@ -1,24 +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
- import { ActionProps } from '@nocobase/client';
10
- export declare const useFlowModelTemplateSearchProps: () => {
11
- placeholder: string;
12
- value: string;
13
- onChange: (e: any) => void;
14
- onSearch: (value: string) => void;
15
- allowClear: boolean;
16
- style: {
17
- width: number;
18
- };
19
- };
20
- export declare const useFlowModelTemplateEditFormProps: () => {
21
- form: import("@formily/core").Form<any>;
22
- };
23
- export declare const useFlowModelTemplateEditActionProps: () => ActionProps;
24
- export declare const useFlowModelTemplateDeleteActionProps: () => ActionProps;
File without changes