From e018739ba9eaa9bff325a81e57e43d16cd0e00e4 Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Wed, 26 Oct 2016 18:42:52 +0200 Subject: [PATCH] Removed unused Format => Use JSON for Export --- js/src/ui/Actionbar/Export/export.js | 35 ++++------------------------ 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/js/src/ui/Actionbar/Export/export.js b/js/src/ui/Actionbar/Export/export.js index 21aaf2a43..7f0ea3e15 100644 --- a/js/src/ui/Actionbar/Export/export.js +++ b/js/src/ui/Actionbar/Export/export.js @@ -44,40 +44,13 @@ class ActionbarExport extends Component { ); } - onDownloadBackup = (filetype) => { + handleExport = () => { const { filename, content } = this.props; - const text = this.contentAsString(content, filetype); - const extension = this.getExtension(filetype); + const text = JSON.stringify(content, null, 4); - const blob = new Blob([ text ], { type: 'text/plain;charset=utf-8' }); - FileSaver.saveAs(blob, `${filename}.${extension}`); - } - - getExtension = (filetype) => { - switch (filetype) { - case 'json': - return filetype; - default: - return 'txt'; - } - } - - contentAsString = (data, filetype) => { - if (typeof data === 'string') { - return data; - } - - switch (filetype) { - case 'json': - return JSON.stringify(data, null, 4); - default: - return data.toString(); - } - } - - handleExport = () => { - this.onDownloadBackup('json'); + const blob = new Blob([ text ], { type: 'application/json' }); + FileSaver.saveAs(blob, `${filename}.json`); } }