From e53c39912f98ef5b997baaa50741cd72a2be31ea Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Wed, 9 Aug 2023 22:33:06 +0200 Subject: [PATCH] fix topHash issue --- frontend/src/lib/components/ScriptBuilder.svelte | 3 +-- .../(logged)/scripts/edit/[...path]/+page.svelte | 11 ++++++----- .../(logged)/scripts/get/[...hash]/+page.svelte | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/frontend/src/lib/components/ScriptBuilder.svelte b/frontend/src/lib/components/ScriptBuilder.svelte index 263ddedbc7..50547df6a7 100644 --- a/frontend/src/lib/components/ScriptBuilder.svelte +++ b/frontend/src/lib/components/ScriptBuilder.svelte @@ -33,7 +33,6 @@ export let template: 'pgsql' | 'mysql' | 'script' | 'docker' | 'powershell' = 'script' export let initialArgs: Record = {} export let lockedLanguage = false - export let topHash: string | undefined = undefined export let showMeta: boolean = false let metadataOpen = @@ -158,7 +157,7 @@ summary: script.summary, description: script.description ?? '', content: script.content, - parent_hash: topHash, + parent_hash: script.parent_hash, schema: script.schema, is_template: script.is_template, language: script.language, diff --git a/frontend/src/routes/(root)/(logged)/scripts/edit/[...path]/+page.svelte b/frontend/src/routes/(root)/(logged)/scripts/edit/[...path]/+page.svelte index 24b5d42468..bb706edc16 100644 --- a/frontend/src/routes/(root)/(logged)/scripts/edit/[...path]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/scripts/edit/[...path]/+page.svelte @@ -57,14 +57,13 @@ } } ]) - topHash = scriptLoadedFromUrl.hash } else { if (hash) { const scriptByHash = await ScriptService.getScriptByHash({ workspace: $workspaceStore!, hash }) - script = { ...scriptByHash, lock: undefined } + script = { ...scriptByHash, parent_hash: hash, lock: undefined } } else { const scriptWithDraft = await ScriptService.getScriptByPathWithDraft({ workspace: $workspaceStore!, @@ -100,7 +99,7 @@ } else { script = scriptWithDraft } - topHash = scriptWithDraft.hash + script.parent_hash = scriptWithDraft.hash } } // hash @@ -116,7 +115,9 @@ if (script) { initialPath = script.path scriptBuilder?.setCode(script.content) - script.parent_hash = topHash + if (topHash) { + script.parent_hash = topHash + } } } @@ -131,5 +132,5 @@ {#if script} - + {/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 a3d3c429a2..d3074030cc 100644 --- a/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte @@ -196,7 +196,7 @@ let moveDrawer: MoveDrawer let deploymentDrawer: DeployWorkspaceDrawer - function getMainButtons(script: Script | undefined, args: object | undefined) { + function getMainButtons(script: Script | undefined, args: object | undefined, topHash?: string) { const buttons: any = [] if (!topHash && script) { @@ -273,7 +273,7 @@ return buttons } - $: mainButtons = getMainButtons(script, args) + $: mainButtons = getMainButtons(script, args, topHash) function getMenuItems(script: Script | undefined) { if (!script || $userStore?.operator) return []