diff --git a/frontend/src/lib/components/FlowBuilder.svelte b/frontend/src/lib/components/FlowBuilder.svelte index cf870d4332..3b29507f41 100644 --- a/frontend/src/lib/components/FlowBuilder.svelte +++ b/frontend/src/lib/components/FlowBuilder.svelte @@ -81,6 +81,7 @@ import CustomPopover from './CustomPopover.svelte' import Summary from './Summary.svelte' import type { FlowBuilderWhitelabelCustomUi } from './custom_ui' + import FlowYamlEditor from './flows/header/FlowYamlEditor.svelte' export let initialPath: string = '' export let pathStoreInit: string | undefined = undefined @@ -1007,6 +1008,7 @@ let flowTutorials: FlowTutorials | undefined = undefined let jsonViewerDrawer: Drawer | undefined = undefined + let yamlEditorDrawer: Drawer | undefined = undefined let flowHistory: FlowHistory | undefined = undefined export function triggerTutorial() { @@ -1049,6 +1051,11 @@ displayName: 'Export', icon: FileJson, action: () => jsonViewerDrawer?.openDrawer() + }, + { + displayName: 'Edit in YAML', + icon: FileJson, + action: () => yamlEditorDrawer?.openDrawer() } ] : []) @@ -1069,6 +1076,7 @@ {#if $pathStore} {/if} + { diff --git a/frontend/src/lib/components/FlowViewerInner.svelte b/frontend/src/lib/components/FlowViewerInner.svelte index 9961ca419a..7fd487ee43 100644 --- a/frontend/src/lib/components/FlowViewerInner.svelte +++ b/frontend/src/lib/components/FlowViewerInner.svelte @@ -9,6 +9,7 @@ import YAML from 'yaml' import { yaml } from 'svelte-highlight/languages' import HighlightTheme from './HighlightTheme.svelte' + import { filteredContentForExport } from './flows/utils' export let flow: { summary: string @@ -17,12 +18,7 @@ schema?: any } - $: flowFiltered = { - summary: flow.summary, - description: flow.description, - value: flow.value, - schema: flow.schema - } + $: flowFiltered = filteredContentForExport(flow) let rawType: 'json' | 'yaml' = 'yaml' diff --git a/frontend/src/lib/components/WorkerTagPicker.svelte b/frontend/src/lib/components/WorkerTagPicker.svelte index 29fbbadfd7..a00278b780 100644 --- a/frontend/src/lib/components/WorkerTagPicker.svelte +++ b/frontend/src/lib/components/WorkerTagPicker.svelte @@ -18,7 +18,7 @@ - {#if workerTags} + {#if $workerTags} {#if $workerTags?.length ?? 0 > 0} Worker Group Tag {/if} + {#if tag && tag != '' && !($workerTags ?? []).includes(tag)} + {tag} + {/if} {#each $workerTags ?? [] as tag (tag)} {tag} {/each} diff --git a/frontend/src/lib/components/flows/content/FlowSettings.svelte b/frontend/src/lib/components/flows/content/FlowSettings.svelte index 46443d2b07..34ce8692b8 100644 --- a/frontend/src/lib/components/flows/content/FlowSettings.svelte +++ b/frontend/src/lib/components/flows/content/FlowSettings.svelte @@ -13,7 +13,7 @@ import { getContext } from 'svelte' import type { FlowEditorContext } from '../types' import Slider from '$lib/components/Slider.svelte' - import { enterpriseLicense, workerTags, workspaceStore } from '$lib/stores' + import { enterpriseLicense, workspaceStore } from '$lib/stores' import { isCloudHosted } from '$lib/cloud' import { copyToClipboard } from '$lib/utils' import Tooltip from '$lib/components/Tooltip.svelte' @@ -36,10 +36,6 @@ $: url = `${hostname}/api/w/${$workspaceStore}/jobs/run/f/${$pathStore}` $: syncedUrl = `${hostname}/api/w/${$workspaceStore}/jobs/run_wait_result/f/${$pathStore}` - $: if ($selectedId == 'settings-worker-group') { - $workerTags = undefined - } - function asSchema(x: any) { return x as Schema } diff --git a/frontend/src/lib/components/flows/header/FlowYamlEditor.svelte b/frontend/src/lib/components/flows/header/FlowYamlEditor.svelte new file mode 100644 index 0000000000..e1f268c738 --- /dev/null +++ b/frontend/src/lib/components/flows/header/FlowYamlEditor.svelte @@ -0,0 +1,62 @@ + + + + drawer?.toggleDrawer()}> + + Reset code + Apply changes + + + {#if $flowStore} + + {/if} + + diff --git a/frontend/src/lib/components/flows/types.ts b/frontend/src/lib/components/flows/types.ts index 6e5f830def..ba8ce95c5b 100644 --- a/frontend/src/lib/components/flows/types.ts +++ b/frontend/src/lib/components/flows/types.ts @@ -19,6 +19,13 @@ export type FlowInput = Record< } > +export type ExtendedOpenFlow = OpenFlow & { + tag?: string + ws_error_handler_muted?: boolean + dedicated_worker?: boolean + visible_to_runner_only?: boolean +} + export type FlowEditorContext = { selectedId: Writable moving: Writable<{ module: FlowModule; modules: FlowModule[] } | undefined> @@ -27,14 +34,7 @@ export type FlowEditorContext = { scriptEditorDrawer: Writable history: History pathStore: Writable - flowStore: Writable< - OpenFlow & { - tag?: string - ws_error_handler_muted?: boolean - dedicated_worker?: boolean - visible_to_runner_only?: boolean - } - > + flowStore: Writable flowStateStore: Writable testStepStore: Writable> saveDraft: () => void diff --git a/frontend/src/lib/components/flows/utils.ts b/frontend/src/lib/components/flows/utils.ts index 545d553e8c..11cf2f4083 100644 --- a/frontend/src/lib/components/flows/utils.ts +++ b/frontend/src/lib/components/flows/utils.ts @@ -17,6 +17,7 @@ import { NEVER_TESTED_THIS_FAR } from './models' import { sendUserToast } from '$lib/toast' import type { Schema } from '$lib/common' import { parseOutputs } from '$lib/infer' +import type { ExtendedOpenFlow } from './types' function create_context_function_template(eval_string: string, context: Record) { return ` @@ -71,6 +72,28 @@ export function evalValue( return v } +export function filteredContentForExport(flow: ExtendedOpenFlow) { + let o = { + summary: flow.summary, + description: flow.description, + value: flow.value, + schema: flow.schema + } + if (flow.dedicated_worker) { + o['dedicated_worker'] = flow.dedicated_worker + } + if (flow.visible_to_runner_only) { + o['visible_to_runner_only'] = flow.visible_to_runner_only + } + if (flow.ws_error_handler_muted) { + o['ws_error_handler_muted'] = flow.ws_error_handler_muted + } + if (flow.tag) { + o['tag'] = flow.tag + } + return o +} + export function cleanInputs(flow: OpenFlow | any): OpenFlow & { tag?: string ws_error_handler_muted?: boolean