From d2cbf72c76437cd8409896f80cef6377447e63ba Mon Sep 17 00:00:00 2001 From: Faton Ramadani Date: Tue, 20 Dec 2022 10:34:50 +0100 Subject: [PATCH] feat(frontend): Add an input field to edit inline script name (#1033) --- .../InlineScriptEditor.svelte | 100 +++++++++--------- .../InlineScriptsPanel.svelte | 11 +- .../InlineScriptsPanelList.svelte | 10 +- 3 files changed, 59 insertions(+), 62 deletions(-) diff --git a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte index 23334eaaf8..7aad84efc9 100644 --- a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte +++ b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte @@ -7,7 +7,7 @@ import { getContext } from 'svelte' import type { AppEditorContext } from '../../types' import SimpleEditor from '$lib/components/SimpleEditor.svelte' - import { Check, CheckCheck, CheckCircle, Code2, X } from 'lucide-svelte' + import { CheckCircle, Code2, X } from 'lucide-svelte' import FlowScriptPicker from '$lib/components/flows/pickers/FlowScriptPicker.svelte' import type { ResultAppInput } from '../../inputType' import InlineScriptEditorDrawer from './InlineScriptEditorDrawer.svelte' @@ -17,11 +17,11 @@ let inlineScriptEditorDrawer: InlineScriptEditorDrawer export let componentInput: ResultAppInput - export let selectedScriptName: string | undefined = undefined - $: shouldDisplay = - componentInput.runnable?.type === 'runnableByName' && - componentInput.runnable?.name === selectedScriptName + const name = + componentInput.runnable?.type === 'runnableByName' ? componentInput.runnable?.name : '' + + $: shouldDisplay = componentInput.runnable?.type === 'runnableByName' const { appPath } = getContext('AppEditorContext') let validCode = false @@ -76,44 +76,48 @@ {#if shouldDisplay} {#if componentInput?.runnable?.type === 'runnableByName' && componentInput?.runnable?.inlineScript}
-
- - +
{#if componentInput?.runnable?.type === 'runnableByName' && componentInput?.runnable?.inlineScript} @@ -152,9 +156,7 @@ label={lang} {lang} on:click={() => { - if (selectedScriptName) { - createInlineScriptByLanguage(lang, selectedScriptName) - } + createInlineScriptByLanguage(lang, name) }} /> {/each} @@ -163,18 +165,14 @@ label={`PostgreSQL`} lang="pgsql" on:click={() => { - if (selectedScriptName) { - createInlineScriptByLanguage(Script.language.DENO, selectedScriptName, 'pgsql') - } + createInlineScriptByLanguage(Script.language.DENO, name, 'pgsql') }} /> { - if (selectedScriptName) { - createInlineScriptByLanguage(Script.language.DENO, selectedScriptName, 'mysql') - } + createInlineScriptByLanguage(Script.language.DENO, name, 'mysql') }} /> diff --git a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptsPanel.svelte b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptsPanel.svelte index d2acdaf83f..b0ca39d442 100644 --- a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptsPanel.svelte +++ b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptsPanel.svelte @@ -8,19 +8,18 @@ const { app } = getContext('AppEditorContext') - let selectedScriptName: string | undefined = undefined + let selectedScriptComponentId: string | undefined = undefined - + {#each $app.grid as gridComponent, index (index)} - + {#if gridComponent.data.id === selectedScriptComponentId} + + {/if} {/each} diff --git a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptsPanelList.svelte b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptsPanelList.svelte index 9a1911b0e8..3bfebb84ad 100644 --- a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptsPanelList.svelte +++ b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptsPanelList.svelte @@ -6,12 +6,12 @@ import type { AppEditorContext } from '../../types' import PanelSection from '../settingsPanel/common/PanelSection.svelte' - export let selectedScriptName: string | undefined = undefined + export let selectedScriptComponentId: string | undefined = undefined const { app } = getContext('AppEditorContext') - function selectInlineScript(name: string) { - selectedScriptName = name + function selectInlineScript(id: string) { + selectedScriptComponentId = id } $: componentInlineScripts = $app.grid.reduce((acc, gridComponent) => { @@ -38,9 +38,9 @@
selectInlineScript(name)} + on:click={() => selectInlineScript(id)} > {name} {id}