mirror of
https://github.com/apache/superset.git
synced 2024-09-18 19:49:37 -04:00
[sqllab] use encodeURIComponent for copy query URL (#1317)
had to bump babel-preset-airbnb for object-rest-spread to work in my env. Change the menu icon, text and tooltip to clarify the usage
This commit is contained in:
parent
79460abdd2
commit
bf1f5ea3de
@ -27,10 +27,10 @@ export default class CopyQueryTabUrl extends React.Component {
|
|||||||
const params = [];
|
const params = [];
|
||||||
const qe = this.props.qe;
|
const qe = this.props.qe;
|
||||||
if (qe.dbId) params.push('dbid=' + qe.dbId);
|
if (qe.dbId) params.push('dbid=' + qe.dbId);
|
||||||
if (qe.title) params.push('title=' + qe.title);
|
if (qe.title) params.push('title=' + encodeURIComponent(qe.title));
|
||||||
if (qe.schema) params.push('schema=' + qe.schema);
|
if (qe.schema) params.push('schema=' + encodeURIComponent(qe.schema));
|
||||||
if (qe.autorun) params.push('autorun=' + qe.autorun);
|
if (qe.autorun) params.push('autorun=' + qe.autorun);
|
||||||
if (qe.sql) params.push('sql=' + qe.sql);
|
if (qe.sql) params.push('sql=' + encodeURIComponent(qe.sql));
|
||||||
|
|
||||||
const queryString = params.join('&');
|
const queryString = params.join('&');
|
||||||
const queryLink = this.state.cleanUri + '?' + queryString;
|
const queryLink = this.state.cleanUri + '?' + queryString;
|
||||||
@ -43,7 +43,8 @@ export default class CopyQueryTabUrl extends React.Component {
|
|||||||
<CopyToClipboard
|
<CopyToClipboard
|
||||||
inMenu
|
inMenu
|
||||||
text={this.getQueryLink()}
|
text={this.getQueryLink()}
|
||||||
copyNode={<span>copy query</span>}
|
copyNode={<span>share query</span>}
|
||||||
|
tooltipText="copy URL to clipboard"
|
||||||
shouldShowText={false}
|
shouldShowText={false}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -7,6 +7,7 @@ const propTypes = {
|
|||||||
shouldShowText: PropTypes.bool,
|
shouldShowText: PropTypes.bool,
|
||||||
text: PropTypes.string.isRequired,
|
text: PropTypes.string.isRequired,
|
||||||
inMenu: PropTypes.bool,
|
inMenu: PropTypes.bool,
|
||||||
|
tooltipText: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
@ -14,6 +15,7 @@ const defaultProps = {
|
|||||||
onCopyEnd: () => {},
|
onCopyEnd: () => {},
|
||||||
shouldShowText: true,
|
shouldShowText: true,
|
||||||
inMenu: false,
|
inMenu: false,
|
||||||
|
tooltipText: 'Copy to clipboard',
|
||||||
};
|
};
|
||||||
|
|
||||||
export default class CopyToClipboard extends React.Component {
|
export default class CopyToClipboard extends React.Component {
|
||||||
@ -64,13 +66,10 @@ export default class CopyToClipboard extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tooltipText() {
|
tooltipText() {
|
||||||
let tooltipText;
|
|
||||||
if (this.state.hasCopied) {
|
if (this.state.hasCopied) {
|
||||||
tooltipText = 'Copied!';
|
return 'Copied!';
|
||||||
} else {
|
|
||||||
tooltipText = 'Copy text';
|
|
||||||
}
|
}
|
||||||
return tooltipText;
|
return this.props.tooltipText;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderLink() {
|
renderLink() {
|
||||||
|
@ -92,7 +92,7 @@
|
|||||||
"babel": "^6.3.26",
|
"babel": "^6.3.26",
|
||||||
"babel-core": "^6.10.4",
|
"babel-core": "^6.10.4",
|
||||||
"babel-loader": "^6.2.4",
|
"babel-loader": "^6.2.4",
|
||||||
"babel-preset-airbnb": "^2.0.0",
|
"babel-preset-airbnb": "^2.1.1",
|
||||||
"babel-preset-react": "^6.11.1",
|
"babel-preset-react": "^6.11.1",
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
"codeclimate-test-reporter": "^0.3.3",
|
"codeclimate-test-reporter": "^0.3.3",
|
||||||
|
Loading…
Reference in New Issue
Block a user