Skip to content

Commit

Permalink
fix: Export Report from File menu no longer crashes
Browse files Browse the repository at this point in the history
Pop up the file dialog before dispatching the action.

Fixes #26
  • Loading branch information
marisademeglio authored and rdeltour committed Dec 23, 2018
1 parent 002b927 commit e0d1463
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default class MenuBuilder {
label: 'Export Report',
id: 'exportReport',
accelerator: 'CmdOrCtrl+Shift+E',
click: () => this.store.dispatch(exportReport())
click: () => FileDialogHelpers.showExportReportDialog(filepath => this.store.dispatch(exportReport(filepath)))
},
{
type: 'separator'
Expand Down
6 changes: 3 additions & 3 deletions src/shared/actions/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function runAce(inputPath) {
dispatch(setProcessing(PROCESSING_TYPE.ACE, true));
dispatch(addMessage(`Running Ace on ${inputPath}`));
let outdir = prepareOutdir(inputPath, getState().preferences);

if (outdir.success) {
ace(inputPath, {outdir: outdir.value})
.then(() => {
Expand Down Expand Up @@ -106,7 +106,7 @@ export function exportReport(outfile) {
dispatch(addMessage(`Saving report to ${outfile}…`));
zip(path.dirname(reportPath), outfile)
.then(() => {
dispatch(addMessage(`Saved report to ${outfile}…`))
dispatch(addMessage(`Saved report to ${outfile}…`));
dispatch(setProcessing(PROCESSING_TYPE.EXPORT, false));
})
.catch(error => {
Expand Down Expand Up @@ -140,4 +140,4 @@ function prepareOutdir(filepath, prefs) {
}
}
return {success: true, value: outdir};
}
}
5 changes: 2 additions & 3 deletions src/shared/helpers/zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import path from 'path';
import readdir from '@mrmlnc/readdir-enhanced';
import fs from 'fs';
import JSZip from 'jszip';

export default function zip(dir, output) {

return new Promise((resolve, reject) => {
var archive = new JSZip();
readdir.stream(dir, {deep: true})
Expand All @@ -21,4 +20,4 @@ export default function zip(dir, output) {
.on('finish', resolve);
});
});
}
}

0 comments on commit e0d1463

Please sign in to comment.