mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-12-03 08:10:27 +00:00
fix: send null for untouched nullable inputs in run forms (#12553)
* fix: send null for untouched nullable inputs in run forms * fix: fill nullable defaults only in forms submitted as run args * fix: keep the nullable opt-out through nested object forms
This commit is contained in:
@@ -98,6 +98,12 @@
|
||||
customErrorMessage?: string | undefined
|
||||
onlyMaskPassword?: boolean
|
||||
nullable?: boolean
|
||||
/**
|
||||
* Write null into an untouched nullable string/list field. Only for forms whose value is
|
||||
* submitted as run args: elsewhere an undefined value has its own meaning (an unset schema
|
||||
* default, a step input still following its expression) that a written null would override.
|
||||
*/
|
||||
fillNullableDefault?: boolean
|
||||
title?: string | undefined
|
||||
placeholder?: string | undefined
|
||||
order?: string[] | undefined
|
||||
@@ -171,6 +177,7 @@
|
||||
customErrorMessage = undefined,
|
||||
onlyMaskPassword = false,
|
||||
nullable = false,
|
||||
fillNullableDefault = false,
|
||||
title = $bindable(undefined),
|
||||
placeholder = $bindable(undefined),
|
||||
order = $bindable(undefined),
|
||||
@@ -301,8 +308,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
// A nullable field's default is a real null: left undefined, the key is dropped
|
||||
// from the submitted args and the runnable never receives it.
|
||||
const unsetNullable =
|
||||
fillNullableDefault &&
|
||||
nnullable &&
|
||||
value === undefined &&
|
||||
!ignoreValueUndefined &&
|
||||
(inputCat === 'string' || inputCat === 'list')
|
||||
if (nnullable && type === 'string' && value === '' && nvalue == null) {
|
||||
value = null
|
||||
} else if (unsetNullable && nvalue == null) {
|
||||
value = null
|
||||
lastValue = value
|
||||
} else if (nvalue != null && !deepEqual(nvalue, value)) {
|
||||
value = nvalue
|
||||
lastValue = value
|
||||
@@ -867,6 +885,7 @@
|
||||
<div class="px-4 pt-4 border rounded-md w-full">
|
||||
<SchemaForm
|
||||
lightHeaderFont
|
||||
{fillNullableDefault}
|
||||
{onlyMaskPassword}
|
||||
{disablePortal}
|
||||
{disabled}
|
||||
@@ -1010,6 +1029,7 @@
|
||||
<div class="p-8 border rounded-md w-full">
|
||||
<SchemaForm
|
||||
lightHeaderFont
|
||||
{fillNullableDefault}
|
||||
{onlyMaskPassword}
|
||||
{disablePortal}
|
||||
{disabled}
|
||||
@@ -1190,6 +1210,7 @@
|
||||
{#if orderEditable}
|
||||
<SchemaFormDnd
|
||||
lightHeaderFont
|
||||
{fillNullableDefault}
|
||||
{nestedClasses}
|
||||
{onlyMaskPassword}
|
||||
{disablePortal}
|
||||
@@ -1226,6 +1247,7 @@
|
||||
{:else}
|
||||
<SchemaForm
|
||||
lightHeaderFont
|
||||
{fillNullableDefault}
|
||||
{nestedClasses}
|
||||
{onlyMaskPassword}
|
||||
{disablePortal}
|
||||
@@ -1314,6 +1336,7 @@
|
||||
{#if orderEditable}
|
||||
<SchemaFormDnd
|
||||
lightHeaderFont
|
||||
{fillNullableDefault}
|
||||
{nestedClasses}
|
||||
{onlyMaskPassword}
|
||||
{disablePortal}
|
||||
@@ -1346,6 +1369,7 @@
|
||||
{:else}
|
||||
<SchemaForm
|
||||
lightHeaderFont
|
||||
{fillNullableDefault}
|
||||
{nestedClasses}
|
||||
{onlyMaskPassword}
|
||||
{disablePortal}
|
||||
|
||||
@@ -79,6 +79,8 @@
|
||||
| undefined
|
||||
workspace?: string | undefined
|
||||
chatInputEnabled?: boolean
|
||||
/** See ArgInput's `fillNullableDefault`; nested forms inherit their parent input's value. */
|
||||
fillNullableDefault?: boolean
|
||||
actions?: import('svelte').Snippet<[{ item: { id: string; value: string } }]> | undefined
|
||||
}
|
||||
|
||||
@@ -123,6 +125,7 @@
|
||||
computeS3ForceViewerPolicies = undefined,
|
||||
workspace = undefined,
|
||||
chatInputEnabled = false,
|
||||
fillNullableDefault = true,
|
||||
actions: actions_render = undefined
|
||||
}: Props = $props()
|
||||
|
||||
@@ -363,6 +366,7 @@
|
||||
simpleTooltip={schemaFieldTooltip[argName]}
|
||||
{onlyMaskPassword}
|
||||
nullable={formerProperty?.nullable}
|
||||
{fillNullableDefault}
|
||||
title={formerProperty?.title}
|
||||
placeholder={formerProperty?.placeholder}
|
||||
orderEditable={dndConfig != undefined}
|
||||
@@ -444,6 +448,7 @@
|
||||
simpleTooltipWarning={argName in schemaFieldWarnings}
|
||||
{onlyMaskPassword}
|
||||
nullable={prop?.nullable}
|
||||
{fillNullableDefault}
|
||||
title={prop?.title}
|
||||
placeholder={prop?.placeholder}
|
||||
orderEditable={dndConfig != undefined}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
dndType?: string
|
||||
lightHeaderFont?: boolean
|
||||
workspace?: string | undefined
|
||||
fillNullableDefault?: boolean
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -48,7 +49,8 @@
|
||||
className = '',
|
||||
dndType = generateRandomString(),
|
||||
lightHeaderFont,
|
||||
workspace = undefined
|
||||
workspace = undefined,
|
||||
fillNullableDefault = true
|
||||
}: Props = $props()
|
||||
|
||||
$effect.pre(() => {
|
||||
@@ -138,6 +140,7 @@
|
||||
{onlyMaskPassword}
|
||||
{disablePortal}
|
||||
{disabled}
|
||||
{fillNullableDefault}
|
||||
{helperScript}
|
||||
{className}
|
||||
bind:schema
|
||||
|
||||
Reference in New Issue
Block a user