mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
[WIP] Add http to copied url and move function to componentWillReceiveProps (#1780)
* 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
This commit is contained in:
@@ -7,14 +7,7 @@ const propTypes = {
|
||||
};
|
||||
|
||||
export default class CopyQueryTabUrl extends React.PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
shortUrl: '',
|
||||
};
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
getUrl(callback) {
|
||||
const qe = this.props.queryEditor;
|
||||
const params = [];
|
||||
if (qe.dbId) params.push('dbid=' + qe.dbId);
|
||||
@@ -25,20 +18,13 @@ export default class CopyQueryTabUrl extends React.PureComponent {
|
||||
|
||||
const queryString = params.join('&');
|
||||
const queryLink = window.location.pathname + '?' + queryString;
|
||||
getShortUrl(queryLink, this.onShortUrlSuccess.bind(this));
|
||||
}
|
||||
|
||||
onShortUrlSuccess(data) {
|
||||
this.setState({
|
||||
shortUrl: data,
|
||||
});
|
||||
getShortUrl(queryLink, callback);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<CopyToClipboard
|
||||
inMenu
|
||||
text={this.state.shortUrl}
|
||||
copyNode={(
|
||||
<div>
|
||||
<i className="fa fa-clipboard" /> <span>share query</span>
|
||||
@@ -46,6 +32,7 @@ export default class CopyQueryTabUrl extends React.PureComponent {
|
||||
)}
|
||||
tooltipText="copy URL to clipboard"
|
||||
shouldShowText={false}
|
||||
getText={this.getUrl.bind(this)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user