-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* In the tab's dropdown menu under SQL editors, copy query link option is added. A url with copied query will pop up a new editor tab. * Made changes based on comments * Move copy query button to right bottom of sql editor box * Added in Alanna's code for copy url under menu item * Fixed linting issues
- Loading branch information
Showing
4 changed files
with
152 additions
and
14 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
caravel/assets/javascripts/SqlLab/components/CopyQueryTabUrl.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from 'react'; | ||
import CopyToClipboard from '../../components/CopyToClipboard'; | ||
|
||
const propTypes = { | ||
qe: React.PropTypes.object, | ||
}; | ||
|
||
const defaultProps = { | ||
qe: null, | ||
}; | ||
|
||
export default class CopyQueryTabUrl extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
const uri = window.location.toString(); | ||
const search = window.location.search; | ||
const cleanUri = search ? uri.substring(0, uri.indexOf('?')) : uri; | ||
const query = search.substring(1); | ||
this.state = { | ||
uri, | ||
cleanUri, | ||
query, | ||
}; | ||
} | ||
|
||
getQueryLink() { | ||
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.autorun) params.push('autorun=' + qe.autorun); | ||
if (qe.sql) params.push('sql=' + qe.sql); | ||
|
||
const queryString = params.join('&'); | ||
const queryLink = this.state.cleanUri + '?' + queryString; | ||
|
||
return queryLink; | ||
} | ||
|
||
render() { | ||
return ( | ||
<CopyToClipboard | ||
inMenu | ||
text={this.getQueryLink()} | ||
copyNode={<span>copy query</span>} | ||
shouldShowText={false} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
CopyQueryTabUrl.propTypes = propTypes; | ||
CopyQueryTabUrl.defaultProps = defaultProps; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters