All files / javascripts/SqlLab/components CopyQueryTabUrl.jsx

0% Statements 0/10
100% Branches 0/0
100% Functions 0/0
0% Lines 0/10
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                                                                                 
import React from 'react';
import PropTypes from 'prop-types';
import CopyToClipboard from '../../components/CopyToClipboard';
import { storeQuery } from '../../../utils/common';
 
const propTypes = {
  queryEditor: PropTypes.object.isRequired,
};
 
export default class CopyQueryTabUrl extends React.PureComponent {
  getUrl(callback) {
    const qe = this.props.queryEditor;
    const sharedQuery = {
      dbId: qe.dbId,
      title: qe.title,
      schema: qe.schema,
      autorun: qe.autorun,
      sql: qe.sql,
    };
    storeQuery(sharedQuery, callback);
  }
 
  render() {
    return (
      <CopyToClipboard
        inMenu
        copyNode={(
          <div>
            <i className="fa fa-clipboard" /> <span>share query</span>
          </div>
        )}
        tooltipText="copy URL to clipboard"
        shouldShowText={false}
        getText={this.getUrl.bind(this)}
      />
    );
  }
}
 
CopyQueryTabUrl.propTypes = propTypes;