mirror of
https://github.com/n8n-io/n8n.git
synced 2026-09-01 15:47:41 +08:00
fix(editor): Show conflicts modal for autosave (no-changelog) (#25458)
This commit is contained in:
@@ -263,6 +263,53 @@ export function useWorkflowSaving({
|
||||
|
||||
uiStore.removeActiveAction('workflowSaving');
|
||||
|
||||
if (error.errorCode === 100) {
|
||||
telemetry.track('User attempted to save locked workflow', {
|
||||
workflowId: currentWorkflow,
|
||||
sharing_role: getWorkflowProjectRole(currentWorkflow),
|
||||
});
|
||||
|
||||
// Hide modal if we already showed it
|
||||
// So that user could explore the workflow
|
||||
if (!autosaveStore.conflictModalShown) {
|
||||
if (autosaved) {
|
||||
autosaveStore.setConflictModalShown(true);
|
||||
}
|
||||
|
||||
const url = router.resolve({
|
||||
name: VIEWS.WORKFLOW,
|
||||
params: { name: currentWorkflow },
|
||||
}).href;
|
||||
|
||||
const overwrite = await message.confirm(
|
||||
i18n.baseText('workflows.concurrentChanges.confirmMessage.message', {
|
||||
interpolate: {
|
||||
url,
|
||||
},
|
||||
}),
|
||||
i18n.baseText('workflows.concurrentChanges.confirmMessage.title'),
|
||||
{
|
||||
confirmButtonText: i18n.baseText(
|
||||
'workflows.concurrentChanges.confirmMessage.confirmButtonText',
|
||||
),
|
||||
cancelButtonText: i18n.baseText(
|
||||
'workflows.concurrentChanges.confirmMessage.cancelButtonText',
|
||||
),
|
||||
},
|
||||
);
|
||||
|
||||
if (overwrite === MODAL_CONFIRM) {
|
||||
return await saveCurrentWorkflow({ id, name, tags }, redirect, true);
|
||||
}
|
||||
}
|
||||
|
||||
// For autosaves, fall through to retry logic below
|
||||
// As we want to still communicate autosave stopped working
|
||||
if (!autosaved) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle autosave failures with exponential backoff
|
||||
if (autosaved) {
|
||||
autosaveStore.incrementRetry();
|
||||
@@ -295,41 +342,6 @@ export function useWorkflowSaving({
|
||||
return false;
|
||||
}
|
||||
|
||||
if (error.errorCode === 100) {
|
||||
telemetry.track('User attempted to save locked workflow', {
|
||||
workflowId: currentWorkflow,
|
||||
sharing_role: getWorkflowProjectRole(currentWorkflow),
|
||||
});
|
||||
|
||||
const url = router.resolve({
|
||||
name: VIEWS.WORKFLOW,
|
||||
params: { name: currentWorkflow },
|
||||
}).href;
|
||||
|
||||
const overwrite = await message.confirm(
|
||||
i18n.baseText('workflows.concurrentChanges.confirmMessage.message', {
|
||||
interpolate: {
|
||||
url,
|
||||
},
|
||||
}),
|
||||
i18n.baseText('workflows.concurrentChanges.confirmMessage.title'),
|
||||
{
|
||||
confirmButtonText: i18n.baseText(
|
||||
'workflows.concurrentChanges.confirmMessage.confirmButtonText',
|
||||
),
|
||||
cancelButtonText: i18n.baseText(
|
||||
'workflows.concurrentChanges.confirmMessage.cancelButtonText',
|
||||
),
|
||||
},
|
||||
);
|
||||
|
||||
if (overwrite === MODAL_CONFIRM) {
|
||||
return await saveCurrentWorkflow({ id, name, tags }, redirect, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
toast.showMessage({
|
||||
title: i18n.baseText('workflowHelpers.showMessage.title'),
|
||||
message: error.message,
|
||||
|
||||
@@ -16,6 +16,7 @@ export const useWorkflowAutosaveStore = defineStore('workflowAutosave', () => {
|
||||
const retryDelay = ref(RETRY_START_DELAY);
|
||||
const isRetrying = ref(false);
|
||||
const lastError = ref<string | null>(null);
|
||||
const conflictModalShown = ref(false);
|
||||
|
||||
function setAutoSaveState(state: AutoSaveState) {
|
||||
autoSaveState.value = state;
|
||||
@@ -42,11 +43,16 @@ export const useWorkflowAutosaveStore = defineStore('workflowAutosave', () => {
|
||||
lastError.value = error;
|
||||
}
|
||||
|
||||
function setConflictModalShown(value: boolean) {
|
||||
conflictModalShown.value = value;
|
||||
}
|
||||
|
||||
function resetRetry() {
|
||||
retryCount.value = 0;
|
||||
retryDelay.value = RETRY_START_DELAY;
|
||||
isRetrying.value = false;
|
||||
lastError.value = null;
|
||||
conflictModalShown.value = false;
|
||||
}
|
||||
|
||||
function reset() {
|
||||
@@ -62,12 +68,14 @@ export const useWorkflowAutosaveStore = defineStore('workflowAutosave', () => {
|
||||
retryDelay,
|
||||
isRetrying,
|
||||
lastError,
|
||||
conflictModalShown,
|
||||
setAutoSaveState,
|
||||
setPendingAutoSave,
|
||||
incrementRetry,
|
||||
getRetryDelay,
|
||||
setRetrying,
|
||||
setLastError,
|
||||
setConflictModalShown,
|
||||
resetRetry,
|
||||
reset,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user