From 84eefadfcf06b4f38117b6c4c534f47fb2ef7cc7 Mon Sep 17 00:00:00 2001 From: Faton Ramadani Date: Wed, 25 Sep 2024 16:22:02 +0200 Subject: [PATCH] feat(frontend): Catch flow errors in the UI (#4429) * feat(frontend): Catch flow errors in the UI * feat(frontend): typo --- .../flows/content/FlowConstants.svelte | 2 +- .../lib/components/graph/FlowGraphV2.svelte | 141 ++-- .../src/lib/components/graph/graphBuilder.ts | 783 ++++++++++-------- 3 files changed, 500 insertions(+), 426 deletions(-) diff --git a/frontend/src/lib/components/flows/content/FlowConstants.svelte b/frontend/src/lib/components/flows/content/FlowConstants.svelte index 4b8185531a661..df0688f177581 100644 --- a/frontend/src/lib/components/flows/content/FlowConstants.svelte +++ b/frontend/src/lib/components/flows/content/FlowConstants.svelte @@ -121,7 +121,7 @@ {/if} {/if} - {#each steps as [args, filter, m] (m.id)} + {#each steps as [args, filter, m], index (m.id + index)} {#if filter.length > 0}

diff --git a/frontend/src/lib/components/graph/FlowGraphV2.svelte b/frontend/src/lib/components/graph/FlowGraphV2.svelte index 680fadd534a6b..4a990b4ec6e68 100644 --- a/frontend/src/lib/components/graph/FlowGraphV2.svelte +++ b/frontend/src/lib/components/graph/FlowGraphV2.svelte @@ -32,6 +32,9 @@ import { encodeState } from '$lib/utils' import BranchOneStart from './renderers/nodes/BranchOneStart.svelte' import NoBranchNode from './renderers/nodes/NoBranchNode.svelte' + import { Alert, Drawer } from '../common' + import Button from '../common/button/Button.svelte' + import FlowYamlEditor from '../flows/header/FlowYamlEditor.svelte' export let success: boolean | undefined = undefined export let modules: FlowModule[] | undefined = [] @@ -178,6 +181,10 @@ let height = 0 function updateStores() { + if (graph.error) { + return + } + $nodes = layoutNodes(graph?.nodes) $edges = graph.edges @@ -236,69 +243,87 @@ onMount(() => { centerViewport(width) }) + let yamlEditorDrawer: Drawer | undefined = undefined + +
- -
- - {#if download} - { - try { - localStorage.setItem( - 'svelvet', - encodeState({ modules, failureModule, preprocessorModule }) - ) - } catch (e) { - console.error('error interacting with local storage', e) - } - window.open('/view_graph', '_blank') - }} - class="!bg-surface" + {#if graph?.error} +
+ + {graph.error} + + - - - {/if} - - - +
+ {:else} + - {#if showDataflow} - { - $useDataflow = !$useDataflow - }} - size="xs" - options={{ - right: 'Dataflow' - }} - /> - {/if} -
- +
+ + {#if download} + { + try { + localStorage.setItem( + 'svelvet', + encodeState({ modules, failureModule, preprocessorModule }) + ) + } catch (e) { + console.error('error interacting with local storage', e) + } + window.open('/view_graph', '_blank') + }} + class="!bg-surface" + > + + + {/if} + + + + {#if showDataflow} + { + $useDataflow = !$useDataflow + }} + size="xs" + options={{ + right: 'Dataflow' + }} + /> + {/if} + + + {/if}