import React, {Component, PropTypes} from 'react' import _ from 'lodash' import LayoutCellMenu from 'shared/components/LayoutCellMenu' import LayoutCellHeader from 'shared/components/LayoutCellHeader' import {errorThrown} from 'shared/actions/errors' import {dashboardtoCSV} from 'shared/parsing/resultsToCSV' import download from 'src/external/download.js' class LayoutCell extends Component { constructor(props) { super(props) this.state = { isDeleting: false, celldata: [], } } closeMenu = () => { this.setState({ isDeleting: false, }) } handleDeleteClick = () => { this.setState({isDeleting: true}) } handleDeleteCell = cell => () => { this.props.onDeleteCell(cell) } handleSummonOverlay = cell => () => { this.props.onSummonOverlayTechnologies(cell) } grabDataForDownload = celldata => { this.setState({celldata}) } handleCSVDownload = cell => () => { const joinedName = cell.name.split(' ').join('_') const {celldata} = this.state try { download(dashboardtoCSV(celldata), `${joinedName}.csv`, 'text/plain') } catch (error) { errorThrown(error, 'Unable to download .csv file') console.error(error) } } render() { const {cell, children, isEditable} = this.props const {isDeleting, celldata} = this.state const queries = _.get(cell, ['queries'], []) return (