From 080e491a0d4bd6e7f16e38f8b90404c7b2dee631 Mon Sep 17 00:00:00 2001 From: Junyi Date: Mon, 25 Mar 2024 21:57:58 +0800 Subject: [PATCH] fix(plugin-workflow-manual): fix schema migration (#3814) --- ...source.ts => 20240325213145-fix-schema.ts} | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) rename packages/plugins/@nocobase/plugin-workflow-manual/src/server/migrations/{20240314163421-change-schema-data-source.ts => 20240325213145-fix-schema.ts} (75%) diff --git a/packages/plugins/@nocobase/plugin-workflow-manual/src/server/migrations/20240314163421-change-schema-data-source.ts b/packages/plugins/@nocobase/plugin-workflow-manual/src/server/migrations/20240325213145-fix-schema.ts similarity index 75% rename from packages/plugins/@nocobase/plugin-workflow-manual/src/server/migrations/20240314163421-change-schema-data-source.ts rename to packages/plugins/@nocobase/plugin-workflow-manual/src/server/migrations/20240325213145-fix-schema.ts index 4d452c2e58..04cfad3bff 100644 --- a/packages/plugins/@nocobase/plugin-workflow-manual/src/server/migrations/20240314163421-change-schema-data-source.ts +++ b/packages/plugins/@nocobase/plugin-workflow-manual/src/server/migrations/20240325213145-fix-schema.ts @@ -20,10 +20,17 @@ function findSchema(root, filter, onlyLeaf = false) { return result; } +function changeToDataPath(item) { + if (item && item['x-decorator-props']?.dataSource) { + item['x-decorator-props'].dataPath = item['x-decorator-props'].dataSource.replace(/^{{|}}$/g, ''); + delete item['x-decorator-props'].dataSource; + } +} + function migrateSchema(schema) { const root = { properties: schema }; - const [node] = findSchema(root, (item) => { + const detailNodes = findSchema(root, (item) => { return ( item['x-decorator'] === 'DetailsBlockProvider' && item['x-component'] === 'CardItem' && @@ -31,10 +38,7 @@ function migrateSchema(schema) { ); }); - if (node && node['x-decorator-props']?.dataSource) { - node['x-decorator-props'].dataPath = node['x-decorator-props'].dataSource.replace(/^{{|}}$/g, ''); - delete node['x-decorator-props'].dataSource; - } + detailNodes.forEach(changeToDataPath); return schema; } @@ -55,12 +59,13 @@ export default class extends Migration { await nodes.reduce( (promise, node) => promise.then(() => { - const { schema, ...config } = node.config; + const { assignees, forms, schema = {}, ...tabs } = node.config; return node.update( { config: { - ...config, - ...migrateSchema(schema), + assignees, + forms, + schema: migrateSchema({ ...tabs, ...schema }), }, }, {