mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-18 16:02:10 +00:00
persist args when editing from a job run
This commit is contained in:
@@ -33,6 +33,7 @@ export const enterpriseLicense = writable<string | undefined>(undefined)
|
||||
export const workerTags = writable<string[] | undefined>(undefined)
|
||||
export const usageStore = writable<number>(0)
|
||||
export const workspaceUsageStore = writable<number>(0)
|
||||
export const initialArgsStore = writable<any>(undefined)
|
||||
export const oauthStore = writable<TokenResponse | undefined>(undefined)
|
||||
export const userStore = writable<UserExt | undefined>(undefined)
|
||||
export const workspaceStore = writable<string | undefined>(
|
||||
|
||||
@@ -272,19 +272,6 @@ export function itemsExists<T>(arr: T[] | undefined, item: T): boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
export function decodeArgs(queryArgs: string | undefined): any {
|
||||
if (queryArgs) {
|
||||
const parsed = decodeState(queryArgs)
|
||||
Object.entries(parsed).forEach(([k, v]) => {
|
||||
if (v == '<function call>') {
|
||||
parsed[k] = undefined
|
||||
}
|
||||
})
|
||||
return parsed
|
||||
}
|
||||
return {}
|
||||
}
|
||||
|
||||
let debounced: NodeJS.Timeout | undefined = undefined
|
||||
export function setQueryWithoutLoad(
|
||||
url: URL,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import type { FlowState } from '$lib/components/flows/flowState'
|
||||
import { importFlowStore, initFlow } from '$lib/components/flows/flowStore'
|
||||
import { FlowService, type Flow } from '$lib/gen'
|
||||
import { userStore, workspaceStore } from '$lib/stores'
|
||||
import { initialArgsStore, userStore, workspaceStore } from '$lib/stores'
|
||||
import { sendUserToast } from '$lib/toast'
|
||||
import { decodeState, emptySchema } from '$lib/utils'
|
||||
import { tick } from 'svelte'
|
||||
@@ -29,6 +29,12 @@
|
||||
let initialPath: string | undefined = undefined
|
||||
let pathStoreInit: string | undefined = undefined
|
||||
|
||||
let initialArgs = {}
|
||||
if ($initialArgsStore) {
|
||||
initialArgs = $initialArgsStore
|
||||
$initialArgsStore = undefined
|
||||
}
|
||||
|
||||
export const flowStore = writable<Flow>({
|
||||
summary: '',
|
||||
value: { modules: [] },
|
||||
@@ -147,6 +153,7 @@
|
||||
bind:this={flowBuilder}
|
||||
newFlow
|
||||
bind:savedFlow
|
||||
{initialArgs}
|
||||
{flowStore}
|
||||
{flowStateStore}
|
||||
{selectedId}
|
||||
|
||||
@@ -3,14 +3,8 @@
|
||||
|
||||
import { page } from '$app/stores'
|
||||
import FlowBuilder from '$lib/components/FlowBuilder.svelte'
|
||||
import { workspaceStore } from '$lib/stores'
|
||||
import {
|
||||
cleanValueProperties,
|
||||
decodeArgs,
|
||||
decodeState,
|
||||
emptySchema,
|
||||
orderedJsonStringify
|
||||
} from '$lib/utils'
|
||||
import { initialArgsStore, workspaceStore } from '$lib/stores'
|
||||
import { cleanValueProperties, decodeState, emptySchema, orderedJsonStringify } from '$lib/utils'
|
||||
import { initFlow } from '$lib/components/flows/flowStore'
|
||||
import { goto } from '$app/navigation'
|
||||
import { writable } from 'svelte/store'
|
||||
@@ -22,7 +16,11 @@
|
||||
let nodraft = $page.url.searchParams.get('nodraft')
|
||||
const initialState = nodraft ? undefined : localStorage.getItem(`flow-${$page.params.path}`)
|
||||
let stateLoadedFromUrl = initialState != undefined ? decodeState(initialState) : undefined
|
||||
const initialArgs = decodeArgs($page.url.searchParams.get('args') ?? undefined)
|
||||
let initialArgs = {}
|
||||
if ($initialArgsStore) {
|
||||
initialArgs = $initialArgsStore
|
||||
$initialArgsStore = undefined
|
||||
}
|
||||
|
||||
let savedFlow:
|
||||
| (Flow & {
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
import DisplayResult from '$lib/components/DisplayResult.svelte'
|
||||
import {
|
||||
enterpriseLicense,
|
||||
initialArgsStore,
|
||||
superadmin,
|
||||
userStore,
|
||||
userWorkspaces,
|
||||
@@ -256,12 +257,14 @@
|
||||
|
||||
function forkPreview() {
|
||||
if (job?.job_kind == 'flowpreview') {
|
||||
$initialArgsStore = job?.args
|
||||
const state = {
|
||||
flow: { value: job?.raw_flow },
|
||||
path: job?.script_path + '_fork'
|
||||
}
|
||||
window.open(`/flows/add#${encodeState(state)}`)
|
||||
} else {
|
||||
$initialArgsStore = job?.args
|
||||
let n: NewScript = {
|
||||
path: job?.script_path + '_fork',
|
||||
summary: 'Fork of preview of ' + job?.script_path,
|
||||
@@ -576,6 +579,7 @@
|
||||
{#if canWrite(job?.script_path ?? '', {}, $userStore)}
|
||||
<Button
|
||||
on:click|once={() => {
|
||||
$initialArgsStore = job?.args
|
||||
goto(`${stem}/edit/${job?.script_path}${isScript ? `` : `?nodraft=true`}`)
|
||||
}}
|
||||
color="blue"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { type NewScript, ScriptService, type Script } from '$lib/gen'
|
||||
|
||||
import { page } from '$app/stores'
|
||||
import { defaultScripts, workspaceStore } from '$lib/stores'
|
||||
import { defaultScripts, initialArgsStore, workspaceStore } from '$lib/stores'
|
||||
import ScriptBuilder from '$lib/components/ScriptBuilder.svelte'
|
||||
import type { Schema } from '$lib/common'
|
||||
import { decodeState, emptySchema, emptyString } from '$lib/utils'
|
||||
@@ -16,6 +16,13 @@
|
||||
const hubPath = $page.url.searchParams.get('hub')
|
||||
const showMeta = /true|1/i.test($page.url.searchParams.get('show_meta') ?? '0')
|
||||
|
||||
let initialArgs = {}
|
||||
|
||||
if ($initialArgsStore) {
|
||||
initialArgs = $initialArgsStore
|
||||
$initialArgsStore = undefined
|
||||
}
|
||||
|
||||
const path = $page.url.searchParams.get('path')
|
||||
|
||||
const initialState = $page.url.hash != '' ? $page.url.hash.slice(1) : undefined
|
||||
@@ -92,6 +99,7 @@
|
||||
</script>
|
||||
|
||||
<ScriptBuilder
|
||||
{initialArgs}
|
||||
bind:this={scriptBuilder}
|
||||
lockedLanguage={templatePath != null || hubPath != null}
|
||||
on:deploy={(e) => {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { ScriptService, type NewScript, type NewScriptWithDraft, DraftService } from '$lib/gen'
|
||||
|
||||
import { page } from '$app/stores'
|
||||
import { workspaceStore } from '$lib/stores'
|
||||
import { initialArgsStore, workspaceStore } from '$lib/stores'
|
||||
import ScriptBuilder from '$lib/components/ScriptBuilder.svelte'
|
||||
import { decodeState, cleanValueProperties, orderedJsonStringify } from '$lib/utils'
|
||||
import { goto } from '$app/navigation'
|
||||
@@ -12,6 +12,11 @@
|
||||
|
||||
const initialState = $page.url.hash != '' ? $page.url.hash.slice(1) : undefined
|
||||
let initialArgs = {}
|
||||
|
||||
if ($initialArgsStore) {
|
||||
initialArgs = $initialArgsStore
|
||||
$initialArgsStore = undefined
|
||||
}
|
||||
let topHash = $page.url.searchParams.get('topHash') ?? undefined
|
||||
|
||||
let hash = $page.url.searchParams.get('hash') ?? undefined
|
||||
|
||||
Reference in New Issue
Block a user