All files / javascripts/SqlLab/components QueryLink.jsx

0% Statements 0/12
100% Branches 0/0
0% Functions 0/1
0% Lines 0/12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63                                                                                                                             
import React from 'react';
import Link from './Link';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import * as Actions from '../actions';
import shortid from 'shortid';
 
class QueryLink extends React.Component {
  popTab() {
    const qe = {
      id: shortid.generate(),
      title: this.props.query.title,
      dbId: this.props.query.dbId,
      autorun: false,
      sql: this.props.query.sql,
    };
    this.props.actions.addQueryEditor(qe);
  }
  render() {
    return (
      <div>
        <div className="clearfix">
          <div className="pull-left">
            <a
              href="#"
              tooltip="Pop this query in a new tab"
              onClick={this.popTab.bind(this)}
            >
              {this.props.query.title}
            </a>
          </div>
          <div className="pull-right">
            <Link
              onClick={this.props.actions.removeWorkspaceQuery.bind(this, this.props.query)}
              tooltip="Remove query from workspace"
              href="#"
            >
              &times;
            </Link>
          </div>
        </div>
        <hr />
      </div>
    );
  }
}
 
QueryLink.propTypes = {
  query: React.PropTypes.object,
  actions: React.PropTypes.object,
};
 
QueryLink.defaultProps = {
};
 
function mapDispatchToProps(dispatch) {
  return {
    actions: bindActionCreators(Actions, dispatch),
  };
}
export default connect(null, mapDispatchToProps)(QueryLink);