mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 19:11:13 +00:00
feat: Add duplicate workflow error handler (#4616)
* feat: Add duplicate workflow error handler * refactor: Change translation string for existing duplicate workflow error
This commit is contained in:
@@ -110,8 +110,8 @@ export default mixins(showMessage, workflowHelpers, restApi).extend({
|
||||
const name = this.name.trim();
|
||||
if (!name) {
|
||||
this.$showMessage({
|
||||
title: this.$locale.baseText('duplicateWorkflowDialog.showMessage.title'),
|
||||
message: this.$locale.baseText('duplicateWorkflowDialog.showMessage.message'),
|
||||
title: this.$locale.baseText('duplicateWorkflowDialog.errors.missingName.title'),
|
||||
message: this.$locale.baseText('duplicateWorkflowDialog.errors.missingName.message'),
|
||||
type: "error",
|
||||
});
|
||||
|
||||
@@ -122,30 +122,46 @@ export default mixins(showMessage, workflowHelpers, restApi).extend({
|
||||
|
||||
this.isSaving = true;
|
||||
|
||||
let workflowToUpdate: IWorkflowDataUpdate | undefined;
|
||||
if (currentWorkflowId !== PLACEHOLDER_EMPTY_WORKFLOW_ID) {
|
||||
const { createdAt, updatedAt, ...workflow } = await this.restApi().getWorkflow(this.data.id);
|
||||
workflowToUpdate = workflow;
|
||||
}
|
||||
try {
|
||||
let workflowToUpdate: IWorkflowDataUpdate | undefined;
|
||||
if (currentWorkflowId !== PLACEHOLDER_EMPTY_WORKFLOW_ID) {
|
||||
const { createdAt, updatedAt, ...workflow } = await this.restApi().getWorkflow(this.data.id);
|
||||
workflowToUpdate = workflow;
|
||||
}
|
||||
|
||||
const saved = await this.saveAsNewWorkflow({
|
||||
name,
|
||||
data: workflowToUpdate,
|
||||
tags: this.currentTagIds,
|
||||
resetWebhookUrls: true,
|
||||
openInNewWindow: true,
|
||||
resetNodeIds: true,
|
||||
});
|
||||
|
||||
if (saved) {
|
||||
this.closeDialog();
|
||||
this.$telemetry.track('User duplicated workflow', {
|
||||
old_workflow_id: currentWorkflowId,
|
||||
workflow_id: this.data.id,
|
||||
const saved = await this.saveAsNewWorkflow({
|
||||
name,
|
||||
data: workflowToUpdate,
|
||||
tags: this.currentTagIds,
|
||||
resetWebhookUrls: true,
|
||||
openInNewWindow: true,
|
||||
resetNodeIds: true,
|
||||
});
|
||||
}
|
||||
|
||||
this.isSaving = false;
|
||||
if (saved) {
|
||||
this.closeDialog();
|
||||
this.$telemetry.track('User duplicated workflow', {
|
||||
old_workflow_id: currentWorkflowId,
|
||||
workflow_id: this.data.id,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.httpStatusCode === 403) {
|
||||
error.message = this.$locale.baseText('duplicateWorkflowDialog.errors.forbidden.message');
|
||||
|
||||
this.$showError(
|
||||
error,
|
||||
this.$locale.baseText('duplicateWorkflowDialog.errors.forbidden.title'),
|
||||
);
|
||||
} else {
|
||||
this.$showError(
|
||||
error,
|
||||
this.$locale.baseText('duplicateWorkflowDialog.errors.generic.title'),
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
this.isSaving = false;
|
||||
}
|
||||
},
|
||||
closeDialog(): void {
|
||||
this.modalBus.$emit("close");
|
||||
|
||||
Reference in New Issue
Block a user