From 2ece1eb475ea0298a7ad83a5eac46a047478b339 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sun, 5 Feb 2023 10:03:03 +0100 Subject: [PATCH] frontend misc --- frontend/src/lib/components/FlowBuilder.svelte | 2 +- .../src/lib/components/HighlightCode.svelte | 8 +++++++- .../src/lib/components/ScriptBuilder.svelte | 2 +- .../InlineScriptEditorPanel.svelte | 4 +++- .../lib/components/common/table/FlowRow.svelte | 4 ++-- .../components/common/table/ScriptRow.svelte | 4 ++-- frontend/src/lib/user.ts | 2 +- frontend/src/lib/utils.ts | 2 +- .../(logged)/apps/get/[...path]/+page.svelte | 5 +++++ .../(logged)/flows/get/[...path]/+page.svelte | 7 ++++++- .../(logged)/flows/run/[...path]/+page.svelte | 2 +- .../(root)/(logged)/run/[...run]/+page.svelte | 2 +- .../scripts/get/[...hash]/+page.svelte | 18 ++++++++++++++---- .../scripts/run/[...hash]/+page.svelte | 5 +++-- frontend/src/routes/+layout.svelte | 2 +- 15 files changed, 49 insertions(+), 20 deletions(-) diff --git a/frontend/src/lib/components/FlowBuilder.svelte b/frontend/src/lib/components/FlowBuilder.svelte index a782843c22..5b9f8c0f0f 100644 --- a/frontend/src/lib/components/FlowBuilder.svelte +++ b/frontend/src/lib/components/FlowBuilder.svelte @@ -113,7 +113,7 @@ } } sendUserToast(`Success! flow saved at ${$flowStore.path}`) - goto(`/flows/get/${$flowStore.path}`) + goto(`/flows/get/${$flowStore.path}?workspace_id=${$workspaceStore}`) } let timeout: NodeJS.Timeout | undefined = undefined diff --git a/frontend/src/lib/components/HighlightCode.svelte b/frontend/src/lib/components/HighlightCode.svelte index 0ab75b9882..ff88547371 100644 --- a/frontend/src/lib/components/HighlightCode.svelte +++ b/frontend/src/lib/components/HighlightCode.svelte @@ -26,4 +26,10 @@ $: lang = getLang(language) - +{#if code?.length < 5000} + +{:else} +
{code}
+{/if} diff --git a/frontend/src/lib/components/ScriptBuilder.svelte b/frontend/src/lib/components/ScriptBuilder.svelte index bf4dac6971..fd175d16d7 100644 --- a/frontend/src/lib/components/ScriptBuilder.svelte +++ b/frontend/src/lib/components/ScriptBuilder.svelte @@ -85,7 +85,7 @@ }) sendUserToast(`Success! New script version created with hash ${newHash}`) await goto(`/scripts/edit/${newHash}?step=2`) - goto(`/scripts/get/${newHash}`) + goto(`/scripts/get/${newHash}?workspace_id=${$workspaceStore}`) } catch (error) { sendUserToast(`Impossible to save the script: ${error.body}`, true) } diff --git a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditorPanel.svelte b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditorPanel.svelte index af7eca9e7b..3b0feb3f02 100644 --- a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditorPanel.svelte +++ b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditorPanel.svelte @@ -4,6 +4,7 @@ import FlowModuleScript from '$lib/components/flows/content/FlowModuleScript.svelte' import FlowPathViewer from '$lib/components/flows/content/FlowPathViewer.svelte' import { inferArgs } from '$lib/infer' + import { workspaceStore } from '$lib/stores' import { emptySchema, getScriptByPath } from '$lib/utils' import { faCodeBranch, faExternalLinkAlt, faEye, faPen } from '@fortawesome/free-solid-svg-icons' import type { AppInput, ResultAppInput } from '../../inputType' @@ -120,7 +121,8 @@ startIcon={{ icon: faEye }} endIcon={{ icon: faExternalLinkAlt }} target="_blank" - href="/flows/get/{componentInput?.['runnable']?.path}">Details pageDetails page diff --git a/frontend/src/lib/components/common/table/FlowRow.svelte b/frontend/src/lib/components/common/table/FlowRow.svelte index 75030d73f9..40743a14dd 100644 --- a/frontend/src/lib/components/common/table/FlowRow.svelte +++ b/frontend/src/lib/components/common/table/FlowRow.svelte @@ -91,7 +91,7 @@ {/if} View flow
diff --git a/frontend/src/routes/(root)/(logged)/run/[...run]/+page.svelte b/frontend/src/routes/(root)/(logged)/run/[...run]/+page.svelte index 5c86ced7ac..56dc5e9a5f 100644 --- a/frontend/src/routes/(root)/(logged)/run/[...run]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/run/[...run]/+page.svelte @@ -277,7 +277,7 @@ {/if} {job.script_path ?? (job.job_kind == 'dependencies' ? 'lock dependencies' : 'No path')} {#if job.script_hash} - {truncateHash(job.script_hash)} {/if} diff --git a/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte b/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte index 145076340b..382734bdd1 100644 --- a/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte @@ -65,6 +65,11 @@ let shareModal: ShareModal + let queryId = $page.url.searchParams.get('workspace_id') + if (queryId && queryId != $workspaceStore) { + $workspaceStore = $page.url.searchParams.get('workspace_id')! + } + $: loading = !script $: if ($workspaceStore) { loadScript($page.params.hash) @@ -182,7 +187,7 @@ { - await goto('/scripts/get/' + e.detail) + await goto('/scripts/get/' + e.detail + `?workspace_id=${$workspaceStore}`) loadScript($page.params.hash) }} /> @@ -327,14 +332,17 @@ variant="contained" size="xs" startIcon={{ icon: faArrowLeft }} - href="/scripts/get/{script.parent_hashes[0]}" + href="/scripts/get/{script.parent_hashes[0]}?workspace_id={$workspaceStore}" > Previous version ({script.parent_hashes.length}) {#each script.parent_hashes as hash} - + {hash} {/each} @@ -354,7 +362,9 @@ {#if topHash} This hash is not HEAD (latest non-archived version at this path) : - Go to the HEAD of this path + Go to the HEAD of this path {/if} {#if script.archived && !topHash} diff --git a/frontend/src/routes/(root)/(logged)/scripts/run/[...hash]/+page.svelte b/frontend/src/routes/(root)/(logged)/scripts/run/[...hash]/+page.svelte index 786f19d222..a32932933b 100644 --- a/frontend/src/routes/(root)/(logged)/scripts/run/[...hash]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/scripts/run/[...hash]/+page.svelte @@ -31,7 +31,7 @@ script = await ScriptService.getScriptByHash({ workspace: $workspaceStore!, hash }) if (script.schema == undefined) { script.schema = emptySchema() - inferArgs(script.language, script.content, script.schema) + await inferArgs(script.language, script.content, script.schema) script = script } if (script.path && script.archived) { @@ -119,7 +119,8 @@ disabled={script == undefined} btnClasses="mr-4" variant="border" - href="/scripts/get/{script?.hash}">View scriptView script
diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte index 9fba26925b..b104359eb5 100644 --- a/frontend/src/routes/+layout.svelte +++ b/frontend/src/routes/+layout.svelte @@ -11,7 +11,7 @@ // Default toast options const toastOptions = { - duration: 10000, // duration of progress bar tween to the `next` value + duration: 5000, // duration of progress bar tween to the `next` value initial: 1, // initial progress bar value next: 0, // next progress value pausable: true, // pause progress bar tween on mouse hover