mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-03 08:57:28 -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 = [],
|
credentials = [],
|
||||||
inputs = [NodeConnectionType.Main],
|
inputs = [NodeConnectionType.Main],
|
||||||
outputs = [NodeConnectionType.Main],
|
outputs = [NodeConnectionType.Main],
|
||||||
|
properties = [],
|
||||||
}: {
|
}: {
|
||||||
name?: INodeTypeDescription['name'];
|
name?: INodeTypeDescription['name'];
|
||||||
version?: INodeTypeDescription['version'];
|
version?: INodeTypeDescription['version'];
|
||||||
credentials?: INodeTypeDescription['credentials'];
|
credentials?: INodeTypeDescription['credentials'];
|
||||||
inputs?: INodeTypeDescription['inputs'];
|
inputs?: INodeTypeDescription['inputs'];
|
||||||
outputs?: INodeTypeDescription['outputs'];
|
outputs?: INodeTypeDescription['outputs'];
|
||||||
|
properties?: INodeTypeDescription['properties'];
|
||||||
} = {}) =>
|
} = {}) =>
|
||||||
mock<INodeTypeDescription>({
|
mock<INodeTypeDescription>({
|
||||||
name,
|
name,
|
||||||
displayName: name,
|
displayName: name,
|
||||||
|
description: '',
|
||||||
version,
|
version,
|
||||||
defaults: {
|
defaults: {
|
||||||
name,
|
name,
|
||||||
},
|
},
|
||||||
defaultVersion: Array.isArray(version) ? version[version.length - 1] : version,
|
defaultVersion: Array.isArray(version) ? version[version.length - 1] : version,
|
||||||
properties: [],
|
properties: properties as [],
|
||||||
maxNodes: Infinity,
|
maxNodes: Infinity,
|
||||||
group: EXECUTABLE_TRIGGER_NODE_TYPES.includes(name) ? ['trigger'] : [],
|
group: EXECUTABLE_TRIGGER_NODE_TYPES.includes(name) ? ['trigger'] : [],
|
||||||
inputs,
|
inputs,
|
||||||
|
|
|
@ -2050,6 +2050,36 @@ describe('useCanvasOperations', () => {
|
||||||
expect(workflowsStore.setConnections).toHaveBeenCalled();
|
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() {
|
function buildImportNodes() {
|
||||||
|
|
|
@ -778,8 +778,8 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
|
||||||
parameters,
|
parameters,
|
||||||
};
|
};
|
||||||
|
|
||||||
resolveNodeParameters(nodeData);
|
|
||||||
resolveNodeName(nodeData);
|
resolveNodeName(nodeData);
|
||||||
|
resolveNodeParameters(nodeData, nodeTypeDescription);
|
||||||
resolveNodeWebhook(nodeData, nodeTypeDescription);
|
resolveNodeWebhook(nodeData, nodeTypeDescription);
|
||||||
|
|
||||||
return nodeData;
|
return nodeData;
|
||||||
|
@ -828,10 +828,9 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
|
||||||
return nodeVersion;
|
return nodeVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveNodeParameters(node: INodeUi) {
|
function resolveNodeParameters(node: INodeUi, nodeTypeDescription: INodeTypeDescription) {
|
||||||
const nodeType = nodeTypesStore.getNodeType(node.type, node.typeVersion);
|
|
||||||
const nodeParameters = NodeHelpers.getNodeParameters(
|
const nodeParameters = NodeHelpers.getNodeParameters(
|
||||||
nodeType?.properties ?? [],
|
nodeTypeDescription?.properties ?? [],
|
||||||
node.parameters,
|
node.parameters,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
|
@ -1381,7 +1380,10 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
|
||||||
workflowHelpers.initState(data);
|
workflowHelpers.initState(data);
|
||||||
|
|
||||||
data.nodes.forEach((node) => {
|
data.nodes.forEach((node) => {
|
||||||
|
const nodeTypeDescription = requireNodeTypeDescription(node.type, node.typeVersion);
|
||||||
nodeHelpers.matchCredentials(node);
|
nodeHelpers.matchCredentials(node);
|
||||||
|
resolveNodeParameters(node, nodeTypeDescription);
|
||||||
|
resolveNodeWebhook(node, nodeTypeDescription);
|
||||||
});
|
});
|
||||||
|
|
||||||
workflowsStore.setNodes(data.nodes);
|
workflowsStore.setNodes(data.nodes);
|
||||||
|
|
Loading…
Reference in a new issue