diff --git a/src/lib/components/payload-input-with-encoding.svelte b/src/lib/components/payload-input-with-encoding.svelte index 3b17e6a97..23979c410 100644 --- a/src/lib/components/payload-input-with-encoding.svelte +++ b/src/lib/components/payload-input-with-encoding.svelte @@ -24,6 +24,7 @@ export let encoding: Writable; export let error = false; export let loading = false; + export let editing = true; const clearValues = () => { $encoding = 'json/plain'; @@ -35,20 +36,23 @@
{translate('workflows.input')}
- -
- - - - + +
+ {#if editing} + + + + + {/if} +
diff --git a/src/lib/components/payload-input.svelte b/src/lib/components/payload-input.svelte index b0d3a338a..078f29e7e 100644 --- a/src/lib/components/payload-input.svelte +++ b/src/lib/components/payload-input.svelte @@ -14,6 +14,7 @@ export let label = translate('workflows.signal-payload-input-label'); export let loading = false; export let hintText = translate('workflows.signal-payload-input-label-hint'); + export let editing = true; $: error = !isValidInput(input); @@ -46,19 +47,21 @@
import type { Writable } from 'svelte/store'; + import Button from '$lib/holocene/button.svelte'; + import { translate } from '$lib/i18n/translate'; import type { Payloads } from '$lib/types'; import { atob } from '$lib/utilities/atob'; import { getSinglePayload } from '$lib/utilities/encode-payload'; @@ -12,21 +14,38 @@ } from '../payload-input-with-encoding.svelte'; export let input: string; + export let editInput: boolean; export let encoding: Writable; export let payloads: Payloads; + export let showEditActions: boolean = false; + let initialInput = ''; + let initialEncoding: PayloadInputEncoding = 'json/plain'; let loading = true; const setInitialInput = (decodedValue: string): void => { - input = getSinglePayload(decodedValue); + initialInput = getSinglePayload(decodedValue); + input = initialInput; const currentEncoding = atob( String(payloads?.payloads[0]?.metadata?.encoding ?? 'json/plain'), ); if (isPayloadInputEncodingType(currentEncoding)) { $encoding = currentEncoding; + initialEncoding = $encoding; } loading = false; }; + + const handleEdit = () => { + if (editInput) { + editInput = false; + input = initialInput; + $encoding = initialEncoding; + } else { + editInput = true; + input; + } + };
@@ -35,7 +54,14 @@ bind:input bind:encoding bind:loading + editing={editInput} id="schedule-payload-input" - /> + > +
+ +
+
diff --git a/src/lib/holocene/file-input.stories.svelte b/src/lib/holocene/file-input.stories.svelte new file mode 100644 index 000000000..324c09301 --- /dev/null +++ b/src/lib/holocene/file-input.stories.svelte @@ -0,0 +1,28 @@ + + + + + + + diff --git a/src/lib/stores/schedules.ts b/src/lib/stores/schedules.ts index 9645dfd17..3ec0482c2 100644 --- a/src/lib/stores/schedules.ts +++ b/src/lib/stores/schedules.ts @@ -199,7 +199,7 @@ export const submitEditSchedule = async ( workflowId, workflowType: { name: workflowType }, taskQueue: { name: taskQueue }, - input: payloads ? { payloads } : null, + ...(input !== undefined && { input: payloads ? { payloads } : null }), }, }, },