Removed unused Format => Use JSON for Export

This commit is contained in:
Nicolas Gotchac 2016-10-26 18:42:52 +02:00
parent 1b0a87cdde
commit e018739ba9

View File

@ -44,40 +44,13 @@ class ActionbarExport extends Component {
); );
} }
onDownloadBackup = (filetype) => { handleExport = () => {
const { filename, content } = this.props; const { filename, content } = this.props;
const text = this.contentAsString(content, filetype); const text = JSON.stringify(content, null, 4);
const extension = this.getExtension(filetype);
const blob = new Blob([ text ], { type: 'text/plain;charset=utf-8' }); const blob = new Blob([ text ], { type: 'application/json' });
FileSaver.saveAs(blob, `${filename}.${extension}`); FileSaver.saveAs(blob, `${filename}.json`);
}
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');
} }
} }