mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 11:22:15 +00:00
feat(core): block workflow update on interim change (#4374)
* ⚡ Add `updatedAt` to store * ⚡ Set `updatedAt` in store * 👕 Update FE types * 👕 Update BE types * ⚡ Set `updatedAt` on workflow open * ⚡ Add endpoint check * ⚡ Add first update check * 🔥 Remove log * ⚡ Simplify check * ⚡ Make `makeWorkflow` more flexible * 🗃️ Make `updatedAt` default consistent * 🧪 Adjust tests checking for `updatedAt` * 🧪 Add tests for interim changes block * ✏️ Remove unneeded quotes * ⏪ Simplify without using `-1` * 👕 Simplify interfaces
This commit is contained in:
@@ -241,6 +241,7 @@ export interface IWorkflowData {
|
||||
settings?: IWorkflowSettings;
|
||||
tags?: string[];
|
||||
pinData?: IPinData;
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
export interface IWorkflowDataUpdate {
|
||||
@@ -252,6 +253,7 @@ export interface IWorkflowDataUpdate {
|
||||
active?: boolean;
|
||||
tags?: ITag[] | string[]; // string[] when store or requested, ITag[] from API response
|
||||
pinData?: IPinData;
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
export interface IWorkflowToShare extends IWorkflowDataUpdate {
|
||||
|
||||
@@ -400,6 +400,7 @@ export const workflowHelpers = mixins(
|
||||
active: this.$store.getters.isActive,
|
||||
settings: this.$store.getters.workflowSettings,
|
||||
tags: this.$store.getters.workflowTags,
|
||||
updatedAt: this.$store.getters.workflowUpdatedAt,
|
||||
};
|
||||
|
||||
const workflowId = this.$store.getters.workflowId;
|
||||
@@ -678,6 +679,8 @@ export const workflowHelpers = mixins(
|
||||
} else {
|
||||
this.$store.commit('setWorkflowInactive', workflowId);
|
||||
}
|
||||
|
||||
this.$store.commit('setWorkflowUpdatedAt', data.updatedAt);
|
||||
},
|
||||
|
||||
async saveCurrentWorkflow({name, tags}: {name?: string, tags?: string[]} = {}, redirect = true): Promise<boolean> {
|
||||
@@ -714,6 +717,7 @@ export const workflowHelpers = mixins(
|
||||
|
||||
this.$store.commit('setStateDirty', false);
|
||||
this.$store.commit('removeActiveAction', 'workflowSaving');
|
||||
this.$store.commit('setWorkflowUpdatedAt', workflowData.updatedAt);
|
||||
this.$externalHooks().run('workflow.afterUpdate', { workflowData });
|
||||
|
||||
return true;
|
||||
|
||||
@@ -464,6 +464,11 @@ export const store = new Vuex.Store({
|
||||
state.workflow.id = id;
|
||||
},
|
||||
|
||||
// updatedAt
|
||||
setWorkflowUpdatedAt (state, updatedAt: string) {
|
||||
state.workflow.updatedAt = updatedAt;
|
||||
},
|
||||
|
||||
// Name
|
||||
setWorkflowName(state, data) {
|
||||
if (data.setStateDirty === true) {
|
||||
@@ -1009,6 +1014,9 @@ export const store = new Vuex.Store({
|
||||
workflowId: (state): string => {
|
||||
return state.workflow.id;
|
||||
},
|
||||
workflowUpdatedAt (state): string | number {
|
||||
return state.workflow.updatedAt;
|
||||
},
|
||||
|
||||
workflowSettings: (state): IWorkflowSettings => {
|
||||
if (state.workflow.settings === undefined) {
|
||||
|
||||
@@ -735,6 +735,7 @@ export default mixins(
|
||||
|
||||
this.$store.commit('setActive', data.active || false);
|
||||
this.$store.commit('setWorkflowId', workflowId);
|
||||
this.$store.commit('setWorkflowUpdatedAt', data.updatedAt);
|
||||
this.$store.commit('setWorkflowName', { newName: data.name, setStateDirty: false });
|
||||
this.$store.commit('setWorkflowSettings', data.settings || {});
|
||||
this.$store.commit('setWorkflowPinData', data.pinData || {});
|
||||
|
||||
Reference in New Issue
Block a user