From 7837de5343e25b77a12c6539a0a0cc542d0fb026 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 14 Sep 2023 17:44:21 -0300 Subject: [PATCH] update satus logic to comprehend group component --- .../src/CustomNodes/GenericNode/index.tsx | 6 +++--- src/frontend/src/utils/reactflowUtils.ts | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index accf96afa..03c3af4c6 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -1,4 +1,4 @@ -import { cloneDeep } from "lodash"; +import { cloneDeep, get } from "lodash"; import { useContext, useEffect, useState } from "react"; import { NodeToolbar, XYPosition, useUpdateNodeInternals } from "reactflow"; import ShadTooltip from "../../components/ShadTooltipComponent"; @@ -10,7 +10,7 @@ import { typesContext } from "../../contexts/typesContext"; import NodeToolbarComponent from "../../pages/FlowPage/components/nodeToolbarComponent"; import { validationStatusType } from "../../types/components"; import { NodeDataType } from "../../types/flow"; -import { cleanEdges, scapedJSONStringfy } from "../../utils/reactflowUtils"; +import { cleanEdges, getGroupStatus, scapedJSONStringfy } from "../../utils/reactflowUtils"; import { nodeColors, nodeIconsLucide } from "../../utils/styleUtils"; import { classNames, toTitleCase } from "../../utils/utils"; import ParameterComponent from "./components/parameterComponent"; @@ -58,7 +58,7 @@ export default function GenericNode({ // New useEffect to watch for changes in sseData and update validation status useEffect(() => { - const relevantData = sseData[data.id]; + const relevantData = data.node?.flow?getGroupStatus(data.node.flow,sseData):sseData[data.id]; if (relevantData) { // Extract validation information from relevantData and update the validationStatus state setValidationStatus(relevantData); diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index 7a9cf2b02..ee4c6cc78 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -871,3 +871,18 @@ export function processFlow(FlowObject: ReactFlowJsonObject) { }); return clonedFLow; } + +export function getGroupStatus(flow: FlowType,ssData:{[key:string]:{valid:boolean,params:string}}) { + let Nodestatus:Array = []; + const {nodes} = flow.data!; + const ids = nodes.map((n:NodeType) => n.data.id); + ids.forEach((id) => { + if(!ssData[id]){ + return ssData[id]; + } + if(!ssData[id].valid){ + return {valid:false,params:ssData[id].params} + } + }) + return {valid:true,params:"Built sucessfully ✨"} +} \ No newline at end of file