mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-20 00:03:21 +00:00
feat: extend get_draft overlay to flow, app, resource, variable, schedule, triggers
This commit is contained in:
@@ -219,9 +219,7 @@
|
||||
const s: ResourceState = {
|
||||
path: '',
|
||||
description: '',
|
||||
args: (defaultValues && Object.keys(defaultValues).length > 0
|
||||
? defaultValues
|
||||
: {}) as any,
|
||||
args: (defaultValues && Object.keys(defaultValues).length > 0 ? defaultValues : {}) as any,
|
||||
labels: undefined,
|
||||
wsSpecific: false
|
||||
}
|
||||
@@ -238,9 +236,12 @@
|
||||
if (ws in states) return
|
||||
untrack(() => {
|
||||
Promise.all([
|
||||
ResourceService.getResource({ workspace: ws, path: initialPath }),
|
||||
ResourceService.getResource({ workspace: ws, path: initialPath, getDraft: true }),
|
||||
getUserExt(ws)
|
||||
]).then(([r, user]) => {
|
||||
if (r.is_draft) {
|
||||
sendUserToast('Loaded your saved draft')
|
||||
}
|
||||
fetchedResources[ws] = r
|
||||
fetchedRev[ws] = r.edited_at
|
||||
const s: ResourceState = {
|
||||
|
||||
@@ -154,9 +154,17 @@
|
||||
if (ws in states) return
|
||||
untrack(() => {
|
||||
Promise.all([
|
||||
VariableService.getVariable({ workspace: ws, path: p, decryptSecret: false }),
|
||||
VariableService.getVariable({
|
||||
workspace: ws,
|
||||
path: p,
|
||||
decryptSecret: false,
|
||||
getDraft: true
|
||||
}),
|
||||
getUserExt(ws)
|
||||
]).then(([v, user]) => {
|
||||
if (v.is_draft) {
|
||||
sendUserToast('Loaded your saved draft')
|
||||
}
|
||||
fetchedRev[ws] = v.edited_at
|
||||
const s: VariableState = {
|
||||
path: v.path,
|
||||
|
||||
@@ -1081,10 +1081,7 @@ async function readWorkspaceItem(
|
||||
true
|
||||
)
|
||||
case 'resource':
|
||||
return resourceToItem(
|
||||
(await ResourceService.getResource({ workspace, path })) as ListableResource,
|
||||
true
|
||||
)
|
||||
return resourceToItem(await ResourceService.getResource({ workspace, path }), true)
|
||||
case 'variable':
|
||||
// Never expose the value, even when read directly. Pass decryptSecret=false
|
||||
// to avoid materializing secret values server-side.
|
||||
@@ -2568,9 +2565,10 @@ async function patchAppFile(
|
||||
}
|
||||
|
||||
async function recomputeAppPolicy(value: AppDraftValue): Promise<void> {
|
||||
const policy = (await updateRawAppPolicy(value.runnables as any, value.policy as any)) as NonNullable<
|
||||
AppDraftValue['policy']
|
||||
>
|
||||
const policy = (await updateRawAppPolicy(
|
||||
value.runnables as any,
|
||||
value.policy as any
|
||||
)) as NonNullable<AppDraftValue['policy']>
|
||||
if (!policy.execution_mode) {
|
||||
policy.execution_mode = 'publisher'
|
||||
}
|
||||
@@ -3045,7 +3043,8 @@ export function prepareGlobalUserMessage(
|
||||
(context) => context.type === 'workspace_script' || context.type === 'workspace_flow'
|
||||
)
|
||||
const activeEditor =
|
||||
options.activeEditor ?? (options.workspace ? getActiveGlobalEditorContext(options.workspace) : undefined)
|
||||
options.activeEditor ??
|
||||
(options.workspace ? getActiveGlobalEditorContext(options.workspace) : undefined)
|
||||
let content = ''
|
||||
|
||||
if (activeEditor) {
|
||||
|
||||
@@ -191,8 +191,12 @@
|
||||
try {
|
||||
const s = await AzureTriggerService.getAzureTrigger({
|
||||
workspace: $workspaceStore!,
|
||||
path: initialPath
|
||||
path: initialPath,
|
||||
getDraft: true
|
||||
})
|
||||
if (s?.is_draft) {
|
||||
sendUserToast('Loaded your saved draft')
|
||||
}
|
||||
loadTriggerConfig(s)
|
||||
} catch (error) {
|
||||
sendUserToast(`Could not load Azure trigger: ${error.body}`, true)
|
||||
|
||||
@@ -212,8 +212,12 @@
|
||||
} else {
|
||||
const s = await EmailTriggerService.getEmailTrigger({
|
||||
workspace: $workspaceStore!,
|
||||
path: initialPath
|
||||
path: initialPath,
|
||||
getDraft: true
|
||||
})
|
||||
if (s?.is_draft) {
|
||||
sendUserToast('Loaded your saved draft')
|
||||
}
|
||||
|
||||
loadTriggerConfig(s)
|
||||
}
|
||||
|
||||
@@ -195,8 +195,12 @@
|
||||
try {
|
||||
const s = await GcpTriggerService.getGcpTrigger({
|
||||
workspace: $workspaceStore!,
|
||||
path: initialPath
|
||||
path: initialPath,
|
||||
getDraft: true
|
||||
})
|
||||
if (s?.is_draft) {
|
||||
sendUserToast('Loaded your saved draft')
|
||||
}
|
||||
loadTriggerConfig(s)
|
||||
} catch (error) {
|
||||
sendUserToast(`Could not load GCP Pub/Sub trigger: ${error.body}`, true)
|
||||
|
||||
@@ -345,8 +345,12 @@
|
||||
} else {
|
||||
const s = await HttpTriggerService.getHttpTrigger({
|
||||
workspace: $workspaceStore!,
|
||||
path: initialPath
|
||||
path: initialPath,
|
||||
getDraft: true
|
||||
})
|
||||
if (s?.is_draft) {
|
||||
sendUserToast('Loaded your saved draft')
|
||||
}
|
||||
|
||||
loadTriggerConfig(s)
|
||||
}
|
||||
|
||||
@@ -251,8 +251,12 @@
|
||||
} else {
|
||||
const s = await KafkaTriggerService.getKafkaTrigger({
|
||||
workspace: $workspaceStore!,
|
||||
path: initialPath
|
||||
path: initialPath,
|
||||
getDraft: true
|
||||
})
|
||||
if (s?.is_draft) {
|
||||
sendUserToast('Loaded your saved draft')
|
||||
}
|
||||
loadTriggerConfig(s)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,8 +251,12 @@
|
||||
} else {
|
||||
const s = await MqttTriggerService.getMqttTrigger({
|
||||
workspace: $workspaceStore!,
|
||||
path: initialPath
|
||||
path: initialPath,
|
||||
getDraft: true
|
||||
})
|
||||
if (s?.is_draft) {
|
||||
sendUserToast('Loaded your saved draft')
|
||||
}
|
||||
loadTriggerConfig(s)
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -233,8 +233,12 @@
|
||||
} else {
|
||||
const s = await NatsTriggerService.getNatsTrigger({
|
||||
workspace: $workspaceStore!,
|
||||
path: initialPath
|
||||
path: initialPath,
|
||||
getDraft: true
|
||||
})
|
||||
if (s?.is_draft) {
|
||||
sendUserToast('Loaded your saved draft')
|
||||
}
|
||||
loadTriggerConfig(s)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,8 +377,12 @@
|
||||
} else {
|
||||
const s = await PostgresTriggerService.getPostgresTrigger({
|
||||
workspace: $workspaceStore!,
|
||||
path: initialPath
|
||||
path: initialPath,
|
||||
getDraft: true
|
||||
})
|
||||
if (s?.is_draft) {
|
||||
sendUserToast('Loaded your saved draft')
|
||||
}
|
||||
|
||||
const publication_data = await PostgresTriggerService.getPostgresPublication({
|
||||
path: s.postgres_resource_path,
|
||||
|
||||
@@ -285,10 +285,15 @@
|
||||
try {
|
||||
let s: Schedule | undefined
|
||||
if (schedule_path) {
|
||||
s = await ScheduleService.getSchedule({
|
||||
const resp = await ScheduleService.getSchedule({
|
||||
workspace: $workspaceStore!,
|
||||
path: schedule_path
|
||||
path: schedule_path,
|
||||
getDraft: true
|
||||
})
|
||||
if (resp.is_draft) {
|
||||
sendUserToast('Loaded your saved draft')
|
||||
}
|
||||
s = resp
|
||||
initNewPath = true
|
||||
} else if (defaultValues) {
|
||||
s = defaultValues
|
||||
@@ -451,8 +456,12 @@
|
||||
try {
|
||||
const s = await ScheduleService.getSchedule({
|
||||
workspace: $workspaceStore!,
|
||||
path: initialPath
|
||||
path: initialPath,
|
||||
getDraft: true
|
||||
})
|
||||
if (s.is_draft) {
|
||||
sendUserToast('Loaded your saved draft')
|
||||
}
|
||||
await loadScheduleCfg(s)
|
||||
} catch (err) {
|
||||
sendUserToast(`Could not load schedule: ${err}`, true)
|
||||
|
||||
@@ -228,8 +228,12 @@
|
||||
} else {
|
||||
const s = await SqsTriggerService.getSqsTrigger({
|
||||
workspace: $workspaceStore!,
|
||||
path: initialPath
|
||||
path: initialPath,
|
||||
getDraft: true
|
||||
})
|
||||
if (s?.is_draft) {
|
||||
sendUserToast('Loaded your saved draft')
|
||||
}
|
||||
loadTriggerConfig(s)
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -308,8 +308,12 @@
|
||||
} else {
|
||||
const s = await WebsocketTriggerService.getWebsocketTrigger({
|
||||
workspace: $workspaceStore!,
|
||||
path: initialPath
|
||||
path: initialPath,
|
||||
getDraft: true
|
||||
})
|
||||
if (s?.is_draft) {
|
||||
sendUserToast('Loaded your saved draft')
|
||||
}
|
||||
loadTriggerConfig(s)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,9 +90,13 @@
|
||||
const tok = ++loadAppToken
|
||||
const backendApp = await AppService.getAppByPath({
|
||||
path: page.params.path ?? '',
|
||||
workspace: $workspaceStore!
|
||||
workspace: $workspaceStore!,
|
||||
getDraft: true
|
||||
})
|
||||
if (tok !== loadAppToken) return
|
||||
if (backendApp.is_draft) {
|
||||
sendUserToast('Loaded your saved draft')
|
||||
}
|
||||
const backendApp_ = structuredClone(stateSnapshot(backendApp))
|
||||
savedApp = {
|
||||
summary: backendApp_.summary,
|
||||
|
||||
@@ -177,9 +177,13 @@
|
||||
const tok = ++loadAppToken
|
||||
const backendApp = await AppService.getAppByPath({
|
||||
path: page.params.path ?? '',
|
||||
workspace: $workspaceStore!
|
||||
workspace: $workspaceStore!,
|
||||
getDraft: true
|
||||
})
|
||||
if (tok !== loadAppToken) return
|
||||
if (backendApp.is_draft) {
|
||||
sendUserToast('Loaded your saved draft')
|
||||
}
|
||||
const backendApp_ = structuredClone(stateSnapshot(backendApp))
|
||||
savedApp = {
|
||||
summary: backendApp_.summary,
|
||||
|
||||
@@ -145,9 +145,13 @@
|
||||
|
||||
const backendFlow = await FlowService.getFlowByPath({
|
||||
workspace: $workspaceStore!,
|
||||
path: page.params.path ?? ''
|
||||
path: page.params.path ?? '',
|
||||
getDraft: true
|
||||
})
|
||||
if (tok !== loadFlowToken) return
|
||||
if (backendFlow.is_draft) {
|
||||
sendUserToast('Loaded your saved draft')
|
||||
}
|
||||
savedFlow = structuredClone($state.snapshot(backendFlow)) as Flow
|
||||
|
||||
const localDraft = flowHandle.draft
|
||||
|
||||
Reference in New Issue
Block a user