mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-14 08:34:07 -08:00
fix(editor): Fix node type properties not updating regression (no-changelog) (#11700)
This commit is contained in:
parent
01ebe9dd38
commit
e3871dbfe2
|
@ -54,22 +54,25 @@ export const mockNodeTypeDescription = ({
|
|||
credentials = [],
|
||||
inputs = [NodeConnectionType.Main],
|
||||
outputs = [NodeConnectionType.Main],
|
||||
properties = [],
|
||||
}: {
|
||||
name?: INodeTypeDescription['name'];
|
||||
version?: INodeTypeDescription['version'];
|
||||
credentials?: INodeTypeDescription['credentials'];
|
||||
inputs?: INodeTypeDescription['inputs'];
|
||||
outputs?: INodeTypeDescription['outputs'];
|
||||
properties?: INodeTypeDescription['properties'];
|
||||
} = {}) =>
|
||||
mock<INodeTypeDescription>({
|
||||
name,
|
||||
displayName: name,
|
||||
description: '',
|
||||
version,
|
||||
defaults: {
|
||||
name,
|
||||
},
|
||||
defaultVersion: Array.isArray(version) ? version[version.length - 1] : version,
|
||||
properties: [],
|
||||
properties: properties as [],
|
||||
maxNodes: Infinity,
|
||||
group: EXECUTABLE_TRIGGER_NODE_TYPES.includes(name) ? ['trigger'] : [],
|
||||
inputs,
|
||||
|
|
|
@ -2050,6 +2050,36 @@ describe('useCanvasOperations', () => {
|
|||
expect(workflowsStore.setConnections).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it('should initialize node data from node type description', () => {
|
||||
const nodeTypesStore = mockedStore(useNodeTypesStore);
|
||||
const type = SET_NODE_TYPE;
|
||||
const version = 1;
|
||||
const expectedDescription = mockNodeTypeDescription({
|
||||
name: type,
|
||||
version,
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Value',
|
||||
name: 'value',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
nodeTypesStore.nodeTypes = { [type]: { [version]: expectedDescription } };
|
||||
|
||||
const workflow = createTestWorkflow({
|
||||
nodes: [createTestNode()],
|
||||
connections: {},
|
||||
});
|
||||
|
||||
const { initializeWorkspace } = useCanvasOperations({ router });
|
||||
initializeWorkspace(workflow);
|
||||
|
||||
expect(workflow.nodes[0].parameters).toEqual({ value: true });
|
||||
});
|
||||
});
|
||||
|
||||
function buildImportNodes() {
|
||||
|
|
|
@ -778,8 +778,8 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
|
|||
parameters,
|
||||
};
|
||||
|
||||
resolveNodeParameters(nodeData);
|
||||
resolveNodeName(nodeData);
|
||||
resolveNodeParameters(nodeData, nodeTypeDescription);
|
||||
resolveNodeWebhook(nodeData, nodeTypeDescription);
|
||||
|
||||
return nodeData;
|
||||
|
@ -828,10 +828,9 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
|
|||
return nodeVersion;
|
||||
}
|
||||
|
||||
function resolveNodeParameters(node: INodeUi) {
|
||||
const nodeType = nodeTypesStore.getNodeType(node.type, node.typeVersion);
|
||||
function resolveNodeParameters(node: INodeUi, nodeTypeDescription: INodeTypeDescription) {
|
||||
const nodeParameters = NodeHelpers.getNodeParameters(
|
||||
nodeType?.properties ?? [],
|
||||
nodeTypeDescription?.properties ?? [],
|
||||
node.parameters,
|
||||
true,
|
||||
false,
|
||||
|
@ -1381,7 +1380,10 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
|
|||
workflowHelpers.initState(data);
|
||||
|
||||
data.nodes.forEach((node) => {
|
||||
const nodeTypeDescription = requireNodeTypeDescription(node.type, node.typeVersion);
|
||||
nodeHelpers.matchCredentials(node);
|
||||
resolveNodeParameters(node, nodeTypeDescription);
|
||||
resolveNodeWebhook(node, nodeTypeDescription);
|
||||
});
|
||||
|
||||
workflowsStore.setNodes(data.nodes);
|
||||
|
|
Loading…
Reference in a new issue