import React from 'react'; import { ButtonGroup } from 'react-bootstrap'; import Link from './Link'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import * as Actions from '../actions'; import shortid from 'shortid'; class TableElement extends React.Component { setSelectStar() { this.props.actions.queryEditorSetSql(this.props.queryEditor, this.selectStar()); } selectStar() { let cols = ''; this.props.table.columns.forEach((col, i) => { cols += col.name; if (i < this.props.table.columns.length - 1) { cols += ', '; } }); return `SELECT ${cols}\nFROM ${this.props.table.name}`; } popSelectStar() { const qe = { id: shortid.generate(), title: this.props.table.name, dbId: this.props.table.dbId, autorun: true, sql: this.selectStar(), }; this.props.actions.addQueryEditor(qe); } render() { let metadata = null; let buttonToggle; if (this.props.table.expanded) { buttonToggle = ( {this.props.table.name} ); metadata = (