fix topHash issue
This commit is contained in:
@@ -33,7 +33,6 @@
|
||||
export let template: 'pgsql' | 'mysql' | 'script' | 'docker' | 'powershell' = 'script'
|
||||
export let initialArgs: Record<string, any> = {}
|
||||
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,
|
||||
|
||||
@@ -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 @@
|
||||
|
||||
<DiffDrawer bind:this={diffDrawer} button={{ text: 'Revert', onClick: reloadAction }} />
|
||||
{#if script}
|
||||
<ScriptBuilder bind:this={scriptBuilder} {topHash} {initialPath} {script} {initialArgs} />
|
||||
<ScriptBuilder bind:this={scriptBuilder} {initialPath} {script} {initialArgs} />
|
||||
{/if}
|
||||
|
||||
@@ -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 []
|
||||
|
||||
Reference in New Issue
Block a user