From f7e23acfdcd19e0af19b5d6416a2843d72e3a067 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Fri, 2 Jun 2023 11:51:47 +0200 Subject: [PATCH] fix: renaming app + improve flow rendering --- backend/windmill-api/src/apps.rs | 4 +- .../lib/components/FlowStatusViewer.svelte | 309 +++++++++--------- .../src/lib/components/SchemaEditor.svelte | 1 + .../apps/editor/AppEditorHeader.svelte | 12 +- .../lib/components/flows/map/MapItem.svelte | 8 +- .../src/lib/components/graph/FlowGraph.svelte | 2 +- 6 files changed, 181 insertions(+), 155 deletions(-) diff --git a/backend/windmill-api/src/apps.rs b/backend/windmill-api/src/apps.rs index 87977c6b17..adb84be856 100644 --- a/backend/windmill-api/src/apps.rs +++ b/backend/windmill-api/src/apps.rs @@ -602,7 +602,7 @@ async fn update_app( if let Some(nvalue) = &ns.value { let app_id = sqlx::query_scalar!( "SELECT id FROM app WHERE path = $1 AND workspace_id = $2", - path, + npath, w_id ) .fetch_one(&mut tx) @@ -623,7 +623,7 @@ async fn update_app( sqlx::query!( "UPDATE app SET versions = array_append(versions, $1) WHERE path = $2 AND workspace_id = $3", v_id, - path, + npath, w_id ) .execute(&mut tx) diff --git a/frontend/src/lib/components/FlowStatusViewer.svelte b/frontend/src/lib/components/FlowStatusViewer.svelte index bb5bb19360..740c9acb50 100644 --- a/frontend/src/lib/components/FlowStatusViewer.svelte +++ b/frontend/src/lib/components/FlowStatusViewer.svelte @@ -37,6 +37,7 @@ let localFlowModuleStates: Record = {} export let retry_status: Record = {} export let suspend_status: number | undefined = undefined + export let render = true export let is_owner = false @@ -152,7 +153,7 @@ $: jobId && updateJobId() - $: isListJob = flowJobIds && Array.isArray(flowJobIds?.flowJobs) + $: isListJob = flowJobIds != undefined && Array.isArray(flowJobIds?.flowJobs) onDestroy(() => { timeout && clearTimeout(timeout) @@ -162,7 +163,7 @@ is_owner = isOwner(path, $userStore!, workspaceId ?? $workspaceStore!) } - let selected: 'graph' | 'sequence' = 'graph' + $: selected = isListJob ? 'sequence' : 'graph' let payload: string = '"a test payload in json"' @@ -209,10 +210,12 @@

Flow result

{/if} {#if isListJob} -
- -
- {:else} + {#if render} +
+ +
+ {/if} + {:else if render}
0 ? 'border border-gray-400 shadow p-2' : ''}> {#if `result` in job} @@ -291,48 +294,51 @@ {/if}
{/if} - - {#if innerModules.length > 0 && !isListJob} - - Graph - Details - + {#if render} + {#if innerModules.length > 0 && !isListJob} + + Graph + Details + + {/if} {/if} - -
+
{#if isListJob}

Embedded flows: ({flowJobIds?.flowJobs.length} items)

{#each flowJobIds?.flowJobs ?? [] as loopJobId, j} - + + + {/if}
{#each innerModules as mod, i} -
-

- {#if job?.raw_flow?.modules && i < job?.raw_flow?.modules.length} - Step - - {i + 1} - - out of - {job?.raw_flow?.modules.length} - {#if job.raw_flow?.modules[i]?.summary} - : - {job.raw_flow?.modules[i]?.summary ?? ''} + {#if render} +
+

+ {#if job?.raw_flow?.modules && i < job?.raw_flow?.modules.length} + Step + + {i + 1} + out of + {job?.raw_flow?.modules.length} + {#if job.raw_flow?.modules[i]?.summary} + : + {job.raw_flow?.modules[i]?.summary ?? ''} + + {/if} + {:else} +

Failure module

{/if} - {:else} -

Failure module

- {/if} -

-
+ +
+ {/if}
  • {#if [FlowStatusModule.type.IN_PROGRESS, FlowStatusModule.type.SUCCESS, FlowStatusModule.type.FAILURE].includes(mod.type)} {#if job.raw_flow?.modules[i]?.value.type == 'flow'} {:else}
  • - {#if job.raw_flow && !isListJob} -
    -
    -
    -
    - {#each Object.values(retry_status) as count} - - Retry in progress, # of failed attempts: {count} - - {/each} - {#if suspend_status} - - Flow suspended, waiting for {pluralize(suspend_status, 'approval')} - - {/if} -
    - - { - if (typeof e.detail == 'string') { - if (e.detail == 'Input') { - selectedNode = 'start' - } else if (e.detail == 'Result') { - selectedNode = 'end' - } else { - selectedNode = e.detail - } - } else { - selectedNode = e.detail.id - } - }} - modules={job.raw_flow?.modules ?? []} - failureModule={job.raw_flow?.failure_module} - /> -
    -
    - {#if selectedNode} - {@const node = localFlowModuleStates[selectedNode]} - {#if selectedNode == 'end'} - - {:else if selectedNode == 'start'} - {#if job.args} -
    - -
    - {:else} -

    No arguments

    + {#if render} + {#if job.raw_flow && !isListJob} +
    +
    +
    +
    + {#each Object.values(retry_status) as count} + + Retry in progress, # of failed attempts: {count} + + {/each} + {#if suspend_status} + + Flow suspended, waiting for {pluralize(suspend_status, 'approval')} + {/if} - {:else if node} -
    - - {#if node.job_id} - - {/if} -
    -
    - -
    +
    - - {:else} -

    The execution of this node has no information attached to it. The job likely did - not run yet

    - {/if} - {:else}

    Select a node to see its details here

    {/if} + { + if (typeof e.detail == 'string') { + if (e.detail == 'Input') { + selectedNode = 'start' + } else if (e.detail == 'Result') { + selectedNode = 'end' + } else { + selectedNode = e.detail + } + } else { + selectedNode = e.detail.id + } + }} + modules={job.raw_flow?.modules ?? []} + failureModule={job.raw_flow?.failure_module} + /> +
    +
    + {#if selectedNode} + {@const node = localFlowModuleStates[selectedNode]} + {#if selectedNode == 'end'} + + {:else if selectedNode == 'start'} + {#if job.args} +
    + +
    + {:else} +

    No arguments

    + {/if} + {:else if node} +
    + + {#if node.job_id} + + {/if} +
    +
    + +
    + + + {:else} +

    The execution of this node has no information attached to it. The job likely did + not run yet

    + {/if} + {:else}

    Select a node to see its details here

    {/if} +
    -
    + {/if} {/if} {:else} Job loading... diff --git a/frontend/src/lib/components/SchemaEditor.svelte b/frontend/src/lib/components/SchemaEditor.svelte index cbc813ba9e..c4de98d601 100644 --- a/frontend/src/lib/components/SchemaEditor.svelte +++ b/frontend/src/lib/components/SchemaEditor.svelte @@ -67,6 +67,7 @@ function handleAddOrEditArgument(modalProperty: ModalSchemaProperty): void { // If editing the arg's name, oldName containing the old argument name must be provided argError = '' + modalProperty.name = modalProperty.name.trim() if (modalProperty.name.length === 0) { argError = 'Arguments need to have a name' } else if (Object.keys(schema.properties).includes(modalProperty.name) && !editing) { diff --git a/frontend/src/lib/components/apps/editor/AppEditorHeader.svelte b/frontend/src/lib/components/apps/editor/AppEditorHeader.svelte index 40d29838ce..2c6438f946 100644 --- a/frontend/src/lib/components/apps/editor/AppEditorHeader.svelte +++ b/frontend/src/lib/components/apps/editor/AppEditorHeader.svelte @@ -206,20 +206,26 @@ } } - async function updateApp(path: string) { + async function updateApp(npath: string) { await computeTriggerables() await AppService.updateApp({ workspace: $workspaceStore!, - path, + path: appPath, requestBody: { value: $app!, summary: $summary, - policy + policy, + path: npath } }) + $dirtyStore = false closeSaveDrawer() sendUserToast('App deployed successfully') + if (appPath !== npath) { + await goto(`/apps/edit/${npath}?nodraft=true`) + window.location.reload() + } } let secretUrl: string | undefined = undefined diff --git a/frontend/src/lib/components/flows/map/MapItem.svelte b/frontend/src/lib/components/flows/map/MapItem.svelte index 71272a2acf..e23fa6ae17 100644 --- a/frontend/src/lib/components/flows/map/MapItem.svelte +++ b/frontend/src/lib/components/flows/map/MapItem.svelte @@ -15,7 +15,7 @@ export let trigger: boolean export let insertable: boolean export let insertableEnd = false - // export let annotation: string | undefined = undefined + export let annotation: string | undefined = undefined export let branchable: boolean = false export let bgColor: string = '' export let modules: FlowModule[] @@ -87,6 +87,12 @@
    {/if} + {#if annotation && annotation != ''} +
    + {annotation} +
    + {/if} +
    {#if mod.value.type === 'forloopflow'}