mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(core): reimplement blocking workflow updates on interim changes (#4446)
* 📘 Update request type * 📘 Update FE types * ⚡ Adjust store * ⚡ Set received hash * ⚡ Send and load hash * ⚡ Make helper more flexible * 🗃️ Add new field to entity * 🚨 Add check to endpoint * 🧪 Add tests * ⚡ Add `forceSave` flag * 🐛 Fix workflow update failing on new workflow * 🧪 Add more tests * ⚡ Move check to `updateWorkflow()` * ⚡ Refactor to accommodate latest changes * 🧪 Refactor tests to keep them passing * ⚡ Improve syntax
This commit is contained in:
@@ -400,6 +400,7 @@ export const workflowHelpers = mixins(
|
||||
active: this.$store.getters.isActive,
|
||||
settings: this.$store.getters.workflowSettings,
|
||||
tags: this.$store.getters.workflowTags,
|
||||
hash: this.$store.getters.workflowHash,
|
||||
};
|
||||
|
||||
const workflowId = this.$store.getters.workflowId;
|
||||
@@ -660,6 +661,9 @@ export const workflowHelpers = mixins(
|
||||
const isCurrentWorkflow = workflowId === this.$store.getters.workflowId;
|
||||
if (isCurrentWorkflow) {
|
||||
data = await this.getWorkflowDataToSave();
|
||||
} else {
|
||||
const { hash } = await this.restApi().getWorkflow(workflowId);
|
||||
data.hash = hash as string;
|
||||
}
|
||||
|
||||
if (active !== undefined) {
|
||||
@@ -667,6 +671,7 @@ export const workflowHelpers = mixins(
|
||||
}
|
||||
|
||||
const workflow = await this.restApi().updateWorkflow(workflowId, data);
|
||||
this.$store.commit('setWorkflowHash', workflow.hash);
|
||||
|
||||
if (isCurrentWorkflow) {
|
||||
this.$store.commit('setActive', !!workflow.active);
|
||||
@@ -701,7 +706,10 @@ export const workflowHelpers = mixins(
|
||||
workflowDataRequest.tags = tags;
|
||||
}
|
||||
|
||||
workflowDataRequest.hash = this.$store.getters.workflowHash;
|
||||
|
||||
const workflowData = await this.restApi().updateWorkflow(currentWorkflow, workflowDataRequest);
|
||||
this.$store.commit('setWorkflowHash', workflowData.hash);
|
||||
|
||||
if (name) {
|
||||
this.$store.commit('setWorkflowName', {newName: workflowData.name});
|
||||
@@ -768,6 +776,7 @@ export const workflowHelpers = mixins(
|
||||
const workflowData = await this.restApi().createNewWorkflow(workflowDataRequest);
|
||||
|
||||
this.$store.commit('addWorkflow', workflowData);
|
||||
this.$store.commit('setWorkflowHash', workflowData.hash);
|
||||
|
||||
if (openInNewWindow) {
|
||||
const routeData = this.$router.resolve({name: VIEWS.WORKFLOW, params: {name: workflowData.id}});
|
||||
|
||||
Reference in New Issue
Block a user