Copy query to clipboard
MODIFY
app/components/Settings/Settings.react.js
app/components/Settings/Settings.react.js
@@ -426,6 +426,7 @@ class Settings extends Component {
openLogin={this.openLogin}
requestor={username}
dialect={dialect}
+ preview={preview}
openQueryPage={() => this.updateSelectedPanel(1)}
/>
</TabPanel>

MODIFY
app/components/Settings/scheduler/login-modal.css
app/components/Settings/scheduler/login-modal.css
padding: 16px;
}
-.login-modal .submit {
+.login-modal .actions button {
width: 50%;
margin: 24px 32px 32px;
}

MODIFY
app/components/Settings/scheduler/login-modal.jsx
app/components/Settings/scheduler/login-modal.jsx
import React from 'react';
import PropTypes from 'prop-types';
+import {CopyToClipboard} from 'react-copy-to-clipboard';
import {Row, Column} from '../../layout.jsx';
import Modal from '../../modal.jsx';
@@ -16,14 +17,19 @@ const PromptLoginModal = props => (
</button>
<Row className="header">
<p>
- To create a scheduled query, you'll need to be logged into Plotly. Logging in will reset your query,
- so please save it elsewhere before doing so.
+ To create a scheduled query, you'll need to be logged into Plotly.<br/><br/>
+ Note: logging in will reset your query, click the button below to copy the query to your clipboard.
</p>
</Row>
- <Row>
- <button type="submit" className="submit" onClick={props.onSubmit}>
+ <Row className="actions">
+ <button type="submit" onClick={props.onSubmit}>
Log In
</button>
+ <CopyToClipboard text={props.preview.code}>
+ <button className="btn-secondary">
+ Copy Query
+ </button>
+ </CopyToClipboard>
</Row>
</Column>
</Modal>
@@ -31,6 +37,7 @@ const PromptLoginModal = props => (
PromptLoginModal.propTypes = {
open: PropTypes.bool.isRequired,
+ preview: PropTypes.string.isRequired,
onClickAway: PropTypes.func.isRequired,
onSubmit: PropTypes.func.isRequired
};

MODIFY
app/components/Settings/scheduler/scheduler.jsx
app/components/Settings/scheduler/scheduler.jsx
@@ -115,6 +115,7 @@ class Scheduler extends Component {
initialCode: PropTypes.string,
requestor: PropTypes.string,
dialect: PropTypes.string,
+ preview: PropTypes.string,
refreshQueries: PropTypes.func.isRequired,
openLogin: PropTypes.func.isRequired,
createScheduledQuery: PropTypes.func.isRequired,
@@ -304,6 +305,7 @@ class Scheduler extends Component {
open={!loggedIn && this.state.createModalOpen}
onClickAway={this.closeCreateModal}
onSubmit={this.props.openLogin}
+ preview={this.props.preview}
/>
{/*

MODIFY
package.json
package.json
"papaparse": "^4.3.7",
"pg": "^4.5.5",
"pg-hstore": "^2.3.2",
+ "react-copy-to-clipboard": "^5.0.1",
"restify": "^4.3.2",
"sequelize": "3.30.4",
"source-map-support": "^0.5.0",

MODIFY
yarn.lock
yarn.lock
@@ -2428,6 +2428,12 @@ copy-descriptor@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d"
+copy-to-clipboard@^3:
+ version "3.0.8"
+ resolved "https://registry.yarnpkg.com/copy-to-clipboard/-/copy-to-clipboard-3.0.8.tgz#f4e82f4a8830dce4666b7eb8ded0c9bcc313aba9"
+ dependencies:
+ toggle-selection "^1.0.3"
+
core-js@^1.0.0:
version "1.2.7"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
@@ -8644,6 +8650,13 @@ react-cookies@^0.1.0:
cookie "^0.3.1"
object-assign "^4.1.1"
+react-copy-to-clipboard@^5.0.1:
+ version "5.0.1"
+ resolved "https://registry.yarnpkg.com/react-copy-to-clipboard/-/react-copy-to-clipboard-5.0.1.tgz#8eae107bb400be73132ed3b6a7b4fb156090208e"
+ dependencies:
+ copy-to-clipboard "^3"
+ prop-types "^15.5.8"
+
react-data-grid-addons@^3.0.11:
version "3.0.11"
resolved "https://registry.yarnpkg.com/react-data-grid-addons/-/react-data-grid-addons-3.0.11.tgz#9d38c31aa1f475f93735246292395e6d1fa7eb38"
@@ -10764,6 +10777,10 @@ to-regex@^3.0.1, to-regex@^3.0.2:
regex-not "^1.0.2"
safe-regex "^1.1.0"
+toggle-selection@^1.0.3:
+ version "1.0.6"
+ resolved "https://registry.yarnpkg.com/toggle-selection/-/toggle-selection-1.0.6.tgz#6e45b1263f2017fa0acc7d89d78b15b8bf77da32"
+
tohash@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/tohash/-/tohash-1.0.2.tgz#9e66e497da0cfd77ba85f9663065adf2d8c99981"

Copy query to clipboard