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,13 +475,13 @@ export default defineComponent({
|
|||
cb(saved);
|
||||
},
|
||||
async handleFileImport(): Promise<void> {
|
||||
const inputRef = this.$refs.importFile as HTMLInputElement | undefined;
|
||||
if (inputRef?.files && inputRef.files.length !== 0) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = (event: ProgressEvent) => {
|
||||
const data = (event.target as FileReader).result;
|
||||
|
||||
reader.onload = () => {
|
||||
let workflowData: IWorkflowDataUpdate;
|
||||
try {
|
||||
workflowData = JSON.parse(data as string);
|
||||
workflowData = JSON.parse(reader.result as string);
|
||||
} catch (error) {
|
||||
this.showMessage({
|
||||
title: this.$locale.baseText('mainSidebar.showMessage.handleFileImport.title'),
|
||||
|
@ -489,13 +489,13 @@ export default defineComponent({
|
|||
type: 'error',
|
||||
});
|
||||
return;
|
||||
} finally {
|
||||
reader.onload = undefined;
|
||||
inputRef.value = null;
|
||||
}
|
||||
|
||||
nodeViewEventBus.emit('importWorkflowData', { data: workflowData });
|
||||
};
|
||||
|
||||
const inputRef = this.$refs.importFile as HTMLInputElement | undefined;
|
||||
if (inputRef?.files && inputRef.files.length !== 0) {
|
||||
reader.readAsText(inputRef.files[0]);
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue