mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-12-04 00:06:39 +00:00
fix: offer script-step test and edit to compose roles with code (#12574)
This commit is contained in:
@@ -102,7 +102,9 @@
|
||||
const scriptItems: Item[] = $derived.by(() => {
|
||||
if (flowModuleValue?.type !== 'script') return []
|
||||
const items: Item[] = []
|
||||
if (!isHub && customUi?.scriptEdit != false && !composeOnlyFlows) {
|
||||
// Editing deploys a new version of the workspace script, which the server allows to any
|
||||
// role with code, whatever its flows level.
|
||||
if (!isHub && customUi?.scriptEdit != false && $roleCaps.code) {
|
||||
items.push({
|
||||
displayName: "Edit the script's code",
|
||||
icon: Pen,
|
||||
@@ -146,6 +148,7 @@
|
||||
})
|
||||
}
|
||||
}
|
||||
// Forking adds inline code to the flow, which a compose role cannot author.
|
||||
if (customUi?.scriptFork != false && !composeOnlyFlows) {
|
||||
items.push({
|
||||
displayName: 'Fork into an inline script',
|
||||
|
||||
@@ -83,7 +83,6 @@
|
||||
|
||||
const operatingWorkspace = useOperatingWorkspace()
|
||||
const roleCaps = useRoleCapabilities()
|
||||
const composeOnlyFlows = $derived($roleCaps.flows === 'compose')
|
||||
|
||||
const {
|
||||
selectionManager,
|
||||
@@ -233,7 +232,6 @@
|
||||
Boolean(flowStore.val.value?.chat_input_enabled) &&
|
||||
flowModule.value.type === 'aiagent'
|
||||
)
|
||||
let visibleSelected = $derived(selected === 'chat' && !canShowChatTab ? 'inputs' : selected)
|
||||
let runSettings: FlowRunSettings | undefined = $state()
|
||||
let agentLinked = $derived(flowModule.value.type === 'aiagent' && Boolean(flowModule.value.agent))
|
||||
// A tool row drills in by selecting that tool's graph node, and the graph draws tool nodes only
|
||||
@@ -261,20 +259,34 @@
|
||||
() => (flowModule.value.type === 'script' ? flowModule.value.hash : undefined),
|
||||
() => opWs
|
||||
)
|
||||
// Hub scripts, hash-pinned steps, and embeddings that disable script editing
|
||||
// can't have their settings edited from here. The drawer must also be mounted:
|
||||
// local-dev editors (Dev.svelte / flows/dev) provide the context store but never
|
||||
// render the drawer, so editing there would be a no-op — keep values read-only.
|
||||
// Not for hub scripts, hash-pinned steps, embeddings that disable script editing, or roles
|
||||
// without code (why: FlowCardHeader's edit item). The drawer must also be mounted: local-dev
|
||||
// editors (Dev.svelte / flows/dev) provide the context store but never render the drawer.
|
||||
let canEditWorkspaceScriptSettings = $derived(
|
||||
flowModule.value.type === 'script' &&
|
||||
!flowModule.value.path?.startsWith('hub/') &&
|
||||
flowModule.value.hash == undefined &&
|
||||
customUi?.scriptEdit != false &&
|
||||
!composeOnlyFlows &&
|
||||
$roleCaps.code &&
|
||||
$workspaceScriptSettingsDrawer != undefined
|
||||
)
|
||||
// Same rule as the graph node's Run button (FlowModuleSchemaItem).
|
||||
let builderCannotTestStep = $derived(composeOnlyFlows && flowModule.value.type === 'script')
|
||||
let builderCannotTestStep = $derived(
|
||||
(flowModule.value.type === 'script' || flowModule.value.type === 'rawscript') &&
|
||||
!($roleCaps.code && $roleCaps.run)
|
||||
)
|
||||
// Several paths ask for a tab that may be hidden (the editor's Ctrl+Enter, the forced test
|
||||
// tab of an input edit or an agent tool); fall back to inputs here rather than guarding each
|
||||
// of them. A preprocessor has no inputs tab, so it says why instead.
|
||||
let visibleSelected = $derived(
|
||||
selected === 'test' && builderCannotTestStep
|
||||
? preprocessorModule
|
||||
? 'cannot_test'
|
||||
: 'inputs'
|
||||
: selected === 'chat' && !canShowChatTab
|
||||
? 'inputs'
|
||||
: selected
|
||||
)
|
||||
let workspaceScriptNoEditReason = $derived(
|
||||
flowModule.value.type !== 'script' || canEditWorkspaceScriptSettings
|
||||
? undefined
|
||||
@@ -282,7 +294,9 @@
|
||||
? 'Hub scripts cannot be edited from here.'
|
||||
: flowModule.value.hash != undefined
|
||||
? 'Steps pinned to a specific version cannot be edited from here.'
|
||||
: 'Editing script settings is not available in this editor.'
|
||||
: !$roleCaps.code
|
||||
? 'Your role cannot edit scripts.'
|
||||
: 'Editing script settings is not available in this editor.'
|
||||
)
|
||||
// Non-positive concurrent_limit / cache_ttl are treated as unset by the runtime (legacy rows).
|
||||
let referencedConcurrentLimit = $derived(
|
||||
@@ -470,7 +484,7 @@
|
||||
flowStore.val && flowModule ? checkIfParentLoop(flowStore.val, flowModule.id) : undefined
|
||||
)
|
||||
$effect(() => {
|
||||
if (selected === 'test') {
|
||||
if (visibleSelected === 'test') {
|
||||
leftPanelSize = 50
|
||||
} else {
|
||||
leftPanelSize = 100
|
||||
@@ -967,7 +981,7 @@
|
||||
{#if assets?.length}
|
||||
<AssetsDropdownButton {assets} />
|
||||
{/if}
|
||||
{#if isDebuggableScript && customUi?.editorBar?.debug != false}
|
||||
{#if isDebuggableScript && customUi?.editorBar?.debug != false && !builderCannotTestStep}
|
||||
<Button
|
||||
variant={debugMode ? 'accent' : 'default'}
|
||||
size="xs"
|
||||
@@ -1394,7 +1408,7 @@
|
||||
{/if}
|
||||
</PropPickerWrapper>
|
||||
</div>
|
||||
{:else if visibleSelected === 'test' && !builderCannotTestStep}
|
||||
{:else if visibleSelected === 'test'}
|
||||
{#if debugMode && isDebuggableScript}
|
||||
<div transition:slide={{ duration: 200 }}>
|
||||
<DebugToolbar
|
||||
@@ -1526,10 +1540,14 @@
|
||||
{workspaceScriptNoEditReason}
|
||||
onEditWorkspaceScript={openWorkspaceScriptSettings}
|
||||
/>
|
||||
{:else if visibleSelected === 'cannot_test'}
|
||||
<div class="h-full flex items-center justify-center text-sm text-tertiary">
|
||||
Your role cannot test this step.
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</Pane>
|
||||
{#if selected === 'test'}
|
||||
{#if visibleSelected === 'test'}
|
||||
<Pane minSize={20} class="relative">
|
||||
{#if stepHistoryLoader?.stepStates[flowModule.id]?.initial && !flowModule.mock?.enabled}
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
|
||||
@@ -148,10 +148,11 @@
|
||||
let mod = $derived(
|
||||
id && flowStore?.val?.value ? dfsPreviousResults(id, flowStore.val, false)[0] : undefined
|
||||
)
|
||||
// A script step is tested as a script preview, which operators are refused: running the
|
||||
// deployed runnable is left to "Test flow".
|
||||
// Script and inline steps are tested as a script preview, which the server allows only to a
|
||||
// role with code and run, whatever its flows level.
|
||||
let builderCannotTestStep = $derived(
|
||||
$roleCaps.flows === 'compose' && mod?.value.type === 'script'
|
||||
(mod?.value.type === 'script' || mod?.value.type === 'rawscript') &&
|
||||
!($roleCaps.code && $roleCaps.run)
|
||||
)
|
||||
let moduleTest: ModuleTest | undefined = $state(undefined)
|
||||
let testIsLoading = $state(false)
|
||||
|
||||
Reference in New Issue
Block a user