fix(plugin-workflow-manual): fix schema migration (#3814)
This commit is contained in:
		
							parent
							
								
									1c32983c00
								
							
						
					
					
						commit
						080e491a0d
					
				@ -20,10 +20,17 @@ function findSchema(root, filter, onlyLeaf = false) {
 | 
				
			|||||||
  return result;
 | 
					  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) {
 | 
					function migrateSchema(schema) {
 | 
				
			||||||
  const root = { properties: schema };
 | 
					  const root = { properties: schema };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const [node] = findSchema(root, (item) => {
 | 
					  const detailNodes = findSchema(root, (item) => {
 | 
				
			||||||
    return (
 | 
					    return (
 | 
				
			||||||
      item['x-decorator'] === 'DetailsBlockProvider' &&
 | 
					      item['x-decorator'] === 'DetailsBlockProvider' &&
 | 
				
			||||||
      item['x-component'] === 'CardItem' &&
 | 
					      item['x-component'] === 'CardItem' &&
 | 
				
			||||||
@ -31,10 +38,7 @@ function migrateSchema(schema) {
 | 
				
			|||||||
    );
 | 
					    );
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (node && node['x-decorator-props']?.dataSource) {
 | 
					  detailNodes.forEach(changeToDataPath);
 | 
				
			||||||
    node['x-decorator-props'].dataPath = node['x-decorator-props'].dataSource.replace(/^{{|}}$/g, '');
 | 
					 | 
				
			||||||
    delete node['x-decorator-props'].dataSource;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return schema;
 | 
					  return schema;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -55,12 +59,13 @@ export default class extends Migration {
 | 
				
			|||||||
      await nodes.reduce(
 | 
					      await nodes.reduce(
 | 
				
			||||||
        (promise, node) =>
 | 
					        (promise, node) =>
 | 
				
			||||||
          promise.then(() => {
 | 
					          promise.then(() => {
 | 
				
			||||||
            const { schema, ...config } = node.config;
 | 
					            const { assignees, forms, schema = {}, ...tabs } = node.config;
 | 
				
			||||||
            return node.update(
 | 
					            return node.update(
 | 
				
			||||||
              {
 | 
					              {
 | 
				
			||||||
                config: {
 | 
					                config: {
 | 
				
			||||||
                  ...config,
 | 
					                  assignees,
 | 
				
			||||||
                  ...migrateSchema(schema),
 | 
					                  forms,
 | 
				
			||||||
 | 
					                  schema: migrateSchema({ ...tabs, ...schema }),
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
              },
 | 
					              },
 | 
				
			||||||
              {
 | 
					              {
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user