mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-20 00:02:19 +00:00
fix: minor bug fixes (#2566)
This commit is contained in:
@@ -110,16 +110,19 @@
|
||||
let loadingDraft = false
|
||||
|
||||
async function saveDraft(): Promise<void> {
|
||||
const flow = cleanInputs($flowStore)
|
||||
if (!newFlow && !savedFlow) {
|
||||
return
|
||||
}
|
||||
if (savedFlow) {
|
||||
const draftOrDeployed = cleanValueProperties(savedFlow.draft || savedFlow)
|
||||
const current = cleanValueProperties(flow)
|
||||
const current = cleanValueProperties($flowStore)
|
||||
if (orderedJsonStringify(draftOrDeployed) === orderedJsonStringify(current)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
loadingDraft = true
|
||||
try {
|
||||
const flow = cleanInputs($flowStore)
|
||||
localStorage.removeItem('flow')
|
||||
localStorage.removeItem(`flow-${$pathStore}`)
|
||||
|
||||
@@ -148,10 +151,15 @@
|
||||
})
|
||||
|
||||
savedFlow = {
|
||||
...cloneDeep(flow),
|
||||
path: newFlow ? $pathStore : initialPath,
|
||||
...(newFlow
|
||||
? {
|
||||
...cloneDeep($flowStore),
|
||||
path: $pathStore,
|
||||
draft_only: true
|
||||
}
|
||||
: savedFlow),
|
||||
draft: {
|
||||
...cloneDeep(flow),
|
||||
...cloneDeep($flowStore),
|
||||
path: newFlow ? $pathStore : initialPath
|
||||
}
|
||||
} as Flow & {
|
||||
@@ -178,13 +186,8 @@
|
||||
|
||||
async function saveFlow(): Promise<void> {
|
||||
loadingSave = true
|
||||
|
||||
const flow = cleanInputs($flowStore)
|
||||
savedFlow = {
|
||||
...cloneDeep(flow),
|
||||
path: $pathStore
|
||||
} as Flow
|
||||
try {
|
||||
const flow = cleanInputs($flowStore)
|
||||
// console.log('flow', computeUnlockedSteps(flow)) // del
|
||||
// loadingSave = false // del
|
||||
// return
|
||||
@@ -252,6 +255,10 @@
|
||||
await createSchedule($pathStore)
|
||||
}
|
||||
}
|
||||
savedFlow = {
|
||||
...cloneDeep($flowStore),
|
||||
path: $pathStore
|
||||
} as Flow
|
||||
loadingSave = false
|
||||
dispatch('deploy', $pathStore)
|
||||
} catch (err) {
|
||||
@@ -1059,6 +1066,7 @@
|
||||
size="xs"
|
||||
startIcon={{ icon: faSave }}
|
||||
on:click={() => saveDraft()}
|
||||
disabled={!newFlow && !savedFlow}
|
||||
>
|
||||
Save draft <Kbd small>Ctrl</Kbd><Kbd small>S</Kbd>
|
||||
</Button>
|
||||
|
||||
@@ -222,13 +222,17 @@
|
||||
}
|
||||
|
||||
async function saveDraft(): Promise<void> {
|
||||
if (initialPath != '' && !savedScript) {
|
||||
return
|
||||
}
|
||||
if (savedScript) {
|
||||
const draftOrDeployed = cleanValueProperties(savedScript['draft'] || savedScript)
|
||||
const draftOrDeployed = cleanValueProperties(savedScript.draft || savedScript)
|
||||
const current = cleanValueProperties(script)
|
||||
if (orderedJsonStringify(draftOrDeployed) === orderedJsonStringify(current)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
loadingDraft = true
|
||||
try {
|
||||
localStorage.removeItem(script.path)
|
||||
@@ -274,10 +278,10 @@
|
||||
}
|
||||
})
|
||||
|
||||
savedScript = await ScriptService.getScriptByPathWithDraft({
|
||||
workspace: $workspaceStore!,
|
||||
path: script.path
|
||||
})
|
||||
savedScript = {
|
||||
...(initialPath == '' ? { ...cloneDeep(script), draft_only: true } : savedScript),
|
||||
draft: cloneDeep(script)
|
||||
} as NewScriptWithDraft
|
||||
|
||||
if (initialPath == '') {
|
||||
goto(`/scripts/edit/${script.path}`)
|
||||
@@ -854,6 +858,7 @@
|
||||
size="xs"
|
||||
startIcon={{ icon: faSave }}
|
||||
on:click={() => saveDraft()}
|
||||
disabled={initialPath != '' && !savedScript}
|
||||
>
|
||||
<span class="hidden sm:flex">
|
||||
Save draft <Kbd small isModifier>{getModifierKey()}</Kbd>
|
||||
|
||||
@@ -225,24 +225,11 @@
|
||||
policy
|
||||
}
|
||||
})
|
||||
const app_w_draft = await AppService.getAppByPathWithDraft({
|
||||
workspace: $workspaceStore!,
|
||||
path
|
||||
})
|
||||
savedApp = {
|
||||
summary: app_w_draft.summary,
|
||||
value: app_w_draft.value,
|
||||
path: app_w_draft.path,
|
||||
policy: app_w_draft.policy,
|
||||
draft_only: app_w_draft.draft_only,
|
||||
draft: app_w_draft.draft
|
||||
? {
|
||||
summary: app_w_draft.summary,
|
||||
value: app_w_draft.draft,
|
||||
path: app_w_draft.path,
|
||||
policy: app_w_draft.policy
|
||||
}
|
||||
: undefined
|
||||
summary: $summary,
|
||||
value: $app,
|
||||
path: path,
|
||||
policy: policy
|
||||
}
|
||||
closeSaveDrawer()
|
||||
sendUserToast('App deployed successfully')
|
||||
@@ -265,24 +252,11 @@
|
||||
path: npath
|
||||
}
|
||||
})
|
||||
const app_w_draft = await AppService.getAppByPathWithDraft({
|
||||
workspace: $workspaceStore!,
|
||||
path: npath
|
||||
})
|
||||
savedApp = {
|
||||
summary: app_w_draft.summary,
|
||||
value: app_w_draft.value,
|
||||
path: app_w_draft.path,
|
||||
policy: app_w_draft.policy,
|
||||
draft_only: app_w_draft.draft_only,
|
||||
draft: app_w_draft.draft
|
||||
? {
|
||||
summary: app_w_draft.summary,
|
||||
value: app_w_draft.draft,
|
||||
path: app_w_draft.path,
|
||||
policy: app_w_draft.policy
|
||||
}
|
||||
: undefined
|
||||
summary: $summary,
|
||||
value: $app,
|
||||
path: npath,
|
||||
policy
|
||||
}
|
||||
|
||||
closeSaveDrawer()
|
||||
@@ -327,18 +301,6 @@
|
||||
}
|
||||
|
||||
async function saveInitialDraft() {
|
||||
if (savedApp) {
|
||||
const draftOrDeployed = cleanValueProperties(savedApp.draft || savedApp)
|
||||
const current = cleanValueProperties({
|
||||
summary: $summary,
|
||||
value: $app,
|
||||
path: newPath || savedApp.draft?.path || savedApp.path,
|
||||
policy
|
||||
})
|
||||
if (orderedJsonStringify(draftOrDeployed) === orderedJsonStringify(current)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
await computeTriggerables()
|
||||
try {
|
||||
await AppService.createApp({
|
||||
@@ -359,24 +321,18 @@
|
||||
value: $app!
|
||||
}
|
||||
})
|
||||
const app_w_draft = await AppService.getAppByPathWithDraft({
|
||||
workspace: $workspaceStore!,
|
||||
path: newPath
|
||||
})
|
||||
savedApp = {
|
||||
summary: app_w_draft.summary,
|
||||
value: app_w_draft.value,
|
||||
path: app_w_draft.path,
|
||||
policy: app_w_draft.policy,
|
||||
draft_only: app_w_draft.draft_only,
|
||||
draft: app_w_draft.draft
|
||||
? {
|
||||
summary: app_w_draft.summary,
|
||||
value: app_w_draft.draft,
|
||||
path: app_w_draft.path,
|
||||
policy: app_w_draft.policy
|
||||
}
|
||||
: undefined
|
||||
summary: $summary,
|
||||
value: $app,
|
||||
path: newPath,
|
||||
policy,
|
||||
draft_only: true,
|
||||
draft: {
|
||||
summary: $summary,
|
||||
value: $app,
|
||||
path: newPath,
|
||||
policy
|
||||
}
|
||||
}
|
||||
|
||||
draftDrawerOpen = false
|
||||
@@ -388,22 +344,24 @@
|
||||
}
|
||||
|
||||
async function saveDraft() {
|
||||
if (savedApp) {
|
||||
const draftOrDeployed = cleanValueProperties(savedApp.draft || savedApp)
|
||||
const current = cleanValueProperties({
|
||||
summary: $summary,
|
||||
value: $app,
|
||||
path: newPath || savedApp.draft?.path || savedApp.path,
|
||||
policy
|
||||
})
|
||||
if (orderedJsonStringify(draftOrDeployed) === orderedJsonStringify(current)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if ($page.params.path == undefined) {
|
||||
// initial draft
|
||||
draftDrawerOpen = true
|
||||
return
|
||||
}
|
||||
if (!savedApp) {
|
||||
return
|
||||
}
|
||||
const draftOrDeployed = cleanValueProperties(savedApp.draft || savedApp)
|
||||
const current = cleanValueProperties({
|
||||
summary: $summary,
|
||||
value: $app,
|
||||
path: newPath || savedApp.draft?.path || savedApp.path,
|
||||
policy
|
||||
})
|
||||
if (orderedJsonStringify(draftOrDeployed) === orderedJsonStringify(current)) {
|
||||
return
|
||||
}
|
||||
loading.saveDraft = true
|
||||
try {
|
||||
await computeTriggerables()
|
||||
@@ -416,24 +374,15 @@
|
||||
value: $app!
|
||||
}
|
||||
})
|
||||
const app_w_draft = await AppService.getAppByPathWithDraft({
|
||||
workspace: $workspaceStore!,
|
||||
path
|
||||
})
|
||||
|
||||
savedApp = {
|
||||
summary: app_w_draft.summary,
|
||||
value: app_w_draft.value,
|
||||
path: app_w_draft.path,
|
||||
policy: app_w_draft.policy,
|
||||
draft_only: app_w_draft.draft_only,
|
||||
draft: app_w_draft.draft
|
||||
? {
|
||||
summary: app_w_draft.summary,
|
||||
value: app_w_draft.draft,
|
||||
path: app_w_draft.path,
|
||||
policy: app_w_draft.policy
|
||||
}
|
||||
: undefined
|
||||
...savedApp,
|
||||
draft: {
|
||||
summary: $summary,
|
||||
value: $app,
|
||||
path,
|
||||
policy
|
||||
}
|
||||
}
|
||||
|
||||
sendUserToast('Draft saved')
|
||||
@@ -1170,7 +1119,13 @@
|
||||
</div>
|
||||
<AppExportButton bind:this={appExport} />
|
||||
<PreviewToggle loading={loading.save} />
|
||||
<Button loading={loading.save} startIcon={{ icon: faSave }} on:click={saveDraft} size="xs">
|
||||
<Button
|
||||
loading={loading.save}
|
||||
startIcon={{ icon: faSave }}
|
||||
on:click={saveDraft}
|
||||
disabled={$page.params.path !== undefined && !savedApp}
|
||||
size="xs"
|
||||
>
|
||||
Save draft <Kbd small>Ctrl</Kbd><Kbd small>S</Kbd>
|
||||
</Button>
|
||||
<Button
|
||||
|
||||
@@ -11,6 +11,7 @@ import { deepEqual } from 'fast-equals'
|
||||
import type { UserExt } from './stores'
|
||||
import { sendUserToast } from './toast'
|
||||
import type { Script } from './gen'
|
||||
import { cloneDeep } from 'lodash'
|
||||
export { sendUserToast }
|
||||
|
||||
export function validateUsername(username: string): string {
|
||||
@@ -678,8 +679,8 @@ export function cleanValueProperties(obj: Value) {
|
||||
} else {
|
||||
let newObj: any = {}
|
||||
for (const key of Object.keys(obj)) {
|
||||
if (key !== 'draft' && key !== 'draft_only' && key !== 'parent_hash' && obj[key]) {
|
||||
newObj[key] = obj[key]
|
||||
if (key !== 'parent_hash' && key !== 'draft' && key !== 'draft_only') {
|
||||
newObj[key] = cloneDeep(obj[key])
|
||||
}
|
||||
}
|
||||
return newObj
|
||||
|
||||
Reference in New Issue
Block a user