mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
Reroute to current workflow and add safeguard
This commit is contained in:
parent
be441fb91f
commit
7695162ffa
|
@ -1,6 +1,7 @@
|
|||
import {
|
||||
HTTP_REQUEST_NODE_TYPE,
|
||||
MODAL_CANCEL,
|
||||
MODAL_CLOSE,
|
||||
MODAL_CONFIRM,
|
||||
PLACEHOLDER_EMPTY_WORKFLOW_ID,
|
||||
PLACEHOLDER_FILLED_AT_EXECUTION_TIME,
|
||||
|
@ -827,6 +828,12 @@ export function useWorkflowHelpers(options: { router: ReturnType<typeof useRoute
|
|||
|
||||
const workflowDataRequest: IWorkflowDataUpdate = await getWorkflowDataToSave();
|
||||
|
||||
// This can happen if the user has another workflow in the browser history and navigates
|
||||
// via the browser back button, encountering our warning dialog with the new route already set
|
||||
if (workflowDataRequest.id !== currentWorkflow) {
|
||||
throw new Error('Attempted to save a workflow different from the current workflow');
|
||||
}
|
||||
|
||||
if (name) {
|
||||
workflowDataRequest.name = name.trim();
|
||||
}
|
||||
|
@ -1139,18 +1146,24 @@ export function useWorkflowHelpers(options: { router: ReturnType<typeof useRoute
|
|||
const saved = await saveCurrentWorkflow({}, false);
|
||||
if (saved) {
|
||||
await npsSurveyStore.fetchPromptsData();
|
||||
}
|
||||
uiStore.stateIsDirty = false;
|
||||
|
||||
const goToNext = await confirm();
|
||||
if (goToNext) {
|
||||
next();
|
||||
uiStore.stateIsDirty = false;
|
||||
const goToNext = await confirm();
|
||||
if (goToNext) {
|
||||
next();
|
||||
}
|
||||
} else {
|
||||
router.resolve({ name: VIEWS.WORKFLOW, params: { name: workflowsStore.workflow.id } });
|
||||
next(false);
|
||||
}
|
||||
} else if (confirmModal === MODAL_CANCEL) {
|
||||
await cancel();
|
||||
|
||||
uiStore.stateIsDirty = false;
|
||||
next();
|
||||
} else if (confirmModal === MODAL_CLOSE) {
|
||||
// The route may have already changed due to the browser back button, so let's restore it
|
||||
router.resolve({ name: VIEWS.WORKFLOW, params: { name: workflowsStore.workflow.id } });
|
||||
next(false);
|
||||
}
|
||||
} else {
|
||||
next();
|
||||
|
|
Loading…
Reference in a new issue