import React from 'react'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import * as Actions from '../actions'; import moment from 'moment'; import { Table } from 'reactable'; import { ProgressBar } from 'react-bootstrap'; import SyntaxHighlighter from 'react-syntax-highlighter'; import { github } from 'react-syntax-highlighter/dist/styles'; import Link from './Link'; import VisualizeModal from './VisualizeModal'; import { STATE_BSSTYLE_MAP } from '../common'; import { fDuration } from '../../modules/dates'; class QueryTable extends React.Component { constructor(props) { super(props); this.state = { showVisualizeModal: false, activeQuery: null, }; } hideVisualizeModal() { this.setState({ showVisualizeModal: false }); } showVisualizeModal(query) { this.setState({ showVisualizeModal: true }); this.setState({ activeQuery: query }); } restoreSql(query) { this.props.actions.queryEditorSetSql({ id: query.sqlEditorId }, query.sql); } notImplemented() { alert('Not implemented yet!'); } render() { const data = this.props.queries.map((query) => { const q = Object.assign({}, query); if (q.endDttm) { q.duration = fDuration(q.startDttm, q.endDttm); } q.started = moment.utc(q.startDttm).format('HH:mm:ss'); const source = q.ctas ? q.executedSql : q.sql; q.sql = ( {source || ''} ); q.output = q.tempTable; q.progress = ( ); let errorTooltip; if (q.errorMessage) { errorTooltip = ( ); } q.state = (
{q.state} {errorTooltip}
); q.actions = (
); return q; }).reverse(); return (
); } } QueryTable.propTypes = { columns: React.PropTypes.array, actions: React.PropTypes.object, queries: React.PropTypes.array, }; QueryTable.defaultProps = { columns: ['state', 'started', 'duration', 'progress', 'rows', 'sql', 'actions'], queries: [], }; function mapStateToProps() { return {}; } function mapDispatchToProps(dispatch) { return { actions: bindActionCreators(Actions, dispatch), }; } export default connect(mapStateToProps, mapDispatchToProps)(QueryTable);