From 38ffcfeb292c6e9df0c89a4ef5364cdb8e23ccdd Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Thu, 21 Jul 2022 21:13:53 +0200 Subject: [PATCH] feat: rich rendering of flows --- .../lib/components/FlowStatusViewer.svelte | 5 +- frontend/src/lib/components/FlowViewer.svelte | 100 ++++++++++++++++++ frontend/src/lib/utils.ts | 8 ++ .../src/routes/flows/get/[...path].svelte | 10 +- 4 files changed, 113 insertions(+), 10 deletions(-) create mode 100644 frontend/src/lib/components/FlowViewer.svelte diff --git a/frontend/src/lib/components/FlowStatusViewer.svelte b/frontend/src/lib/components/FlowStatusViewer.svelte index 1f83e626ec..654a5f426b 100644 --- a/frontend/src/lib/components/FlowStatusViewer.svelte +++ b/frontend/src/lib/components/FlowStatusViewer.svelte @@ -1,6 +1,6 @@ + + + {@html github} + + +{#if !embedded} + +{/if} +{#if tab == 'ui'} +
+

+ {flow.value.modules.length} Steps + +

+
    + {#each flow.value.modules ?? [] as mod, i} +
  • +
    + {#if i < (flow.value.modules ?? []).length - 1} +
    +
  • + {/each} +
+
+{:else} + +{/if} diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts index 6b28ec4556..55a48f93fb 100644 --- a/frontend/src/lib/utils.ts +++ b/frontend/src/lib/utils.ts @@ -402,3 +402,11 @@ export function setInputCat(type: string | undefined, format: string | undefined return 'string' } } + +export function scriptPathToHref(path: string): string { + if (path.startsWith('hub/')) { + return 'https://hub.windmill.dev/scripts/get/' + path.substring(4) + } else { + return `/scripts/get/${path}` + } +} diff --git a/frontend/src/routes/flows/get/[...path].svelte b/frontend/src/routes/flows/get/[...path].svelte index 9d7365cfb4..8f60e1f2b9 100644 --- a/frontend/src/routes/flows/get/[...path].svelte +++ b/frontend/src/routes/flows/get/[...path].svelte @@ -11,10 +11,7 @@ faCalendar, faShare } from '@fortawesome/free-solid-svg-icons' - import Highlight from 'svelte-highlight' - import json from 'svelte-highlight/languages/json' - import github from 'svelte-highlight/styles/github' import Tooltip from '$lib/components/Tooltip.svelte' import ShareModal from '$lib/components/ShareModal.svelte' import { userStore, workspaceStore } from '$lib/stores' @@ -23,6 +20,7 @@ import SchemaViewer from '$lib/components/SchemaViewer.svelte' import Dropdown from '$lib/components/Dropdown.svelte' import CenteredPage from '$lib/components/CenteredPage.svelte' + import FlowViewer from '$lib/components/FlowViewer.svelte' let flow: Flow | undefined let can_write = false @@ -47,10 +45,6 @@ } - - {@html github} - -

@@ -190,7 +184,7 @@

Flow

- +
{/if}