Skip to content

Commit

Permalink
flow builder args handling improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenfiszel committed Jan 28, 2023
1 parent 6907f98 commit 1463b2d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.analysis.typeCheckingMode": "basic"
}
11 changes: 8 additions & 3 deletions frontend/src/lib/components/InputTransformForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,13 @@
const openBracket = '${'
const closeBracket = '}'
$: schema.properties[argName].default &&
!arg?.value &&
monacoTemplate?.setCode(schema.properties[argName].default)
function setDefaultCode() {
if (!arg?.value) {
monacoTemplate?.setCode(schema.properties[argName].default)
}
}
$: schema.properties[argName].default && setDefaultCode()
</script>

{#if arg != undefined}
Expand Down Expand Up @@ -172,6 +176,7 @@
if (staticTemplate) {
if (arg) {
arg.value = codeToStaticTemplate(arg.expr)
arg.expr = undefined
}
setPropertyType(arg?.value)
} else {
Expand Down
6 changes: 2 additions & 4 deletions frontend/src/lib/components/flows/CreateActionsFlow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@
import Drawer from '$lib/components/common/drawer/Drawer.svelte'
import DrawerContent from '$lib/components/common/drawer/DrawerContent.svelte'
import SimpleEditor from '$lib/components/SimpleEditor.svelte'
import { flowStore, initFlow } from '$lib/components/flows/flowStore'
import { importFlowStore } from '$lib/components/flows/flowStore'
import { Icon } from 'svelte-awesome'
let drawer: Drawer | undefined = undefined
let pendingJson: string
async function importJson() {
await goto('/flows/add')
Object.assign($flowStore, JSON.parse(pendingJson))
initFlow($flowStore)
$importFlowStore = JSON.parse(pendingJson)
drawer?.closeDrawer?.()
}
</script>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lib/components/flows/flowStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { numberToChars } from './utils'

export type FlowMode = 'push' | 'pull'

export const importFlowStore = writable<Flow | undefined>(undefined)
export const flowStore = writable<Flow>({
summary: '',
value: { modules: [] },
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/routes/(root)/(logged)/flows/add/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { dirtyStore } from '$lib/components/common/confirmationModal/dirtyStore'
import FlowBuilder from '$lib/components/FlowBuilder.svelte'
import { initFlow } from '$lib/components/flows/flowStore'
import { importFlowStore, initFlow } from '$lib/components/flows/flowStore'
import { FlowService, type Flow } from '$lib/gen'
import { userStore, workspaceStore } from '$lib/stores'
import { decodeState, emptySchema, sendUserToast } from '$lib/utils'
Expand Down Expand Up @@ -36,7 +36,11 @@
}
let state = initialState ? decodeState(initialState) : undefined
if (!templatePath && !hubId && state) {
if ($importFlowStore) {
flow = $importFlowStore
$importFlowStore = undefined
sendUserToast('Flow loaded from JSON')
} else if (!templatePath && !hubId && state) {
sendUserToast('Flow restored from draft')
flow = state.flow
state?.selectedId && (selectedId = state?.selectedId)
Expand Down

0 comments on commit 1463b2d

Please sign in to comment.