feat: approval steps description

This commit is contained in:
Ruben Fiszel
2024-03-27 14:03:53 +01:00
parent 240ae93748
commit 810136a4a4
7 changed files with 93 additions and 21 deletions

View File

@@ -203,6 +203,8 @@ pub struct Suspend {
pub user_groups_required: Option<InputTransform>,
#[serde(skip_serializing_if = "Option::is_none")]
pub self_approval_disabled: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub hide_cancel: Option<bool>,
}
#[derive(Deserialize, Serialize, Debug, Clone)]

View File

@@ -34,6 +34,7 @@
export let jobId: string | undefined = undefined
export let workspaceId: string | undefined = undefined
export let hideAsJson: boolean = false
export let noControls: boolean = false
let resultKind:
| 'json'
@@ -288,7 +289,7 @@
</div>
<div class="text-tertiary text-xs flex gap-2 z-10 items-center">
<slot name="copilot-fix" />
{#if !disableExpand}
{#if !disableExpand && !noControls}
<button on:click={() => copyToClipboard(toJsonStr(result))}
><ClipboardCopy size={16} /></button
>
@@ -542,11 +543,13 @@
{/if}
{:else if typeof result == 'string' && result.length > 0}
<pre class="text-sm">{result}</pre>
<div class="flex">
<Button on:click={() => copyToClipboard(result)} color="light" size="xs">
<div class="flex gap-2 items-center">Copy <ClipboardCopy size={12} /> </div>
</Button>
</div>
{#if !noControls}
<div class="flex">
<Button on:click={() => copyToClipboard(result)} color="light" size="xs">
<div class="flex gap-2 items-center">Copy <ClipboardCopy size={12} /> </div>
</Button>
</div>
{/if}
{:else}
<Highlight
class={forceJson ? '' : 'h-full w-full'}

View File

@@ -3,6 +3,7 @@
import { Job, JobService } from '$lib/gen'
import { workspaceStore } from '$lib/stores'
import { sendUserToast } from '$lib/toast'
import DisplayResult from './DisplayResult.svelte'
import LightweightSchemaForm from './LightweightSchemaForm.svelte'
import Tooltip from './Tooltip.svelte'
import { Button } from './common'
@@ -14,6 +15,7 @@
let default_payload: object = {}
let enum_payload: object = {}
let resumeUrl: string | undefined = undefined
let description: any = undefined
$: approvalStep = (job?.flow_status?.step ?? 1) - 1
@@ -35,6 +37,7 @@
id: jobId
})
const args = job_result?.default_args ?? {}
description = job_result?.description
defaultValues = JSON.parse(JSON.stringify(args))
default_payload = args
@@ -45,6 +48,9 @@
<div class="w-full h-full mt-2 text-sm text-tertiary">
<p>Waiting to be resumed</p>
{#if description != undefined}
<DisplayResult noControls result={description} />
{/if}
<div>
{#if isOwner || resumeUrl}
<div class="flex flex-row gap-2 mt-2">

View File

@@ -221,6 +221,13 @@
</div>
{/if}
{#if flowModule.suspend?.resume_form}
<Toggle
bind:checked={flowModule.suspend.hide_cancel}
size="xs"
options={{
right: 'Hide cancel button on approval page'
}}
/>
<SchemaEditor bind:schema={flowModule.suspend.resume_form.schema} />
{/if}
</div>

View File

@@ -277,22 +277,62 @@ func main() (interface{}, error) {
export const DENO_INIT_CODE_APPROVAL = `import * as wmill from "npm:windmill-client@^1.158.2"
export async function main(approver?: string) {
return wmill.getResumeUrls(approver)
const urls = await wmill.getResumeUrls(approver)
// send the urls to their intended recipients
// if the resumeUrls are part of the response, they will be available to any persons having access
// to the run page and allowed to be approved from there, even from non owners of the flow
// self-approval is disablable in the suspend options
return {
...urls,
default_args: {},
enums: {},
description: undefined
}
}`
export const BUN_INIT_CODE_APPROVAL = `import * as wmill from "windmill-client@^1.158.2"
export async function main(approver?: string) {
const urls = await wmill.getResumeUrls(approver)
// send the urls to their intended recipients
// if the resumeUrls are part of the response, they will be available to any persons having access
// to the run page and allowed to be approved from there, even from non owners of the flow
// self-approval is disablable in the suspend options
return {
...urls,
default_args: {},
enums: {},
description: undefined
// supports all formats from rich display rendering such as simple strings,
// but also markdown, html, images, tables, maps, render_all, etc...
// https://www.windmill.dev/docs/core_concepts/rich_display_rendering
}
}`
export const PYTHON_INIT_CODE_APPROVAL = `import wmill
def main():
urls = wmill.get_resume_urls()
return urls
# send the urls to their intended recipients
# if the get_resume_urls are part of the response, they will be available to any persons having access
# to the run page and allowed to be approved from there, even from non owners of the flow
# self-approval is disablable in the suspend options
return {
**urls,
"default_args": {},
"enums": {},
"description": None,
# supports all formats from rich display rendering such as simple strings,
# but also markdown, html, images, tables, maps, render_all, etc...
# https://www.windmill.dev/docs/core_concepts/rich_display_rendering
}
`
export const BUN_INIT_CODE_APPROVAL = `import * as wmill from "windmill-client@^1.158.2"
export async function main(approver?: string) {
return wmill.getResumeUrls(approver)
}`
export const DOCKER_INIT_CODE = `# shellcheck shell=bash
# Bash script that calls docker as a client to the host daemon
# See documentation: https://www.windmill.dev/docs/advanced/docker

View File

@@ -17,6 +17,7 @@
import { Alert } from '$lib/components/common'
import { getUserExt } from '$lib/user'
import { setLicense } from '$lib/enterpriseUtils'
import DisplayResult from '$lib/components/DisplayResult.svelte'
$workspaceStore = $page.params.workspace
let rd = $page.url.href.replace($page.url.origin, '')
@@ -37,6 +38,7 @@
let error: string | undefined = undefined
let default_payload: any = {}
let enum_payload: object = {}
let description: any = undefined
setLicense()
@@ -80,6 +82,7 @@
workspace: job?.workspace_id ?? '',
id: jobId
})
description = job_result?.description
default_payload = job_result?.default_args ?? {}
enum_payload = job_result?.enums ?? {}
}
@@ -203,6 +206,10 @@
<div class="my-2"><p><b>You have already approved this flow to be resumed</b></p></div>
{/if}
{#if description != undefined}
<DisplayResult noControls result={description} />
{/if}
{#if schema}
{#if emptyString($enterpriseLicense)}
<Alert type="warning" title="Adding a form to the approval page is an EE feature" />
@@ -217,13 +224,18 @@
{/if}
<div class="w-max-md flex flex-row gap-x-4 gap-y-4 justify-between w-full flex-wrap mt-2">
<Button
btnClasses="grow"
color="red"
on:click|once={cancel}
size="md"
disabled={completed || alreadyResumed}>Deny</Button
>
{#if !job?.raw_flow?.modules?.[approvalStep]?.suspend?.hide_cancel}
<Button
btnClasses="grow"
color="red"
on:click|once={cancel}
size="md"
disabled={completed || alreadyResumed}>Deny</Button
>
{:else}
<div />
{/if}
<Button
btnClasses="grow"
color="green"

View File

@@ -135,6 +135,8 @@ components:
$ref: "#/components/schemas/InputTransform"
self_approval_disabled:
type: boolean
hide_cancel:
type: boolean
priority:
type: number