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 {
|
import {
|
||||||
HTTP_REQUEST_NODE_TYPE,
|
HTTP_REQUEST_NODE_TYPE,
|
||||||
MODAL_CANCEL,
|
MODAL_CANCEL,
|
||||||
|
MODAL_CLOSE,
|
||||||
MODAL_CONFIRM,
|
MODAL_CONFIRM,
|
||||||
PLACEHOLDER_EMPTY_WORKFLOW_ID,
|
PLACEHOLDER_EMPTY_WORKFLOW_ID,
|
||||||
PLACEHOLDER_FILLED_AT_EXECUTION_TIME,
|
PLACEHOLDER_FILLED_AT_EXECUTION_TIME,
|
||||||
|
@ -827,6 +828,12 @@ export function useWorkflowHelpers(options: { router: ReturnType<typeof useRoute
|
||||||
|
|
||||||
const workflowDataRequest: IWorkflowDataUpdate = await getWorkflowDataToSave();
|
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) {
|
if (name) {
|
||||||
workflowDataRequest.name = name.trim();
|
workflowDataRequest.name = name.trim();
|
||||||
}
|
}
|
||||||
|
@ -1139,18 +1146,24 @@ export function useWorkflowHelpers(options: { router: ReturnType<typeof useRoute
|
||||||
const saved = await saveCurrentWorkflow({}, false);
|
const saved = await saveCurrentWorkflow({}, false);
|
||||||
if (saved) {
|
if (saved) {
|
||||||
await npsSurveyStore.fetchPromptsData();
|
await npsSurveyStore.fetchPromptsData();
|
||||||
}
|
uiStore.stateIsDirty = false;
|
||||||
uiStore.stateIsDirty = false;
|
const goToNext = await confirm();
|
||||||
|
if (goToNext) {
|
||||||
const goToNext = await confirm();
|
next();
|
||||||
if (goToNext) {
|
}
|
||||||
next();
|
} else {
|
||||||
|
router.resolve({ name: VIEWS.WORKFLOW, params: { name: workflowsStore.workflow.id } });
|
||||||
|
next(false);
|
||||||
}
|
}
|
||||||
} else if (confirmModal === MODAL_CANCEL) {
|
} else if (confirmModal === MODAL_CANCEL) {
|
||||||
await cancel();
|
await cancel();
|
||||||
|
|
||||||
uiStore.stateIsDirty = false;
|
uiStore.stateIsDirty = false;
|
||||||
next();
|
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 {
|
} else {
|
||||||
next();
|
next();
|
||||||
|
|
Loading…
Reference in a new issue