Files
windmill/frontend/src/lib/components/SaveInputsButton.svelte
T
Diego Imbert 5d79f33590 Final Svelte 5 migration (#8211)
* Remove $$props.field usage

* Rename slots to ensure no hyphen

* _props

* _trigger

* OnSelectedIteration type correct capitalization

* rename _content

* Remove afterUpdate

* Migrate everything to svelte 5

* array bind

* Fix popover

* type never

* nit fixes

* Fixed many trivial errors

* onClick

* Fix errors

* use let:

* nit typing

* fix: wrap state_referenced_locally vars with untrack()

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add untrack import

* Fix all syntax errors due to untrack migration

* Fix undefined errors

* Fix more undefined errors

* untrack(() => initialOpen)

* svelte-ignore

* Fix state_descriptors_fixed error in Chart.svelte

Use $state.snapshot() to pass plain copies of data/options to Chart.js
instead of $state proxies. Chart.js's listenArrayEvents tries to define
property descriptors on data arrays, which Svelte 5 proxies reject.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* nit typing

* Merge issue

* Fix "path is not set" error in resource picker / editor

* Fix InputTransformForm error when rerunning some flows

* fix npm run check

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-05 18:11:40 +01:00

71 lines
1.6 KiB
Svelte

<script lang="ts">
import { displayDate } from '$lib/utils.js'
import { InputService, type CreateInput, type RunnableType } from '$lib/gen/index.js'
import { workspaceStore } from '$lib/stores.js'
import { Button } from '$lib/components/common'
import { Save } from 'lucide-svelte'
import { sendUserToast } from '$lib/utils.js'
import { createEventDispatcher } from 'svelte'
import Tooltip from '$lib/components/Tooltip.svelte'
const dispatch = createEventDispatcher()
interface Props {
runnableId: string | undefined;
runnableType: RunnableType | undefined;
args: object;
disabled?: boolean;
small?: boolean | undefined;
showTooltip?: boolean | undefined;
}
let {
runnableId,
runnableType,
args,
disabled = false,
small = undefined,
showTooltip = undefined
}: Props = $props();
let savingInputs = $state(false)
async function saveInput(args: object) {
savingInputs = true
const requestBody: CreateInput = {
name: 'Saved ' + displayDate(new Date()),
args: args as any
}
try {
await InputService.createInput({
workspace: $workspaceStore!,
runnableId,
runnableType,
requestBody
})
} catch (err) {
console.error(err)
sendUserToast(`Failed to save Input: ${err}`, true)
}
savingInputs = false
dispatch('update')
}
</script>
<Button
on:click={() => saveInput(args)}
{disabled}
loading={savingInputs}
startIcon={{ icon: Save }}
variant={small ? 'subtle' : 'default'}
unifiedSize="sm"
>
<span>{small ? 'Save inputs' : 'Save current input'}</span>
{#if showTooltip}
<Tooltip>Shared inputs are available to anyone with access to the script</Tooltip>
{/if}
</Button>