mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 20:54:07 -08:00
Co-authored-by: Omar Ajoue <krynble@gmail.com>
This commit is contained in:
parent
dc93694a1a
commit
72ac20b070
|
@ -398,7 +398,7 @@ export default mixins(
|
|||
return;
|
||||
}
|
||||
|
||||
this.$store.commit('setWorkflowName', {newName: workflowName, setStateDirty: true});
|
||||
this.$store.commit('setWorkflowName', {newName: workflowName, setStateDirty: false});
|
||||
|
||||
this.$showMessage({
|
||||
title: 'Workflow renamed',
|
||||
|
@ -452,6 +452,7 @@ export default mixins(
|
|||
if(result) {
|
||||
const importConfirm = await this.confirmMessage(`When you switch workflows your current workflow changes will be lost.`, 'Save your Changes?', 'warning', 'Yes, switch workflows and forget changes');
|
||||
if (importConfirm === true) {
|
||||
this.$store.commit('setStateDirty', false);
|
||||
this.$router.push({ name: 'NodeViewNew' });
|
||||
|
||||
this.$showMessage({
|
||||
|
|
|
@ -92,12 +92,28 @@ export default mixins(
|
|||
},
|
||||
async openWorkflow (data: IWorkflowShortResponse, column: any) { // tslint:disable-line:no-any
|
||||
if (column.label !== 'Active') {
|
||||
|
||||
const currentWorkflowId = this.$store.getters.workflowId;
|
||||
|
||||
if (data.id === currentWorkflowId) {
|
||||
this.$showMessage({
|
||||
title: 'Already open',
|
||||
message: 'This is the current workflow',
|
||||
type: 'error',
|
||||
duration: 800,
|
||||
});
|
||||
// Do nothing if current workflow is the one user chose to open
|
||||
return;
|
||||
}
|
||||
|
||||
const result = this.$store.getters.getStateIsDirty;
|
||||
if(result) {
|
||||
const importConfirm = await this.confirmMessage(`When you switch workflows your current workflow changes will be lost.`, 'Save your Changes?', 'warning', 'Yes, switch workflows and forget changes');
|
||||
if (importConfirm === false) {
|
||||
return;
|
||||
} else {
|
||||
// This is used to avoid duplicating the message
|
||||
this.$store.commit('setStateDirty', false);
|
||||
this.$emit('openWorkflow', data.id);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -80,6 +80,8 @@ export const workflowSave = mixins(
|
|||
// Workflow exists already so update it
|
||||
await this.restApi().updateWorkflow(currentWorkflow, workflowData);
|
||||
}
|
||||
// Set dirty = false before pushing route so unsaved changes message doesnt trigger.
|
||||
this.$store.commit('setStateDirty', false);
|
||||
|
||||
if (this.$route.params.name !== workflowData.id) {
|
||||
this.$router.push({
|
||||
|
@ -89,7 +91,6 @@ export const workflowSave = mixins(
|
|||
}
|
||||
|
||||
this.$store.commit('removeActiveAction', 'workflowSaving');
|
||||
this.$store.commit('setStateDirty', false);
|
||||
this.$showMessage({
|
||||
title: 'Workflow saved',
|
||||
message: `The workflow "${workflowData.name}" got saved!`,
|
||||
|
|
|
@ -214,6 +214,21 @@ export default mixins(
|
|||
deep: true,
|
||||
},
|
||||
},
|
||||
async beforeRouteLeave(to, from, next) {
|
||||
const result = this.$store.getters.getStateIsDirty;
|
||||
if(result) {
|
||||
const importConfirm = await this.confirmMessage(`When you switch workflows your current workflow changes will be lost.`, 'Save your Changes?', 'warning', 'Yes, switch workflows and forget changes');
|
||||
if (importConfirm === false) {
|
||||
next(false);
|
||||
} else {
|
||||
// Prevent other popups from displaying
|
||||
this.$store.commit('setStateDirty', false);
|
||||
next();
|
||||
}
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
activeNode (): INodeUi | null {
|
||||
return this.$store.getters.activeNode;
|
||||
|
@ -358,6 +373,8 @@ export default mixins(
|
|||
|
||||
await this.addNodes(data.nodes, data.connections);
|
||||
|
||||
this.$store.commit('setStateDirty', false);
|
||||
|
||||
return data;
|
||||
},
|
||||
touchTap (e: MouseEvent | TouchEvent) {
|
||||
|
@ -1339,6 +1356,8 @@ export default mixins(
|
|||
];
|
||||
|
||||
await this.addNodes(defaultNodes);
|
||||
this.$store.commit('setStateDirty', false);
|
||||
|
||||
},
|
||||
async initView (): Promise<void> {
|
||||
if (this.$route.params.action === 'workflowSave') {
|
||||
|
@ -1351,9 +1370,17 @@ export default mixins(
|
|||
if (this.$route.name === 'ExecutionById') {
|
||||
// Load an execution
|
||||
const executionId = this.$route.params.id;
|
||||
|
||||
await this.openExecution(executionId);
|
||||
} else {
|
||||
|
||||
const result = this.$store.getters.getStateIsDirty;
|
||||
if(result) {
|
||||
const importConfirm = await this.confirmMessage(`When you switch workflows your current workflow changes will be lost.`, 'Save your Changes?', 'warning', 'Yes, switch workflows and forget changes');
|
||||
if (importConfirm === false) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
// Load a workflow
|
||||
let workflowId = null as string | null;
|
||||
if (this.$route.params.name) {
|
||||
|
|
Loading…
Reference in a new issue