mirror of
https://github.com/apache/superset.git
synced 2026-04-10 20:06:13 +00:00
* Add http to copied url and move function to componentWillReceiveProps * Added getText() to CopyToClipbaord to enable ajax calls for getting copy text * Set ajax call to synchronous (document.execCommand only works in synchronous mode
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
import React from 'react';
|
|
import CopyToClipboard from '../../components/CopyToClipboard';
|
|
import { getShortUrl } from '../../../utils/common';
|
|
|
|
const propTypes = {
|
|
queryEditor: React.PropTypes.object.isRequired,
|
|
};
|
|
|
|
export default class CopyQueryTabUrl extends React.PureComponent {
|
|
getUrl(callback) {
|
|
const qe = this.props.queryEditor;
|
|
const params = [];
|
|
if (qe.dbId) params.push('dbid=' + qe.dbId);
|
|
if (qe.title) params.push('title=' + encodeURIComponent(qe.title));
|
|
if (qe.schema) params.push('schema=' + encodeURIComponent(qe.schema));
|
|
if (qe.autorun) params.push('autorun=' + qe.autorun);
|
|
if (qe.sql) params.push('sql=' + encodeURIComponent(qe.sql));
|
|
|
|
const queryString = params.join('&');
|
|
const queryLink = window.location.pathname + '?' + queryString;
|
|
getShortUrl(queryLink, 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;
|