From 07bf8311bb70b5bdd12f6223db7b12d90ecb80c0 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Date: Thu, 23 Jan 2025 16:31:07 -0300 Subject: [PATCH] fix: errors exhibition and printing (#5892) * Added onBuildError to error case on buildVertices * add onBuildError just if there's no source * refactor: Update markdown rendering in alert components * Fixed list on error * Fixed md exibition of error * Fixed exibition for component erorrs * Made errors be generated with the correct map * Removed markdown from unused places * Update src/frontend/src/utils/buildUtils.ts Co-authored-by: Cristhian Zanforlin Lousa * Update src/frontend/src/utils/buildUtils.ts Co-authored-by: Cristhian Zanforlin Lousa --------- Co-authored-by: anovazzi1 Co-authored-by: Cristhian Zanforlin Lousa --- .../components/singleAlertComponent/index.tsx | 31 ++++++++++++++- src/frontend/src/alerts/error/index.tsx | 38 ++++++++++++++++--- src/frontend/src/utils/buildUtils.ts | 8 ++-- 3 files changed, 67 insertions(+), 10 deletions(-) diff --git a/src/frontend/src/alerts/alertDropDown/components/singleAlertComponent/index.tsx b/src/frontend/src/alerts/alertDropDown/components/singleAlertComponent/index.tsx index 5cae3a091..32ebd57ea 100644 --- a/src/frontend/src/alerts/alertDropDown/components/singleAlertComponent/index.tsx +++ b/src/frontend/src/alerts/alertDropDown/components/singleAlertComponent/index.tsx @@ -1,5 +1,7 @@ import { CustomLink } from "@/customization/components/custom-link"; import { useState } from "react"; +import Markdown from "react-markdown"; +import remarkGfm from "remark-gfm"; import IconComponent from "../../../../components/common/genericIconComponent"; import { SingleAlertComponentType } from "../../../../types/alerts"; @@ -28,10 +30,35 @@ export default function SingleAlert({ {dropItem.list ? (
-
    +
      {dropItem.list.map((item, idx) => (
    • - {item} + ( + + {props.children} + + ), + p({ node, ...props }) { + return ( + + {props.children} + + ); + }, + }} + > + {Array.isArray(item) ? item.join("\n") : item} +
    • ))}
    diff --git a/src/frontend/src/alerts/error/index.tsx b/src/frontend/src/alerts/error/index.tsx index 1e4e54b10..d88f44558 100644 --- a/src/frontend/src/alerts/error/index.tsx +++ b/src/frontend/src/alerts/error/index.tsx @@ -1,5 +1,7 @@ import { Transition } from "@headlessui/react"; import { useEffect, useState } from "react"; +import Markdown from "react-markdown"; +import remarkGfm from "remark-gfm"; import IconComponent from "../../components/common/genericIconComponent"; import { ErrorAlertType } from "../../types/alerts"; @@ -23,7 +25,6 @@ export default function ErrorAlert({ return ( {title} {list?.length !== 0 && list?.some((item) => item !== null && item !== undefined) ? ( -
    -
      +
      +
        {list.map((item, index) => ( -
      • - {item} +
      • + + ( + + {props.children} + + ), + p({ node, ...props }) { + return ( + + {props.children} + + ); + }, + }} + > + {Array.isArray(item) ? item.join("\n") : item} + +
      • ))}
      diff --git a/src/frontend/src/utils/buildUtils.ts b/src/frontend/src/utils/buildUtils.ts index c4dbe047e..4ff24a63d 100644 --- a/src/frontend/src/utils/buildUtils.ts +++ b/src/frontend/src/utils/buildUtils.ts @@ -248,7 +248,7 @@ export async function buildFlowVertices({ if (!buildData.valid) { // lots is a dictionary with the key the output field name and the value the log object // logs: { [key: string]: { message: any; type: string }[] }; - const errorMessages = Object.keys(buildData.data.outputs).map( + const errorMessages = Object.keys(buildData.data.outputs).flatMap( (key) => { const outputs = buildData.data.outputs[key]; if (Array.isArray(outputs)) { @@ -317,9 +317,11 @@ export async function buildFlowVertices({ return true; } case "error": { - useFlowStore.getState().setIsBuilding(false); - if (data.category === "error") { + if (data?.category === "error") { useMessagesStore.getState().addMessage(data); + if (data?.properties?.source?.id === null) { + onBuildError!("Error Building Flow", [data.text]); + } } buildResults.push(false); return true;