[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:
vera-liu
2016-12-06 17:49:41 -08:00
committed by GitHub
parent c1558578d7
commit 74edb936a5
4 changed files with 21 additions and 25 deletions

View File

@@ -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)}
/>
);
}