diff --git a/frontend/src/lib/components/apps/components/helpers/RunnableComponent.svelte b/frontend/src/lib/components/apps/components/helpers/RunnableComponent.svelte index cc1e44206e..54da05d290 100644 --- a/frontend/src/lib/components/apps/components/helpers/RunnableComponent.svelte +++ b/frontend/src/lib/components/apps/components/helpers/RunnableComponent.svelte @@ -138,7 +138,11 @@ Object.keys(inputs ?? {}).forEach((key: string) => { const input = inputs[key] - if (['static', 'eval', 'connected'].includes(input.type) && schemaStripped !== undefined) { + if ( + ['static', 'eval', 'connected'].includes(input.type) && + schemaStripped !== undefined && + schemaStripped.properties + ) { delete schemaStripped.properties[key] } }) diff --git a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte index 4c3c19aa70..4fa22555cb 100644 --- a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte +++ b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte @@ -10,7 +10,6 @@ import Badge from '$lib/components/common/badge/Badge.svelte' import Editor from '$lib/components/Editor.svelte' import { emptySchema, getModifierKey, scriptLangToEditorLang } from '$lib/utils' - import Popover from '../../../Popover.svelte' import { computeFields } from './utils' import { deepEqual } from 'fast-equals' import type { AppInput } from '../../inputType' @@ -145,18 +144,16 @@ Invalid {/if} - - dispatch('delete')} - > - - - Delete - + dispatch('delete')} + > + + {#if inlineScript.language != 'frontend'} {/if} + {#key $stateId} diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/mainInput/RunnableSelector.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/mainInput/RunnableSelector.svelte index 9ebe6a8891..7784f8f951 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/mainInput/RunnableSelector.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/mainInput/RunnableSelector.svelte @@ -11,7 +11,7 @@ import { createEventDispatcher, getContext } from 'svelte' import type { Schema } from '$lib/common' import { getAllScriptNames, loadSchema, schemaToInputsSpec } from '$lib/components/apps/utils' - import { emptySchema } from '$lib/utils' + import { defaultIfEmptyString, emptySchema } from '$lib/utils' type Tab = 'hubscripts' | 'workspacescripts' | 'workspaceflows' | 'inlinescripts' @@ -34,18 +34,19 @@ async function loadSchemaFromTriggerable( path: string, runType: 'script' | 'flow' | 'hubscript' - ): Promise { + ): Promise<{ schema: Schema; summary: string | undefined }> { return loadSchema(workspace, path, runType) ?? emptySchema() } async function pickScript(path: string) { const schema = await loadSchemaFromTriggerable(path, 'script') - const fields = schemaToInputsSpec(schema, defaultUserInput) + const fields = schemaToInputsSpec(schema.schema, defaultUserInput) const runnable = { type: 'runnableByPath', path, runType: 'script', - schema + schema, + name: defaultIfEmptyString(schema.summary, path) } as const dispatch('pick', { @@ -56,12 +57,13 @@ async function pickFlow(path: string) { const schema = await loadSchemaFromTriggerable(path, 'flow') - const fields = schemaToInputsSpec(schema, defaultUserInput) + const fields = schemaToInputsSpec(schema.schema, defaultUserInput) const runnable = { type: 'runnableByPath', path, runType: 'flow', - schema + schema, + name: defaultIfEmptyString(schema.summary, path) } as const dispatch('pick', { runnable, @@ -71,12 +73,13 @@ async function pickHubScript(path: string) { const schema = await loadSchemaFromTriggerable(path, 'hubscript') - const fields = schemaToInputsSpec(schema, defaultUserInput) + const fields = schemaToInputsSpec(schema.schema, defaultUserInput) const runnable = { type: 'runnableByPath', path, runType: 'hubscript', - schema + schema, + name: defaultIfEmptyString(schema.summary, path) } as const dispatch('pick', { runnable, diff --git a/frontend/src/lib/components/apps/inputType.ts b/frontend/src/lib/components/apps/inputType.ts index bd7d23ee2f..f7430dd83e 100644 --- a/frontend/src/lib/components/apps/inputType.ts +++ b/frontend/src/lib/components/apps/inputType.ts @@ -69,6 +69,7 @@ export type TemplateInput = { } export type RunnableByPath = { + name: string path: string schema: any runType: 'script' | 'flow' | 'hubscript' diff --git a/frontend/src/lib/components/apps/utils.ts b/frontend/src/lib/components/apps/utils.ts index 6fd793c6eb..95bb626e47 100644 --- a/frontend/src/lib/components/apps/utils.ts +++ b/frontend/src/lib/components/apps/utils.ts @@ -41,21 +41,21 @@ export async function loadSchema( workspace: string, path: string, runType: 'script' | 'flow' | 'hubscript' -): Promise { +): Promise<{ schema: Schema; summary: string | undefined }> { if (runType === 'script') { const script = await ScriptService.getScriptByPath({ workspace, path }) - return script.schema + return { schema: script.schema, summary: script.summary } } else if (runType === 'flow') { const flow = await FlowService.getFlowByPath({ workspace, path }) - return flow.schema + return { schema: flow.schema, summary: flow.summary } } else { const script = await ScriptService.getHubScriptByPath({ path @@ -69,7 +69,7 @@ export async function loadSchema( } await inferArgs(script.language, script.content, script.schema) - return script.schema + return { schema: script.schema, summary: script.summary } } }