mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-23 16:00:38 +00:00
feat(script-editor): wire initialTestPanelCollapsed through ScriptBuilder
The `initialTestPanelCollapsed` prop was already declared on `ScriptBuilderProps` (used by the session preview to start the editor with the run/test pane closed) but never destructured in `ScriptBuilder.svelte`, so the value silently dropped on the floor and the test pane always opened. - `ScriptBuilder.svelte` — destructure the prop and forward it to `<ScriptEditor>`. - `ScriptEditor.svelte` — accept the prop and seed `rawTestPanelSize` to 0 when true, while keeping `storedTestPanelSize` at the default 30 so the user's first toggle expands the pane to a sensible width rather than 0. Regular `/scripts/edit/...` doesn't pass the prop → default `false` → panel still opens by default.
This commit is contained in:
@@ -134,7 +134,8 @@
|
||||
onSaveDraftError,
|
||||
onSaveDraft,
|
||||
onNavigate,
|
||||
disableAi
|
||||
disableAi,
|
||||
initialTestPanelCollapsed = false
|
||||
}: ScriptBuilderProps = $props()
|
||||
|
||||
export function getInitialAndModifiedValues(): SavedAndModifiedValue {
|
||||
@@ -2091,6 +2092,7 @@
|
||||
bind:assets={script.assets}
|
||||
bind:modules={script.modules}
|
||||
enablePreprocessorSnippet
|
||||
{initialTestPanelCollapsed}
|
||||
/>
|
||||
</div>
|
||||
{:else}
|
||||
|
||||
@@ -159,6 +159,11 @@
|
||||
modules?: { [key: string]: ScriptModule } | null
|
||||
editorBarRight?: import('svelte').Snippet
|
||||
enablePreprocessorSnippet?: boolean
|
||||
// When true the right-hand test/run pane mounts collapsed. The user
|
||||
// can still expand it via `toggleTestPanel`. Defaults to false so the
|
||||
// regular /scripts/edit route keeps its current open-by-default UX;
|
||||
// the session preview opts in to save vertical real estate.
|
||||
initialTestPanelCollapsed?: boolean
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -192,7 +197,8 @@
|
||||
assets = $bindable(),
|
||||
modules = $bindable(undefined),
|
||||
editorBarRight,
|
||||
enablePreprocessorSnippet = false
|
||||
enablePreprocessorSnippet = false,
|
||||
initialTestPanelCollapsed = false
|
||||
}: Props = $props()
|
||||
|
||||
let initialArgs = structuredClone($state.snapshot(args))
|
||||
@@ -1359,8 +1365,11 @@
|
||||
// dynamic minimum below — so when the editor shrinks, the displayed test
|
||||
// pane grows to honor the new minimum without needing an effect. The code
|
||||
// pane's size is purely derived from it (100 - test).
|
||||
let rawTestPanelSize = $state(30)
|
||||
let storedTestPanelSize = untrack(() => rawTestPanelSize)
|
||||
// `initialTestPanelCollapsed` seeds the raw value at 0 (collapsed) while
|
||||
// keeping the "remembered" size at 30, so the user's first toggle expands
|
||||
// the pane to a sensible width rather than 0.
|
||||
let rawTestPanelSize = $state(untrack(() => (initialTestPanelCollapsed ? 0 : 30)))
|
||||
let storedTestPanelSize = 30
|
||||
const testPanelSize = $derived(
|
||||
rawTestPanelSize === 0 ? 0 : Math.max(rawTestPanelSize, testPaneMinPercent)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user