fix loading flow from blank state

This commit is contained in:
Ruben Fiszel
2022-08-01 13:36:09 +02:00
parent 8a6d977a95
commit e2788a2003
5 changed files with 38 additions and 37 deletions
+23 -16
View File
@@ -115,7 +115,9 @@
}
flowStore.subscribe((flow: Flow) => {
setQueryWithoutLoad($page.url, 'state', encodeState(flowToMode(flow, $mode)))
if (flow) {
setQueryWithoutLoad($page.url, 'state', encodeState(flowToMode(flow, $mode)))
}
})
onMount(() => {
@@ -171,6 +173,7 @@
{/if}
</div>
</div>
<div class="flex flex-row-reverse">
<span class="my-1 text-sm text-gray-500 italic">
{#if initialPath && initialPath != $flowStore?.path} {initialPath} &rightarrow; {/if}
@@ -181,21 +184,25 @@
<!-- metadata -->
{#if step === 1}
<FlowEditor
bind:pathError
bind:initialPath
bind:scheduleEnabled
bind:scheduleCron
bind:scheduleArgs
/>
{:else if step === 2}
<ScriptSchema
synchronizedHeader={false}
bind:summary={$flowStore.summary}
bind:description={$flowStore.description}
bind:schema={$flowStore.schema}
/>
{#if $flowStore}
{#if step === 1}
<FlowEditor
bind:pathError
bind:initialPath
bind:scheduleEnabled
bind:scheduleCron
bind:scheduleArgs
/>
{:else if step === 2}
<ScriptSchema
synchronizedHeader={false}
bind:summary={$flowStore.summary}
bind:description={$flowStore.description}
bind:schema={$flowStore.schema}
/>
{/if}
{:else}
<p>Loading</p>
{/if}
</div>
@@ -31,7 +31,6 @@
logs[i] =
(await JobService.getJob({ workspace: $workspaceStore ?? '', id: last.job ?? '' }))
.logs ?? ''
console.log(logs[i])
logs = logs
pres[i].scroll({ top: pres[i]?.scrollHeight, behavior: 'smooth' })
}
@@ -9,7 +9,6 @@
export let format: string
export let value: any
console.log(value)
function isString(value: any) {
return typeof value === 'string' || value instanceof String
}
@@ -58,7 +58,6 @@
} else if (Object.keys(schema.properties).includes(modalProperty.name) && !editing) {
argError = 'There is already an argument with this name'
} else {
console.log('XXXXXX')
schema.properties[modalProperty.name] = modalToSchema(modalProperty)
if (modalProperty.required) {
schema.required = [...schema.required, modalProperty.name]
+15 -18
View File
@@ -17,27 +17,24 @@
const initialState = $page.url.searchParams.get('state')
const hubId = $page.url.searchParams.get('hub')
let flow: Flow =
initialState != undefined
? decodeState(initialState)
: {
path: '',
summary: '',
value: { modules: [] },
edited_by: '',
edited_at: '',
archived: false,
extra_perms: {},
schema: emptySchema()
}
async function loadFlow() {
let flow: Flow =
initialState != undefined
? decodeState(initialState)
: {
path: '',
summary: '',
value: { modules: [] },
edited_by: '',
edited_at: '',
archived: false,
extra_perms: {},
schema: emptySchema()
}
if (hubId) {
const hub = (await FlowService.getHubFlowById({ id: Number(hubId) })).flow
flow.summary = hub?.summary ?? ''
flow.value = hub?.value ?? { modules: [] }
flow.description = hub?.description
flow.schema = hub?.schema ?? emptySchema()
Object.assign(flow, hub)
flow = flow
$page.url.searchParams.delete('hub')
sendUserToast(`Flow has been loaded from hub flow id ${hubId}.`)