diff --git a/web/src/components/pipeline/ImportPipeline.vue b/web/src/components/pipeline/ImportPipeline.vue index ce26653611..199332d181 100644 --- a/web/src/components/pipeline/ImportPipeline.vue +++ b/web/src/components/pipeline/ImportPipeline.vue @@ -344,39 +344,6 @@ along with this program. If not, see . - - {{ errorMessage.message }} -
- - -
-
{{ errorMessage.message }}
. outlined filled dense - @update:model-value="updateFunctionName(userSelectedFunctionName[index],index)" + @update:model-value="updateFunctionName(userSelectedFunctionName[errorMessage.nodeIndex], index, errorMessage.nodeIndex)" :rules="[(val: any) => !!val || 'Field is required!']" style="width: 300px" />
+ { - jsonArrayOfObj.value[index].nodes.forEach((node: any) => { - if(node.io_type == "default" && node.data.node_type == "function"){ - node.data.name = functionName; - } - }); jsonStr.value = JSON.stringify(jsonArrayOfObj.value, null, 2); }; + watch(jsonFiles, async (newVal:any, oldVal:any) => { if (newVal && newVal.length > 0) { @@ -999,14 +978,20 @@ along with this program. If not, see . }; const validateNodesForOrg = (input: any) => { return input.nodes.some((node: any) => { - return !node.data.org_id || (node.data.org_id != store.state.selectedOrganization.identifier) - }) ? false : true; // If condition is met (returns true), return false, otherwise return true - } + const isFunction = node.data.node_type === 'function'; + const isCondition = node.data.node_type === 'condition'; + const orgId = node.data.org_id; + const selectedOrgId = store.state.selectedOrganization.identifier; + + return !isFunction && !isCondition && (!orgId || orgId !== selectedOrgId); + }) ? false : true; + }; + const validatePipelineInputs = async (input: any, index: number) => { - let pipelineErrors: (string | { message: string; field: string })[] = []; + let pipelineErrors: (string | { message: string; field: string; nodeIndex?: number; currentValue?: string })[] = []; // 1. validate name it should not be empty if(!input.name.trim() || input.name.trim() === ""){ @@ -1131,14 +1116,27 @@ along with this program. If not, see . } //validate function node in pipeline - const validateFunctionNode = async (input: any) => { - const isValid = !input.nodes.some((node: any) => { - return node.io_type == "default" && - node.data.node_type == "function" && - (!node.data.name || !existingFunctions.value.includes(node.data.name)); + //this function helps in validating the function node and pushing the errors to the pipelineErrors array + //we track the function counter to get the correct node index because all nodes are not function nodes + //we use the nodeIndex to push the error to the correct node + const validateFunctionNode = (input: any, pipelineIndex: number) => { + let functionCounter = 0; + + input.nodes.forEach((node: any, nodeIndex: number) => { + if (node.io_type === "default" && node.data.node_type === "function") { + functionCounter++; + + if (!node.data.name || !existingFunctions.value.includes(node.data.name)) { + pipelineErrors.push({ + message: `Pipeline - ${pipelineIndex}, Function-${functionCounter}: Function name is required and should be in the existing functions list`, + field: `function_name_${nodeIndex}`, + nodeIndex: nodeIndex, + }); + } + } }); - return isValid; - } + }; + const validateConditionNode = (input: any) => { const isValid = !input.nodes.some((node: any) => { return node.io_type == "default" && @@ -1147,11 +1145,7 @@ along with this program. If not, see . }); return isValid; } - - const isValidFunctionNode = await validateFunctionNode(input); - if(!isValidFunctionNode){ - pipelineErrors.push({ message: `Pipeline - ${index}: Function name is required and should be in the existing functions list`, field: "function_name" }); - } + validateFunctionNode(input, index); //validate condition node if(!validateConditionNode(input)){ pipelineErrors.push({ message: `Pipeline - ${index}: Condition is required`, field: "empty_condition" });