Removed CSV Export option (#2147)

This commit is contained in:
Nicolas Gotchac 2016-10-26 11:59:25 +02:00
parent 61f41cdbe2
commit 1b0a87cdde
2 changed files with 8 additions and 46 deletions

View File

@ -115,7 +115,6 @@
"geopattern": "^1.2.3", "geopattern": "^1.2.3",
"isomorphic-fetch": "^2.2.1", "isomorphic-fetch": "^2.2.1",
"js-sha3": "^0.5.2", "js-sha3": "^0.5.2",
"json2csv": "^3.7.1",
"lodash": "^4.11.1", "lodash": "^4.11.1",
"marked": "^0.3.6", "marked": "^0.3.6",
"material-ui": "^0.16.1", "material-ui": "^0.16.1",

View File

@ -15,11 +15,8 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
import React, { Component, PropTypes } from 'react'; import React, { Component, PropTypes } from 'react';
import IconMenu from 'material-ui/IconMenu';
import MenuItem from 'material-ui/MenuItem';
import FileSaver from 'file-saver'; import FileSaver from 'file-saver';
import json2csv from 'json2csv';
import FileDownloadIcon from 'material-ui/svg-icons/file/file-download'; import FileDownloadIcon from 'material-ui/svg-icons/file/file-download';
import { Button } from '../../'; import { Button } from '../../';
@ -34,32 +31,16 @@ class ActionbarExport extends Component {
className: PropTypes.string className: PropTypes.string
} }
state = {
menuOpen: false
}
render () { render () {
const { className } = this.props; const { className } = this.props;
return ( return (
<IconMenu <Button
iconButtonElement={ className={ className }
<Button icon={ <FileDownloadIcon /> }
className={ className } label='export'
icon={ <FileDownloadIcon /> } onClick={ this.handleExport }
label='export' />
onClick={ this.handleMenuOpen }
/>
}
open={ this.state.menuOpen }
onRequestChange={ this.handleMenuChange }
onItemTouchTap={ this.handleExport }
targetOrigin={ { horizontal: 'right', vertical: 'top' } }
anchorOrigin={ { horizontal: 'right', vertical: 'top' } }
>
<MenuItem value='json' primaryText='Export to JSON' />
<MenuItem value='csv' primaryText='Export to CSV' />
</IconMenu>
); );
} }
@ -76,7 +57,6 @@ class ActionbarExport extends Component {
getExtension = (filetype) => { getExtension = (filetype) => {
switch (filetype) { switch (filetype) {
case 'json': case 'json':
case 'csv':
return filetype; return filetype;
default: default:
return 'txt'; return 'txt';
@ -91,30 +71,13 @@ class ActionbarExport extends Component {
switch (filetype) { switch (filetype) {
case 'json': case 'json':
return JSON.stringify(data, null, 4); return JSON.stringify(data, null, 4);
case 'csv':
return this.toCSV(data);
default: default:
return data.toString(); return data.toString();
} }
} }
toCSV = (data) => { handleExport = () => {
const json = Object.values(data); this.onDownloadBackup('json');
console.log(json);
return json2csv({ data: json });
}
handleExport = (event, child) => {
const type = child.props.value;
this.onDownloadBackup(type);
}
handleMenuOpen = () => {
this.setState({ menuOpen: true });
}
handleMenuChange = (open) => {
this.setState({ menuOpen: open });
} }
} }