Skip to content

Commit

Permalink
[sqllab] use encodeURIComponent for copy query URL (#1317)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mistercrunch committed Oct 11, 2016
1 parent 79460ab commit bf1f5ea
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export default class CopyQueryTabUrl extends React.Component {
const params = [];
const qe = this.props.qe;
if (qe.dbId) params.push('dbid=' + qe.dbId);
if (qe.title) params.push('title=' + qe.title);
if (qe.schema) params.push('schema=' + qe.schema);
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=' + qe.sql);
if (qe.sql) params.push('sql=' + encodeURIComponent(qe.sql));

const queryString = params.join('&');
const queryLink = this.state.cleanUri + '?' + queryString;
Expand All @@ -43,7 +43,8 @@ export default class CopyQueryTabUrl extends React.Component {
<CopyToClipboard
inMenu
text={this.getQueryLink()}
copyNode={<span>copy query</span>}
copyNode={<span>share query</span>}
tooltipText="copy URL to clipboard"
shouldShowText={false}
/>
);
Expand Down
9 changes: 4 additions & 5 deletions caravel/assets/javascripts/components/CopyToClipboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ const propTypes = {
shouldShowText: PropTypes.bool,
text: PropTypes.string.isRequired,
inMenu: PropTypes.bool,
tooltipText: PropTypes.string,
};

const defaultProps = {
copyNode: <span>Copy</span>,
onCopyEnd: () => {},
shouldShowText: true,
inMenu: false,
tooltipText: 'Copy to clipboard',
};

export default class CopyToClipboard extends React.Component {
Expand Down Expand Up @@ -64,13 +66,10 @@ export default class CopyToClipboard extends React.Component {
}

tooltipText() {
let tooltipText;
if (this.state.hasCopied) {
tooltipText = 'Copied!';
} else {
tooltipText = 'Copy text';
return 'Copied!';
}
return tooltipText;
return this.props.tooltipText;
}

renderLink() {
Expand Down
2 changes: 1 addition & 1 deletion caravel/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"babel": "^6.3.26",
"babel-core": "^6.10.4",
"babel-loader": "^6.2.4",
"babel-preset-airbnb": "^2.0.0",
"babel-preset-airbnb": "^2.1.1",
"babel-preset-react": "^6.11.1",
"chai": "^3.5.0",
"codeclimate-test-reporter": "^0.3.3",
Expand Down

0 comments on commit bf1f5ea

Please sign in to comment.