feat: Add prompt to overwrite changes when concurrent editing occurs (#4817)

* feat: Add prompt to overwrite changes when concurrent editing occurs

* chore: undo config schema update
This commit is contained in:
Alex Grozav
2022-12-05 14:34:14 +02:00
committed by GitHub
parent 46c75b9fd2
commit af6ac42aa3
4 changed files with 25 additions and 5 deletions

View File

@@ -703,7 +703,7 @@ export const workflowHelpers = mixins(
}
},
async saveCurrentWorkflow({id, name, tags}: {id?: string, name?: string, tags?: string[]} = {}, redirect = true): Promise<boolean> {
async saveCurrentWorkflow({id, name, tags}: {id?: string, name?: string, tags?: string[]} = {}, redirect = true, forceSave = false): Promise<boolean> {
const currentWorkflow = id || this.$route.params.name;
if (!currentWorkflow || ['new', PLACEHOLDER_EMPTY_WORKFLOW_ID].includes(currentWorkflow)) {
@@ -726,7 +726,7 @@ export const workflowHelpers = mixins(
workflowDataRequest.hash = this.workflowsStore.workflowHash;
const workflowData = await this.restApi().updateWorkflow(currentWorkflow, workflowDataRequest);
const workflowData = await this.restApi().updateWorkflow(currentWorkflow, workflowDataRequest, forceSave);
this.workflowsStore.setWorkflowHash(workflowData.hash);
if (name) {
@@ -747,6 +747,22 @@ export const workflowHelpers = mixins(
} catch (error) {
this.uiStore.removeActiveAction('workflowSaving');
if (error.errorCode === 400 && error.message.startsWith('Your most recent changes may be lost')) {
const overwrite = await this.confirmMessage(
this.$locale.baseText('workflows.concurrentChanges.confirmMessage.message'),
this.$locale.baseText('workflows.concurrentChanges.confirmMessage.title'),
null,
this.$locale.baseText('workflows.concurrentChanges.confirmMessage.confirmButtonText'),
this.$locale.baseText('workflows.concurrentChanges.confirmMessage.cancelButtonText'),
);
if (overwrite) {
return this.saveCurrentWorkflow({id, name, tags}, redirect, true);
}
return false;
}
this.$showMessage({
title: this.$locale.baseText('workflowHelpers.showMessage.title'),
message: error.message,