mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
fix(editor): Allow importing the same workflow multiple times (#7458)
Fixes #7457
This commit is contained in:
parent
ac814a9c61
commit
3c0a166f7f
|
@ -475,27 +475,27 @@ export default defineComponent({
|
||||||
cb(saved);
|
cb(saved);
|
||||||
},
|
},
|
||||||
async handleFileImport(): Promise<void> {
|
async handleFileImport(): Promise<void> {
|
||||||
const reader = new FileReader();
|
|
||||||
reader.onload = (event: ProgressEvent) => {
|
|
||||||
const data = (event.target as FileReader).result;
|
|
||||||
|
|
||||||
let workflowData: IWorkflowDataUpdate;
|
|
||||||
try {
|
|
||||||
workflowData = JSON.parse(data as string);
|
|
||||||
} catch (error) {
|
|
||||||
this.showMessage({
|
|
||||||
title: this.$locale.baseText('mainSidebar.showMessage.handleFileImport.title'),
|
|
||||||
message: this.$locale.baseText('mainSidebar.showMessage.handleFileImport.message'),
|
|
||||||
type: 'error',
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
nodeViewEventBus.emit('importWorkflowData', { data: workflowData });
|
|
||||||
};
|
|
||||||
|
|
||||||
const inputRef = this.$refs.importFile as HTMLInputElement | undefined;
|
const inputRef = this.$refs.importFile as HTMLInputElement | undefined;
|
||||||
if (inputRef?.files && inputRef.files.length !== 0) {
|
if (inputRef?.files && inputRef.files.length !== 0) {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = () => {
|
||||||
|
let workflowData: IWorkflowDataUpdate;
|
||||||
|
try {
|
||||||
|
workflowData = JSON.parse(reader.result as string);
|
||||||
|
} catch (error) {
|
||||||
|
this.showMessage({
|
||||||
|
title: this.$locale.baseText('mainSidebar.showMessage.handleFileImport.title'),
|
||||||
|
message: this.$locale.baseText('mainSidebar.showMessage.handleFileImport.message'),
|
||||||
|
type: 'error',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
} finally {
|
||||||
|
reader.onload = undefined;
|
||||||
|
inputRef.value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
nodeViewEventBus.emit('importWorkflowData', { data: workflowData });
|
||||||
|
};
|
||||||
reader.readAsText(inputRef.files[0]);
|
reader.readAsText(inputRef.files[0]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue