From fd886b585a97502b53fd480fd1a1ee486463f1e5 Mon Sep 17 00:00:00 2001 From: Mutasem Date: Fri, 5 Nov 2021 14:46:31 +0100 Subject: [PATCH] handle unknown types --- .../editor-ui/src/components/NodeCredentials.vue | 2 +- .../editor-ui/src/components/NodeSettings.vue | 5 ++++- .../editor-ui/src/components/NodeWebhooks.vue | 2 +- packages/editor-ui/src/components/RunData.vue | 5 +++-- .../editor-ui/src/components/mixins/nodeBase.ts | 4 ++-- .../src/components/mixins/workflowHelpers.ts | 6 +++--- packages/editor-ui/src/views/NodeView.vue | 16 ++++++++-------- 7 files changed, 22 insertions(+), 18 deletions(-) diff --git a/packages/editor-ui/src/components/NodeCredentials.vue b/packages/editor-ui/src/components/NodeCredentials.vue index cc2d63c2c2..3637b2df38 100644 --- a/packages/editor-ui/src/components/NodeCredentials.vue +++ b/packages/editor-ui/src/components/NodeCredentials.vue @@ -101,7 +101,7 @@ export default mixins( credentialTypesNodeDescription (): INodeCredentialDescription[] { const node = this.node as INodeUi; - const activeNodeType = this.$store.getters.nodeType(node.type) as INodeTypeDescription; + const activeNodeType = this.$store.getters.nodeType(node.type) as INodeTypeDescription | null; if (activeNodeType && activeNodeType.credentials) { return activeNodeType.credentials; } diff --git a/packages/editor-ui/src/components/NodeSettings.vue b/packages/editor-ui/src/components/NodeSettings.vue index ae8316ce3a..3db16ffbf8 100644 --- a/packages/editor-ui/src/components/NodeSettings.vue +++ b/packages/editor-ui/src/components/NodeSettings.vue @@ -353,7 +353,10 @@ export default mixins( } else if (parameterData.name.startsWith('parameters.')) { // A node parameter changed - const nodeType = this.$store.getters.nodeType(node.type); + const nodeType = this.$store.getters.nodeType(node.type) as INodeTypeDescription | null; + if (!nodeType) { + return; + } // Get only the parameters which are different to the defaults let nodeParameters = NodeHelpers.getNodeParameters(nodeType.properties, node.parameters, false, false); diff --git a/packages/editor-ui/src/components/NodeWebhooks.vue b/packages/editor-ui/src/components/NodeWebhooks.vue index c08ec51f54..ef7c8fb2c5 100644 --- a/packages/editor-ui/src/components/NodeWebhooks.vue +++ b/packages/editor-ui/src/components/NodeWebhooks.vue @@ -64,7 +64,7 @@ export default mixins( ], data () { return { - isMinimized: this.nodeType.name !== WEBHOOK_NODE_TYPE, + isMinimized: this.nodeType && this.nodeType.name !== WEBHOOK_NODE_TYPE, showUrlFor: 'test', }; }, diff --git a/packages/editor-ui/src/components/RunData.vue b/packages/editor-ui/src/components/RunData.vue index 925c23d8a3..98592dd056 100644 --- a/packages/editor-ui/src/components/RunData.vue +++ b/packages/editor-ui/src/components/RunData.vue @@ -203,6 +203,7 @@ import { IBinaryKeyData, IDataObject, INodeExecutionData, + INodeTypeDescription, IRunData, IRunExecutionData, ITaskData, @@ -529,8 +530,8 @@ export default mixins( return outputIndex + 1; } - const nodeType = this.$store.getters.nodeType(this.node.type); - if (!nodeType.hasOwnProperty('outputNames') || nodeType.outputNames.length <= outputIndex) { + const nodeType = this.$store.getters.nodeType(this.node.type) as INodeTypeDescription | null; + if (!nodeType || !nodeType.outputNames || nodeType.outputNames.length <= outputIndex) { return outputIndex + 1; } diff --git a/packages/editor-ui/src/components/mixins/nodeBase.ts b/packages/editor-ui/src/components/mixins/nodeBase.ts index c9899530b1..d940202e50 100644 --- a/packages/editor-ui/src/components/mixins/nodeBase.ts +++ b/packages/editor-ui/src/components/mixins/nodeBase.ts @@ -314,10 +314,10 @@ export const nodeBase = mixins( }); }, __addNode (node: INodeUi) { - let nodeTypeData = this.$store.getters.nodeType(node.type); + let nodeTypeData = this.$store.getters.nodeType(node.type) as INodeTypeDescription | null; if (!nodeTypeData) { // If node type is not know use by default the base.noOp data to display it - nodeTypeData = this.$store.getters.nodeType(NO_OP_NODE_TYPE); + nodeTypeData = this.$store.getters.nodeType(NO_OP_NODE_TYPE) as INodeTypeDescription; } this.__addInputEndpoints(node, nodeTypeData); diff --git a/packages/editor-ui/src/components/mixins/workflowHelpers.ts b/packages/editor-ui/src/components/mixins/workflowHelpers.ts index c0a6d4fb02..54ec15750a 100644 --- a/packages/editor-ui/src/components/mixins/workflowHelpers.ts +++ b/packages/editor-ui/src/components/mixins/workflowHelpers.ts @@ -225,7 +225,7 @@ export const workflowHelpers = mixins( return []; }, getByName: (nodeType: string): INodeType | INodeVersionedType | undefined => { - const nodeTypeDescription = this.$store.getters.nodeType(nodeType); + const nodeTypeDescription = this.$store.getters.nodeType(nodeType) as INodeTypeDescription | null; if (nodeTypeDescription === null) { return undefined; @@ -236,7 +236,7 @@ export const workflowHelpers = mixins( }; }, getByNameAndVersion: (nodeType: string, version?: number): INodeType | undefined => { - const nodeTypeDescription = this.$store.getters.nodeType(nodeType, version); + const nodeTypeDescription = this.$store.getters.nodeType(nodeType, version) as INodeTypeDescription | null; if (nodeTypeDescription === null) { return undefined; @@ -329,7 +329,7 @@ export const workflowHelpers = mixins( // Get the data of the node type that we can get the default values // TODO: Later also has to care about the node-type-version as defaults could be different - const nodeType = this.$store.getters.nodeType(node.type, node.typeVersion) as INodeTypeDescription; + const nodeType = this.$store.getters.nodeType(node.type, node.typeVersion) as INodeTypeDescription | null; if (nodeType !== null) { // Node-Type is known so we can save the parameters correctly diff --git a/packages/editor-ui/src/views/NodeView.vue b/packages/editor-ui/src/views/NodeView.vue index 12b753229f..6a146b5462 100644 --- a/packages/editor-ui/src/views/NodeView.vue +++ b/packages/editor-ui/src/views/NodeView.vue @@ -1151,7 +1151,7 @@ export default mixins( let yOffset = 0; if (lastSelectedConnection) { - const sourceNodeType = this.$store.getters.nodeType(lastSelectedNode.type); + const sourceNodeType = this.$store.getters.nodeType(lastSelectedNode.type) as INodeTypeDescription | null; const offsets = [[-100, 100], [-140, 0, 140], [-240, -100, 100, 240]]; if (sourceNodeType && sourceNodeType.outputs.length > 1) { const offset = offsets[sourceNodeType.outputs.length - 2]; @@ -1528,8 +1528,8 @@ export default mixins( const nodeName = (element as HTMLElement).dataset['name'] as string; const node = this.$store.getters.getNodeByName(nodeName) as INodeUi | null; if (node) { - const nodeType = this.$store.getters.nodeType(node.type) as INodeTypeDescription; - if (nodeType.inputs.length === 1) { + const nodeType = this.$store.getters.nodeType(node.type) as INodeTypeDescription | null; + if (nodeType && nodeType.inputs && nodeType.inputs.length === 1) { this.pullConnActiveNodeName = node.name; const endpoint = this.instance.getEndpoint(this.getInputEndpointUUID(nodeName, 0)); @@ -1718,8 +1718,8 @@ export default mixins( const node = this.$store.getters.getNodeByName(nodeName); - const nodeTypeData: INodeTypeDescription = this.$store.getters.nodeType(node.type); - if (nodeTypeData.maxNodes !== undefined && this.getNodeTypeCount(node.type) >= nodeTypeData.maxNodes) { + const nodeTypeData: INodeTypeDescription | null= this.$store.getters.nodeType(node.type); + if (nodeTypeData && nodeTypeData.maxNodes !== undefined && this.getNodeTypeCount(node.type) >= nodeTypeData.maxNodes) { this.showMaxNodeTypeError(nodeTypeData); return; } @@ -1880,8 +1880,8 @@ export default mixins( } // connect nodes before/after deleted node - const nodeType: INodeTypeDescription = this.$store.getters.nodeType(node.type, node.typeVersion); - if (nodeType.outputs.length === 1 + const nodeType: INodeTypeDescription | null = this.$store.getters.nodeType(node.type, node.typeVersion); + if (nodeType && nodeType.outputs.length === 1 && nodeType.inputs.length === 1) { const {incoming, outgoing} = this.getIncomingOutgoingConnections(node.name); if (incoming.length === 1 && outgoing.length === 1) { @@ -2051,7 +2051,7 @@ export default mixins( let nodeType: INodeTypeDescription | null; let foundNodeIssues: INodeIssues | null; nodes.forEach((node) => { - nodeType = this.$store.getters.nodeType(node.type, node.typeVersion); + nodeType = this.$store.getters.nodeType(node.type, node.typeVersion) as INodeTypeDescription | null; // Make sure that some properties always exist if (!node.hasOwnProperty('disabled')) {