Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: flatten and merge Actions #4336

Merged
merged 20 commits into from
May 17, 2024
Merged

refactor: flatten and merge Actions #4336

merged 20 commits into from
May 17, 2024

Conversation

zhangzhonghe
Copy link
Contributor

@zhangzhonghe zhangzhonghe commented May 13, 2024

背景

配置操作的下拉菜单之前是多层级的,分了 enable actions 和 customize 两组,第一组是 Switch 的只能添加一次,第二组是常规的可以多次添加。但是这种设计有一些问题:

  1. 有些操作是可以多次添加的,比如查看、编辑
  2. 这种分组设计给扩展开发带来较大困扰,开发需要知道按钮所在分组。
  3. Switch 的设计导致有些重复的操作出现,比如 add new 和 add record,Submit 和 Save record

基于以上几点考虑,将配置操作的下拉菜单拍平处理,只能添加一次的操作的还保留 Switch 的效果,其他可以重复添加的操作将不再是 Switch 的交互了

主要变更

扁平化 配置操作(Configure actions) 列表

以 Table 区块为例,变更前与变更后的变化如下所示:

变更前:

image

变更后:

  1. 去除了 Enable actions 分组
  2. 去除了某些选项右侧的 Switch 开关,以支持添加多个相同的按钮
  3. 去除了名为 Customize 的子菜单,里面的按钮拍平到列表中

image

此次改动对插件开发者的影响

在添加 Action 的时候不再需要 enableActions 前缀

注意:这部分的变更已做了兼容处理,也就是说开发者自己开发的插件不需要做任何变更也可以正常运行。

会影响在插件中注册 Actions 时所使用的 name 的值。下面以 导入(Import) 按钮为例:

class PluginActionImportClient extends Plugin {
  async load() {
    // ...other code

    const tableActionInitializers = this.app.schemaInitializerManager.get('table:configureActions');
-   ableActionInitializers?.add('enableActions.import', initializerData);
+   ableActionInitializers?.add('import', initializerData);
  }
}

在添加 导入(Import) 按钮的时候应将 enableActions.import 改为 import

在添加 Action 的时候不再需要 customize 前缀

注意:这部分的变更已做了兼容处理,也就是说开发者自己开发的插件不需要做任何变更也可以正常运行。

会影响在插件中注册 Actions 时所使用的 name 的值。下面以 批量编辑(Bulk edit) 为例:

class PluginActionBulkEditClient extends Plugin {
  async load() {
    // ...other code

-   this.app.schemaInitializerManager.addItem('table:configureActions', 'customize.bulkEdit', initializerData);
+   this.app.schemaInitializerManager.addItem('table:configureActions', 'bulkEdit', initializerData);
  }
}

在添加 批量编辑(Bulk edit) 按钮的时候应将 customize.bulkEdit 改为 bulkEdit

将功能相似的 Actions 合并

合并 添加(Add new)添加数据(Add record) 选项

移除 添加数据 选项,保留 添加 选项,原有的 添加数据 按钮的功能转移到添加按钮上,如下图所示,通过 其它数据表(Other collections) 选项可以添加任意数据表的区块:

原有的 添加数据 按钮的功能:可以添加任意数据表的区块。

image

合并 提交(Submit)保存记录(Save record) 选项

image

移除 保存记录 选项,保留 提交 选项,原有 保存记录 按钮的配置项转移到 提交 按钮上。新版 提交 按钮的配置项如下所示:

image

Copy link

height bot commented May 13, 2024

This pull request has been linked to and will mark 1 task as "Done" when merged:

  • T-4284 table区块,行编辑弹窗添加编辑表单,提交按钮属性重复 (unlink task)

This pull request has also been linked to 1 additional task:

This comment has been minimized.

This comment has been minimized.

@zhangzhonghe zhangzhonghe marked this pull request as ready for review May 15, 2024 01:00

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link

Tests results for "E2E"

14 flaky ⚠️ [chromium] › plugins/@nocobase/plugin-workflow/src/client/__e2e__/conditionNode/BranchIntoYesAndNoMathEngine.test.ts:261:5 › Collection event Add Data Trigger, determines that the trigger node integer field variable is not equal to an equal constant, fails.
⚠️ [chromium] › plugins/@nocobase/plugin-action-bulk-edit/src/client/__e2e__/schemaSettings.test.ts:14:7 › bulk edit action setting › data will be updated && edit form configure
⚠️ [chromium] › core/client/src/modules/blocks/data-blocks/list/__e2e__/schemaInitializer.test.ts:29:7 › where list block can be added › popup
⚠️ [chromium] › plugins/@nocobase/plugin-acl/src/client/__e2e__/association.test.ts:245:5 › association block action permission
⚠️ [chromium] › plugins/@nocobase/plugin-action-bulk-update/src/client/__e2e__/schemaSettings.test.ts:14:7 › data will be updated && Assign field values && after successful submission › data will be updated && Assign field values && after successful submission
⚠️ [chromium] › plugins/@nocobase/plugin-auth/src/client/__e2e__/auth.test.ts:21:7 › auth › register
⚠️ [chromium] › plugins/@nocobase/plugin-file-manager/src/client/__e2e__/editLocalStorage.test.ts:15:7 › File manager › edit local storage title
⚠️ [chromium] › plugins/@nocobase/plugin-action-duplicate/src/client/__e2e__/schemaInitailizer.test.ts:19:7 › TableActionColumnInitializers & DetailsActionInitializers & ReadPrettyFormActionInitializers should add duplication action › duplication action in TableActionColumnInitializers
⚠️ [chromium] › plugins/@nocobase/plugin-data-source-main/src/client/__e2e__/fields/hasOne/schemaSettings2.test.ts:181:7 › form item & edit form › quick create
⚠️ [chromium] › core/client/src/modules/blocks/data-blocks/table/__e2e__/schemaSettings1.test.ts:92:9 › table block schema settings › enable drag and drop sorting › enable drag and drop sorting
⚠️ [chromium] › core/client/src/modules/variable/__e2e__/basic.test.ts:14:7 › variables › linkage rules of table view action
⚠️ [chromium] › plugins/@nocobase/plugin-acl/src/client/__e2e__/configure.test.ts:13:5 › allows to configure interface
⚠️ [chromium] › plugins/@nocobase/plugin-action-bulk-edit/src/client/__e2e__/schemaInitailizer.test.ts:14:7 › TableActionInitializers & GanttActionInitializers & MapActionInitializers should add bulk edit action › bulk edit in TableActionInitializers
⚠️ [chromium] › plugins/@nocobase/plugin-workflow/src/client/__e2e__/conditionNode/BranchIntoYesAndNoFormulaEngine.test.ts:930:5 › Collection event add data trigger, determine the trigger node integer variable is not equal to the query node not equal integer variable, pass.

970 passed, 28 skipped
✔️✔️✔️

Full HTML report. Merge workflow run.

@zhangzhonghe zhangzhonghe merged commit ec558e3 into main May 17, 2024
8 checks passed
@zhangzhonghe zhangzhonghe deleted the T-4267 branch May 17, 2024 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants