Skip to content

Commit

Permalink
fix(editor): Allow importing the same workflow multiple times (#7458)
Browse files Browse the repository at this point in the history
Fixes #7457
  • Loading branch information
netroy committed Oct 23, 2023
1 parent cb3c62e commit 15e1737
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions packages/editor-ui/src/components/MainHeader/WorkflowDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -475,27 +475,27 @@ export default defineComponent({
cb(saved);
},
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;
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]);
}
},
Expand Down

0 comments on commit 15e1737

Please sign in to comment.