No script found at id {$selectedComponentInEditor}
diff --git a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptsPanelList.svelte b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptsPanelList.svelte
index c0da8e8ea4..77630ff1af 100644
--- a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptsPanelList.svelte
+++ b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptsPanelList.svelte
@@ -23,11 +23,15 @@
$: runnables = getAppScripts($app.grid, $app.subgrids)
// When selected component changes, update selectedScriptComponentId
- $: if (
- $selectedComponent != $selectedComponentInEditor &&
- !$selectedComponentInEditor?.includes('_transformer')
- ) {
- $selectedComponentInEditor = $selectedComponent?.[0]
+ $: $selectedComponent && handleSelectedComponent()
+
+ function handleSelectedComponent() {
+ if (
+ $selectedComponent != $selectedComponentInEditor &&
+ !$selectedComponentInEditor?.includes('_transformer')
+ ) {
+ $selectedComponentInEditor = $selectedComponent?.[0]
+ }
}
function createBackgroundScript() {
@@ -57,7 +61,7 @@
name: newScriptPath,
inlineScript: undefined,
autoRefresh: true,
-
+ type: 'runnableByName',
fields: {}
})
$app.hiddenInlineScripts = $app.hiddenInlineScripts
diff --git a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/RunButton.svelte b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/RunButton.svelte
new file mode 100644
index 0000000000..84101e686c
--- /dev/null
+++ b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/RunButton.svelte
@@ -0,0 +1,59 @@
+
+
+{#if $runnableComponents[id] != undefined}
+ {#if !runLoading}
+
+ {:else}
+
+ {/if}
+{/if}
diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/InputsSpecsEditor.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/InputsSpecsEditor.svelte
index 930debf6ab..06c9d5cf41 100644
--- a/frontend/src/lib/components/apps/editor/settingsPanel/InputsSpecsEditor.svelte
+++ b/frontend/src/lib/components/apps/editor/settingsPanel/InputsSpecsEditor.svelte
@@ -6,18 +6,20 @@
export let id: string
export let inputSpecs: RichConfigurations
- export let inputSpecsConfiguration: RichConfigurations = inputSpecs
+ export let inputSpecsConfiguration: RichConfigurations | undefined = undefined
export let userInputEnabled: boolean = false
export let shouldCapitalize: boolean = true
export let rowColumns = false
export let resourceOnly = false
export let displayType = false
+
+ $: finalInputSpecsConfiguration = inputSpecsConfiguration ?? inputSpecs
{#if inputSpecs}
- {#each Object.keys(inputSpecsConfiguration) as k}
- {#if inputSpecsConfiguration[k]?.type == 'oneOf'}
+ {#each Object.keys(finalInputSpecsConfiguration) as k}
+ {#if finalInputSpecsConfiguration[k]?.type == 'oneOf'}
{:else}
- {@const meta = inputSpecsConfiguration?.[k]}
+ {@const meta = finalInputSpecsConfiguration?.[k]}
- import type { ResultAppInput } from '$lib/components/apps/inputType'
+ import type { ResultAppInput, Runnable, StaticAppInput } from '$lib/components/apps/inputType'
import { isScriptByNameDefined, isScriptByPathDefined } from '$lib/components/apps/utils'
+ import { getContext } from 'svelte'
import type { AppComponent } from '../../component'
import RunnableSelector from '../mainInput/RunnableSelector.svelte'
import SelectedRunnable from '../SelectedRunnable.svelte'
+ import type { AppEditorContext } from '$lib/components/apps/types'
export let appInput: ResultAppInput
export let defaultUserInput = false
export let appComponent: AppComponent
+
+ const { selectedComponentInEditor } = getContext('AppEditorContext')
+
+ function onPick({
+ runnable,
+ fields
+ }: {
+ runnable: Runnable
+ fields: Record
+ }) {
+ if (appInput.type === 'runnable') {
+ appInput = { ...appInput, runnable, fields }
+ $selectedComponentInEditor = appComponent.id
+ } else {
+ console.warn('Cannot pick runnable for non-runnable input')
+ }
+ }
{#if isScriptByPathDefined(appInput) || isScriptByNameDefined(appInput)}
{:else if appInput !== undefined}
-
+ onPick(e.detail)} />
{/if}
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 eff4155323..9ebe6a8891 100644
--- a/frontend/src/lib/components/apps/editor/settingsPanel/mainInput/RunnableSelector.svelte
+++ b/frontend/src/lib/components/apps/editor/settingsPanel/mainInput/RunnableSelector.svelte
@@ -4,27 +4,32 @@
import PickHubScript from '$lib/components/flows/pickers/PickHubScript.svelte'
import { Building, Globe2 } from 'lucide-svelte'
import InlineScriptList from './InlineScriptList.svelte'
- import type { ResultAppInput } from '$lib/components/apps/inputType'
+ import type { Runnable, StaticAppInput } from '$lib/components/apps/inputType'
import WorkspaceScriptList from './WorkspaceScriptList.svelte'
import WorkspaceFlowList from './WorkspaceFlowList.svelte'
- import type { AppEditorContext, AppViewerContext } from '$lib/components/apps/types'
- import { getContext } from 'svelte'
+ import type { AppViewerContext } from '$lib/components/apps/types'
+ 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'
type Tab = 'hubscripts' | 'workspacescripts' | 'workspaceflows' | 'inlinescripts'
- export let appInput: ResultAppInput
export let defaultUserInput = false
- export let id: string
+ export let hideCreateScript = false
let tab: Tab = 'inlinescripts'
let filter: string = ''
let picker: Drawer
const { app, workspace } = getContext('AppViewerContext')
- const { selectedComponentInEditor } = getContext('AppEditorContext')
+
+ const dispatch = createEventDispatcher<{
+ pick: {
+ runnable: Runnable
+ fields: Record
+ }
+ }>()
async function loadSchemaFromTriggerable(
path: string,
@@ -34,48 +39,49 @@
}
async function pickScript(path: string) {
- if (appInput.type === 'runnable') {
- const schema = await loadSchemaFromTriggerable(path, 'script')
- const fields = schemaToInputsSpec(schema, defaultUserInput)
- appInput.runnable = {
- type: 'runnableByPath',
- path,
- runType: 'script',
- schema
- }
- appInput.fields = fields
- $selectedComponentInEditor = id
- }
+ const schema = await loadSchemaFromTriggerable(path, 'script')
+ const fields = schemaToInputsSpec(schema, defaultUserInput)
+ const runnable = {
+ type: 'runnableByPath',
+ path,
+ runType: 'script',
+ schema
+ } as const
+
+ dispatch('pick', {
+ runnable,
+ fields
+ })
}
async function pickFlow(path: string) {
- if (appInput.type === 'runnable') {
- const schema = await loadSchemaFromTriggerable(path, 'flow')
- const fields = schemaToInputsSpec(schema, defaultUserInput)
- appInput.runnable = {
- type: 'runnableByPath',
- path,
- runType: 'flow',
- schema
- }
- appInput.fields = fields
- $selectedComponentInEditor = id
- }
+ const schema = await loadSchemaFromTriggerable(path, 'flow')
+ const fields = schemaToInputsSpec(schema, defaultUserInput)
+ const runnable = {
+ type: 'runnableByPath',
+ path,
+ runType: 'flow',
+ schema
+ } as const
+ dispatch('pick', {
+ runnable,
+ fields
+ })
}
async function pickHubScript(path: string) {
- if (appInput.type === 'runnable') {
- const schema = await loadSchemaFromTriggerable(path, 'hubscript')
- const fields = schemaToInputsSpec(schema, defaultUserInput)
- appInput.runnable = {
- type: 'runnableByPath',
- path,
- runType: 'hubscript',
- schema
- }
- appInput.fields = fields
- $selectedComponentInEditor = id
- }
+ const schema = await loadSchemaFromTriggerable(path, 'hubscript')
+ const fields = schemaToInputsSpec(schema, defaultUserInput)
+ const runnable = {
+ type: 'runnableByPath',
+ path,
+ runType: 'hubscript',
+ schema
+ } as const
+ dispatch('pick', {
+ runnable,
+ fields
+ })
}
function pickInlineScript(name: string) {
@@ -83,20 +89,20 @@
(script) => script.name === name
)
const unusedInlineScript = $app.unusedInlineScripts?.[unusedInlineScriptIndex]
- if (appInput.type === 'runnable' && unusedInlineScript?.inlineScript) {
- appInput.runnable = {
+ dispatch('pick', {
+ runnable: {
type: 'runnableByName',
name,
inlineScript: unusedInlineScript.inlineScript
- }
+ },
+ fields: {}
+ })
- $app.unusedInlineScripts.splice(unusedInlineScriptIndex, 1)
- }
- $selectedComponentInEditor = id
- $app = $app
+ $app.unusedInlineScripts.splice(unusedInlineScriptIndex, 1)
+ $app.unusedInlineScripts = $app.unusedInlineScripts
}
- function createScript(): string {
+ function createScript() {
let index = 0
let newScriptPath = `Inline Script ${index}`
@@ -107,16 +113,14 @@
newScriptPath = `Inline Script ${++index}`
}
- appInput.runnable = {
- type: 'runnableByName',
- name: newScriptPath,
- inlineScript: undefined
- }
-
- appInput = appInput
- $selectedComponentInEditor = id
-
- return newScriptPath
+ dispatch('pick', {
+ runnable: {
+ type: 'runnableByName',
+ name: newScriptPath,
+ inlineScript: undefined
+ },
+ fields: {}
+ })
}
@@ -175,16 +179,18 @@
-
+ {#if !hideCreateScript}
+
+ {/if}