diff --git a/frontend/src/lib/components/raw_apps/RawAppInlineScriptRunnable.svelte b/frontend/src/lib/components/raw_apps/RawAppInlineScriptRunnable.svelte index ca48eb74dc..2291ed4569 100644 --- a/frontend/src/lib/components/raw_apps/RawAppInlineScriptRunnable.svelte +++ b/frontend/src/lib/components/raw_apps/RawAppInlineScriptRunnable.svelte @@ -10,7 +10,7 @@ type UserAppInput, type CtxAppInput } from '../apps/inputType' - import { createEventDispatcher } from 'svelte' + import { createEventDispatcher, untrack } from 'svelte' import RawAppInlineScriptEditor from './RawAppInlineScriptEditor.svelte' import { Pane, Splitpanes } from 'svelte-splitpanes' import Tabs from '../common/tabs/Tabs.svelte' @@ -75,7 +75,7 @@ } } - let selectedTab = $state('test') + let selectedTab = $state(isRunnableByPath(runnable) ? 'view' : 'test') let args = $state({}) let hubFlowPreview: OpenFlow | undefined = $state(undefined) @@ -125,6 +125,16 @@ } }) + // 'view' only exists in the runnable-by-path layout: land on it there, leave it otherwise + let isByPath = $derived(isRunnableByPath(runnable)) + $effect(() => { + if (isByPath) { + untrack(() => (selectedTab = 'view')) + } else if (untrack(() => selectedTab) == 'view') { + untrack(() => (selectedTab = 'test')) + } + }) + // Helper to get actual ctx value for testing function getCtxValue(expr: string): any { switch (expr) { @@ -199,41 +209,188 @@ bind:job={testJob} /> -{#if isRunnableByPath(runnable) || (isRunnableByName(runnable) && runnable.inlineScript)} +{#snippet inputsPanel()} + {#if runnable?.fields} +
+ {#each Object.keys(runnable.fields) as k} + {@const meta = runnable.fields[k]} + + {/each} +
+ {:else} +
No inputs
+ {/if} +{/snippet} + +{#snippet testPanel()} + {#if debugMode && isDebuggableScript} +
+ inlineScriptEditor?.startDebugging() ?? Promise.resolve()} + onStop={() => inlineScriptEditor?.stopDebugging() ?? Promise.resolve()} + onContinue={() => inlineScriptEditor?.continueExecution() ?? Promise.resolve()} + onStepOver={() => inlineScriptEditor?.stepOver() ?? Promise.resolve()} + onStepIn={() => inlineScriptEditor?.stepIn() ?? Promise.resolve()} + onStepOut={() => inlineScriptEditor?.stepOut() ?? Promise.resolve()} + onClearBreakpoints={() => inlineScriptEditor?.clearAllBreakpoints()} + onExitDebug={() => inlineScriptEditor?.toggleDebugMode()} + /> +
+ {/if} + + + +
+
+ { + if (jobLoader) { + await jobLoader.cancelJob() + } + }} + size="md" + /> +
+ v.type == 'static') + .map(([k]) => k)} + schema={runnable ? getSchema(runnable) : {}} + bind:args + /> +
+
+ + {#if showDebugPanel || hasDebugResult} + + + + + + + + {#if hasDebugResult} +
+ +
+ {:else} +
+ {#if $debugState.running && !$debugState.stopped} + Running... + {:else if $debugState.stopped} + Paused at breakpoint + {:else} + Waiting for debug session + {/if} +
+ {/if} +
+
+
+ + + +
+ {:else if debugMode && isDebuggableScript} +
+ Click "Debug" in the toolbar to start debugging +
+ {:else} + + {/if} +
+
+
+{/snippet} + +{#if isRunnableByPath(runnable)} +
+ + + + + {#snippet content()} +
+ {#if selectedTab == 'inputs'} + {@render inputsPanel()} + {:else if selectedTab == 'test'} + {@render testPanel()} + {:else} + fork(e.detail)} + on:delete + {id} + isLoading={testIsLoading} + onRun={testPreview} + onCancel={async () => { + if (jobLoader) { + await jobLoader.cancelJob() + } + }} + /> + {/if} +
+ {/snippet} +
+
+{:else if isRunnableByName(runnable) && runnable.inlineScript} - {#if isRunnableByName(runnable)} - dispatch('createScriptFromInlineScript', runnable)} - {id} - bind:inlineScript={runnable.inlineScript} - bind:name={runnable.name} - bind:fields={runnable.fields} - bind:delete_after_secs={runnable.delete_after_secs} - onRun={testPreview} - on:delete - path={appPath} - {onSelectionChange} - /> - {:else if isRunnableByPath(runnable)} - fork(e.detail)} - on:delete - {id} - isLoading={testIsLoading} - onRun={testPreview} - onCancel={async () => { - if (jobLoader) { - await jobLoader.cancelJob() - } - }} - /> - {/if} + dispatch('createScriptFromInlineScript', runnable)} + {id} + bind:inlineScript={runnable.inlineScript} + bind:name={runnable.name} + bind:fields={runnable.fields} + bind:delete_after_secs={runnable.delete_after_secs} + onRun={testPreview} + on:delete + path={appPath} + {onSelectionChange} + /> @@ -241,135 +398,9 @@ {#snippet content()} {#if selectedTab == 'inputs'} - {#if runnable?.fields} -
- {#each Object.keys(runnable.fields) as k} - {@const meta = runnable.fields[k]} - - {/each} -
- {:else} -
No inputs
- {/if} - {:else if selectedTab == 'test'} - {#if debugMode && isDebuggableScript} -
- inlineScriptEditor?.startDebugging() ?? Promise.resolve()} - onStop={() => inlineScriptEditor?.stopDebugging() ?? Promise.resolve()} - onContinue={() => inlineScriptEditor?.continueExecution() ?? Promise.resolve()} - onStepOver={() => inlineScriptEditor?.stepOver() ?? Promise.resolve()} - onStepIn={() => inlineScriptEditor?.stepIn() ?? Promise.resolve()} - onStepOut={() => inlineScriptEditor?.stepOut() ?? Promise.resolve()} - onClearBreakpoints={() => inlineScriptEditor?.clearAllBreakpoints()} - onExitDebug={() => inlineScriptEditor?.toggleDebugMode()} - /> -
- {/if} - - - -
-
- { - if (jobLoader) { - await jobLoader.cancelJob() - } - }} - size="md" - /> -
- v.type == 'static') - .map(([k]) => k)} - schema={runnable ? getSchema(runnable) : {}} - bind:args - /> -
-
- - {#if showDebugPanel || hasDebugResult} - - - - - - - - {#if hasDebugResult} -
- -
- {:else} -
- {#if $debugState.running && !$debugState.stopped} - Running... - {:else if $debugState.stopped} - Paused at breakpoint - {:else} - Waiting for debug session - {/if} -
- {/if} -
-
-
- - - -
- {:else if debugMode && isDebuggableScript} -
- Click "Debug" in the toolbar to start debugging -
- {:else} - - {/if} -
-
-
+ {@render inputsPanel()} + {:else} + {@render testPanel()} {/if} {/snippet}