From 1b6e66c1abcfd9cf2d544e51bad219aca0fb18ba Mon Sep 17 00:00:00 2001 From: Faton Ramadani Date: Fri, 29 Sep 2023 12:02:47 +0200 Subject: [PATCH] feat(frontend): copy schema from json and past runs in flow inputs (#2352) * feat(frontend): copy schema from json and past runs in flow inputs * feat(frontend): copy schema from json and past runs in flow inputs --- frontend/package-lock.json | 14 +-- frontend/package.json | 2 +- .../src/lib/components/SavedInputs.svelte | 23 ++--- .../components/inputs/AppRangeInput.svelte | 4 +- .../components/flows/content/FlowInput.svelte | 86 +++++++++++++++++-- 5 files changed, 103 insertions(+), 26 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 0e80a30c17..1ae6363c79 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -95,7 +95,7 @@ "svelte-overlay": "^1.4.1", "svelte-popperjs": "^1.3.2", "svelte-preprocess": "^5.0.1", - "svelte-range-slider-pips": "^2.1.1", + "svelte-range-slider-pips": "^2.2.3", "svelte-splitpanes": "^0.8.0", "svelte2tsx": "^0.6.16", "tailwindcss": "^3.3.2", @@ -9073,9 +9073,9 @@ } }, "node_modules/svelte-range-slider-pips": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/svelte-range-slider-pips/-/svelte-range-slider-pips-2.1.1.tgz", - "integrity": "sha512-fLkhfnyEc4uMOCZCl8IPyC0e9lujrjqdSyrKw28Y8j99YUPZR+pHnSxde7PqhM0ST6eyO4ugh2nFnLZTIoG9aQ==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/svelte-range-slider-pips/-/svelte-range-slider-pips-2.2.3.tgz", + "integrity": "sha512-ZAwX9+NDOE6cdqUTMfwBw27YI7NFgSXyPS1ARx3Zuaish2q6FuAtgx5d9+uqNzxQ7WVFhxgM7iQp8MvCpvy4Jw==", "dev": true }, "node_modules/svelte-splitpanes": { @@ -16433,9 +16433,9 @@ } }, "svelte-range-slider-pips": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/svelte-range-slider-pips/-/svelte-range-slider-pips-2.1.1.tgz", - "integrity": "sha512-fLkhfnyEc4uMOCZCl8IPyC0e9lujrjqdSyrKw28Y8j99YUPZR+pHnSxde7PqhM0ST6eyO4ugh2nFnLZTIoG9aQ==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/svelte-range-slider-pips/-/svelte-range-slider-pips-2.2.3.tgz", + "integrity": "sha512-ZAwX9+NDOE6cdqUTMfwBw27YI7NFgSXyPS1ARx3Zuaish2q6FuAtgx5d9+uqNzxQ7WVFhxgM7iQp8MvCpvy4Jw==", "dev": true }, "svelte-splitpanes": { diff --git a/frontend/package.json b/frontend/package.json index 03dae10643..3c0709e444 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -60,7 +60,7 @@ "svelte-overlay": "^1.4.1", "svelte-popperjs": "^1.3.2", "svelte-preprocess": "^5.0.1", - "svelte-range-slider-pips": "^2.1.1", + "svelte-range-slider-pips": "^2.2.3", "svelte-splitpanes": "^0.8.0", "svelte2tsx": "^0.6.16", "tailwindcss": "^3.3.2", diff --git a/frontend/src/lib/components/SavedInputs.svelte b/frontend/src/lib/components/SavedInputs.svelte index cafbed4c57..5baef88b1a 100644 --- a/frontend/src/lib/components/SavedInputs.svelte +++ b/frontend/src/lib/components/SavedInputs.svelte @@ -15,6 +15,7 @@ export let scriptHash: string | null = null export let scriptPath: string | null = null export let flowPath: string | null = null + export let canSaveInputs: boolean = true let runnableId: string | undefined = scriptPath || flowPath || undefined let runnableType: RunnableType | undefined = scriptHash @@ -150,16 +151,18 @@ >Shared inputs are available to anyone with access to the script - + {#if canSaveInputs} + + {/if}
diff --git a/frontend/src/lib/components/apps/components/inputs/AppRangeInput.svelte b/frontend/src/lib/components/apps/components/inputs/AppRangeInput.svelte index 18a1e5835b..dbb03524f8 100644 --- a/frontend/src/lib/components/apps/components/inputs/AppRangeInput.svelte +++ b/frontend/src/lib/components/apps/components/inputs/AppRangeInput.svelte @@ -41,8 +41,6 @@ values = [resolvedConfig?.defaultLow ?? 0, resolvedConfig?.defaultHigh ?? 1] } - let disabled = false - let slider: HTMLElement let outputs = initOutput($worldStore, id, { @@ -117,7 +115,7 @@ min={resolvedConfig.min == undefined ? 0 : +resolvedConfig.min} max={resolvedConfig.max == undefined ? 1 : +resolvedConfig.max} range - {disabled} + disabled={resolvedConfig.disabled} />
diff --git a/frontend/src/lib/components/flows/content/FlowInput.svelte b/frontend/src/lib/components/flows/content/FlowInput.svelte index 248190e5db..052dce8d3d 100644 --- a/frontend/src/lib/components/flows/content/FlowInput.svelte +++ b/frontend/src/lib/components/flows/content/FlowInput.svelte @@ -1,5 +1,5 @@
-
+
Copy input's schema from
+ +
+ + + { + jsonPayload.closeDrawer() + }} + > + + + + + + + + + + { + const parsed = JSON.parse(JSON.stringify(e.detail)) + + if (!parsed) { + sendUserToast('Invalid JSON', true) + return + } + + $flowStore.schema = { required: [], properties: {}, ...convert(parsed) } + inputLibraryDrawer?.closeDrawer() + }} + /> + +