From edf91d01ee04238fca80b178607350f916338553 Mon Sep 17 00:00:00 2001 From: Alex Tideman Date: Fri, 20 Sep 2024 09:04:17 -0500 Subject: [PATCH 1/3] Remove preview codeblock, add error for invalid json --- src/lib/i18n/locales/en/common.ts | 1 + src/lib/pages/start-workflow.svelte | 41 +++++++++++++++++------------ 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/lib/i18n/locales/en/common.ts b/src/lib/i18n/locales/en/common.ts index 7e966efff..24e0741a9 100644 --- a/src/lib/i18n/locales/en/common.ts +++ b/src/lib/i18n/locales/en/common.ts @@ -179,4 +179,5 @@ export const Strings = { state: 'State', attempt: 'Attempt', message: 'Message', + 'upload-json': 'Upload JSON', } as const; diff --git a/src/lib/pages/start-workflow.svelte b/src/lib/pages/start-workflow.svelte index 39cf33cfb..1f9314efd 100644 --- a/src/lib/pages/start-workflow.svelte +++ b/src/lib/pages/start-workflow.svelte @@ -13,6 +13,7 @@ import Input from '$lib/holocene/input/input.svelte'; import Label from '$lib/holocene/label.svelte'; import Link from '$lib/holocene/link.svelte'; + import Tooltip from '$lib/holocene/tooltip.svelte'; import { translate } from '$lib/i18n/translate'; import { getPollers } from '$lib/services/pollers-service'; import { @@ -140,10 +141,26 @@ inputRetrieved = Date.now(); }; + const inputIsJSON = (input: string) => { + try { + JSON.parse(input); + return true; + } catch (e) { + return false; + } + }; + + $: inputValid = !input || inputIsJSON(input); + + $: { + console.log('Input valid: ', inputValid); + } + $: enableStart = !!workflowId && !!taskQueue && !!workflowType && + !!inputValid && !workflowCreateDisabled($page); $: checkTaskQueue(taskQueueParam); @@ -222,25 +239,12 @@
- {#if initialInput} -
-
- {/if} -
+
{#key inputRetrieved} {/key} + {#if !inputValid} + + {/if}
{#if viewAdvancedOptions} From 31d78d1af2348a9fbb7842aa3f72bd49bb9110d5 Mon Sep 17 00:00:00 2001 From: Alex Tideman Date: Fri, 20 Sep 2024 09:04:36 -0500 Subject: [PATCH 2/3] Remove console --- src/lib/pages/start-workflow.svelte | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/lib/pages/start-workflow.svelte b/src/lib/pages/start-workflow.svelte index 1f9314efd..3e81a8fe3 100644 --- a/src/lib/pages/start-workflow.svelte +++ b/src/lib/pages/start-workflow.svelte @@ -152,10 +152,6 @@ $: inputValid = !input || inputIsJSON(input); - $: { - console.log('Input valid: ', inputValid); - } - $: enableStart = !!workflowId && !!taskQueue && From b713ef71baa5a6daaf614239e29e6776d9673ec4 Mon Sep 17 00:00:00 2001 From: Alex Tideman Date: Fri, 20 Sep 2024 09:11:46 -0500 Subject: [PATCH 3/3] Translate --- src/lib/i18n/locales/en/common.ts | 1 + src/lib/pages/start-workflow.svelte | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/i18n/locales/en/common.ts b/src/lib/i18n/locales/en/common.ts index 24e0741a9..cc0e14549 100644 --- a/src/lib/i18n/locales/en/common.ts +++ b/src/lib/i18n/locales/en/common.ts @@ -180,4 +180,5 @@ export const Strings = { attempt: 'Attempt', message: 'Message', 'upload-json': 'Upload JSON', + 'input-valid-json': 'Input must be valid JSON', } as const; diff --git a/src/lib/pages/start-workflow.svelte b/src/lib/pages/start-workflow.svelte index 3e81a8fe3..efcbef130 100644 --- a/src/lib/pages/start-workflow.svelte +++ b/src/lib/pages/start-workflow.svelte @@ -253,7 +253,7 @@ /> {/key} {#if !inputValid} - + {/if}