mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-19 16:02:14 +00:00
c0aafee9a9
* Improve UI of script record * Improve UI for scripts * Remove Result & Logs loading container while flow not finised * Improve Graph view * Add click on a step mention * Fix spacing when empty * Fix step duration disappearing in recorded flows * Modernize timeline tab * Improve Script recording result UI * feat: externalize recording player controls for fake-window embedding Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor: reorder FlowViewer tab sync effects for clarity Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor: eliminate tab sync effects in FlowViewer, use selectedTab directly Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor: remove unnecessary untrack in FlowViewer tab init Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: skip tab auto-selection when selectedTab is controlled externally Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: export recording types from package Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: non-null assertion for recording.flow in FlowGraphViewer Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: replace banned $bindable(default_value) pattern and simplify tab sync Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: use svelte 5 onclick syntax on replay page Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: skip db clock endpoint during replay mode Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: remove line numbers from script recording code display Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: hugocasa <hugo@casademont.ch> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
227 lines
6.0 KiB
Svelte
227 lines
6.0 KiB
Svelte
<script lang="ts">
|
|
import { untrack } from 'svelte'
|
|
import { type FlowValue, FlowService } from '$lib/gen'
|
|
import { Tab, Tabs, TabContent } from './common'
|
|
import SchemaViewer from './SchemaViewer.svelte'
|
|
import FlowGraphViewer from './FlowGraphViewer.svelte'
|
|
import { Loader2 } from 'lucide-svelte'
|
|
import { orderedYamlStringify, cleanValueProperties, replaceFalseWithUndefined } from '$lib/utils'
|
|
import { workspaceStore } from '$lib/stores'
|
|
import { watch } from 'runed'
|
|
|
|
import HighlightTheme from './HighlightTheme.svelte'
|
|
import FlowViewerInner from './FlowViewerInner.svelte'
|
|
import FlowInputViewer from './FlowInputViewer.svelte'
|
|
|
|
interface PreviousFlow {
|
|
summary: string
|
|
description?: string
|
|
value: FlowValue
|
|
schema?: any
|
|
}
|
|
|
|
export type TabValue = 'ui' | 'raw' | 'schema' | 'diff'
|
|
|
|
interface Props {
|
|
flow: {
|
|
summary: string
|
|
description?: string
|
|
value: FlowValue
|
|
schema?: any
|
|
}
|
|
initialOpen?: number | undefined
|
|
noSide?: boolean
|
|
noGraph?: boolean
|
|
initTab?: TabValue
|
|
selectedTab?: TabValue
|
|
hideTabs?: boolean
|
|
noSummary?: boolean
|
|
noInput?: boolean
|
|
hideDefaultInputs?: boolean
|
|
showStepHint?: boolean
|
|
noGraphDownload?: boolean
|
|
availableVersions?: Array<{ id: number; deployment_msg?: string }>
|
|
selectedVersionId?: number
|
|
graphContent?: import('svelte').Snippet
|
|
}
|
|
|
|
let {
|
|
flow,
|
|
initialOpen = undefined,
|
|
noSide = false,
|
|
noGraph = false,
|
|
availableVersions = undefined,
|
|
initTab = undefined,
|
|
selectedTab = $bindable(),
|
|
hideTabs = false,
|
|
noSummary = false,
|
|
noInput = false,
|
|
hideDefaultInputs = false,
|
|
showStepHint = false,
|
|
noGraphDownload = false,
|
|
selectedVersionId = undefined,
|
|
graphContent = undefined
|
|
}: Props = $props()
|
|
|
|
let open: { [id: number]: boolean } = {}
|
|
const untrackedInitialOpen = untrack(() => initialOpen)
|
|
if (untrackedInitialOpen) {
|
|
open[untrackedInitialOpen] = true
|
|
}
|
|
|
|
let previousVersionId: number | undefined = $state(undefined)
|
|
let previousFlow: PreviousFlow | undefined = $state(undefined)
|
|
const tabControlledExternally = selectedTab !== undefined
|
|
if (!tabControlledExternally) {
|
|
selectedTab = initTab ?? 'diff'
|
|
}
|
|
|
|
let previousFlowCache: Record<number, PreviousFlow> = {}
|
|
|
|
async function loadPreviousFlow(version: number) {
|
|
try {
|
|
if (previousFlowCache[version]) {
|
|
previousFlow = previousFlowCache[version]
|
|
return
|
|
}
|
|
previousFlow = await FlowService.getFlowVersion({
|
|
workspace: $workspaceStore!,
|
|
version
|
|
})
|
|
previousFlowCache[version] = previousFlow
|
|
} catch (e) {
|
|
console.error(e)
|
|
previousFlow = undefined
|
|
}
|
|
}
|
|
|
|
// Load previous flow when previousVersionId changes
|
|
$effect.pre(() => {
|
|
if (previousVersionId !== undefined) {
|
|
loadPreviousFlow(previousVersionId)
|
|
} else {
|
|
previousFlow = undefined
|
|
}
|
|
})
|
|
|
|
$effect.pre(() => {
|
|
if (initTab || tabControlledExternally) {
|
|
return
|
|
}
|
|
if (availableVersions && availableVersions.length > 0) {
|
|
selectedTab = 'diff'
|
|
} else {
|
|
if (noGraph) {
|
|
selectedTab = 'schema'
|
|
} else {
|
|
selectedTab = 'ui'
|
|
}
|
|
}
|
|
})
|
|
|
|
// Auto-select first available version and validate current selection
|
|
watch([() => availableVersions, () => selectedVersionId], () => {
|
|
if (availableVersions && availableVersions.length > 0) {
|
|
previousVersionId = availableVersions[0].id
|
|
} else {
|
|
previousVersionId = undefined
|
|
}
|
|
})
|
|
|
|
let currentFlowYaml = $derived.by(() => {
|
|
const metadata = structuredClone(cleanValueProperties(replaceFalseWithUndefined(flow)))
|
|
return orderedYamlStringify(metadata)
|
|
})
|
|
|
|
let previousFlowYaml = $derived.by(() => {
|
|
if (!previousFlow) return undefined
|
|
const metadata = structuredClone(cleanValueProperties(replaceFalseWithUndefined(previousFlow)))
|
|
return orderedYamlStringify(metadata)
|
|
})
|
|
</script>
|
|
|
|
<HighlightTheme />
|
|
|
|
<Tabs bind:selected={selectedTab as string} {hideTabs}>
|
|
{#if availableVersions && availableVersions.length > 0}
|
|
<Tab value="diff" label="Diff" />
|
|
{/if}
|
|
{#if !noGraph}
|
|
<Tab value="ui" label="Graph" />
|
|
{/if}
|
|
<Tab value="raw" label="Raw" />
|
|
<Tab value="schema" label="Input Schema" />
|
|
|
|
{#snippet content()}
|
|
{#if availableVersions && availableVersions.length > 0}
|
|
<TabContent value="diff">
|
|
<div class="flex flex-col gap-2 h-full">
|
|
<div class="flex flex-row items-center gap-2 py-2">
|
|
<div class="text-xs">Compare with:</div>
|
|
<select bind:value={previousVersionId} class="!text-xs !w-40">
|
|
{#each availableVersions as version (version.id)}
|
|
<option value={version.id} class="!text-xs">
|
|
{version.deployment_msg ?? `Version ${version.id}`}
|
|
</option>
|
|
{/each}
|
|
</select>
|
|
</div>
|
|
|
|
{#if previousFlowYaml}
|
|
<div class="h-[calc(100vh-150px)] min-h-[400px]">
|
|
{#await import('$lib/components/FlowDiffViewer.svelte')}
|
|
<Loader2 class="animate-spin" />
|
|
{:then Module}
|
|
<Module.default beforeYaml={previousFlowYaml} afterYaml={currentFlowYaml} />
|
|
{/await}
|
|
</div>
|
|
{:else}
|
|
<Loader2 class="animate-spin" />
|
|
{/if}
|
|
</div>
|
|
</TabContent>
|
|
{/if}
|
|
<TabContent value="ui">
|
|
{#if graphContent}
|
|
{@render graphContent()}
|
|
{:else}
|
|
<div class="flow-root w-full pb-4">
|
|
{#if showStepHint}
|
|
<p class="text-2xs text-tertiary py-1">Click on a step to see its details</p>
|
|
{/if}
|
|
{#if !noSummary}
|
|
<h2 class="my-4">{flow.summary}</h2>
|
|
<div>{flow.description ?? ''}</div>
|
|
{/if}
|
|
|
|
{#if !noInput}
|
|
<p class="font-black text-lg w-full my-4">
|
|
<span>Flow Input</span>
|
|
</p>
|
|
{#if flow.schema && flow.schema.properties && Object.keys(flow.schema.properties).length > 0 && flow.schema}
|
|
<FlowInputViewer schema={flow.schema} />
|
|
{:else}
|
|
<div class="text-secondary text-xs italic mb-4">No inputs</div>
|
|
{/if}
|
|
{/if}
|
|
|
|
<FlowGraphViewer
|
|
download={!noGraphDownload}
|
|
{noSide}
|
|
{hideDefaultInputs}
|
|
{flow}
|
|
overflowAuto
|
|
/>
|
|
</div>
|
|
{/if}
|
|
</TabContent>
|
|
<TabContent value="raw">
|
|
<FlowViewerInner {flow} />
|
|
</TabContent>
|
|
<TabContent value="schema">
|
|
<div class="my-4"></div>
|
|
<SchemaViewer schema={flow.schema} />
|
|
</TabContent>
|
|
{/snippet}
|
|
</Tabs>
|