mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-02-17 00:21:20 -05:00
Merge pull request #2343 from paulkaplan/implement-copy-link
Implement the copy link functionality
This commit is contained in:
commit
2f393d2407
4 changed files with 19 additions and 1 deletions
|
@ -25,6 +25,7 @@
|
||||||
"homepage": "https://github.com/llk/scratch-www#readme",
|
"homepage": "https://github.com/llk/scratch-www#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bunyan": "1.7.1",
|
"bunyan": "1.7.1",
|
||||||
|
"clipboard-copy": "2.0.1",
|
||||||
"compression": "1.6.1",
|
"compression": "1.6.1",
|
||||||
"express": "4.16.1",
|
"express": "4.16.1",
|
||||||
"express-http-proxy": "1.1.0",
|
"express-http-proxy": "1.1.0",
|
||||||
|
|
|
@ -69,6 +69,7 @@ const PreviewPresentation = ({
|
||||||
onAddComment,
|
onAddComment,
|
||||||
onAddToStudioClicked,
|
onAddToStudioClicked,
|
||||||
onAddToStudioClosed,
|
onAddToStudioClosed,
|
||||||
|
onCopyProjectLink,
|
||||||
onDeleteComment,
|
onDeleteComment,
|
||||||
onFavoriteClicked,
|
onFavoriteClicked,
|
||||||
onLoadMore,
|
onLoadMore,
|
||||||
|
@ -236,6 +237,7 @@ const PreviewPresentation = ({
|
||||||
shareDate={shareDate}
|
shareDate={shareDate}
|
||||||
onAddToStudioClicked={onAddToStudioClicked}
|
onAddToStudioClicked={onAddToStudioClicked}
|
||||||
onAddToStudioClosed={onAddToStudioClosed}
|
onAddToStudioClosed={onAddToStudioClosed}
|
||||||
|
onCopyProjectLink={onCopyProjectLink}
|
||||||
onReportClicked={onReportClicked}
|
onReportClicked={onReportClicked}
|
||||||
onReportClose={onReportClose}
|
onReportClose={onReportClose}
|
||||||
onReportSubmit={onReportSubmit}
|
onReportSubmit={onReportSubmit}
|
||||||
|
@ -366,6 +368,7 @@ const PreviewPresentation = ({
|
||||||
shareDate={shareDate}
|
shareDate={shareDate}
|
||||||
onAddToStudioClicked={onAddToStudioClicked}
|
onAddToStudioClicked={onAddToStudioClicked}
|
||||||
onAddToStudioClosed={onAddToStudioClosed}
|
onAddToStudioClosed={onAddToStudioClosed}
|
||||||
|
onCopyProjectLink={onCopyProjectLink}
|
||||||
onReportClicked={onReportClicked}
|
onReportClicked={onReportClicked}
|
||||||
onReportClose={onReportClose}
|
onReportClose={onReportClose}
|
||||||
onReportSubmit={onReportSubmit}
|
onReportSubmit={onReportSubmit}
|
||||||
|
@ -513,6 +516,7 @@ PreviewPresentation.propTypes = {
|
||||||
onAddComment: PropTypes.func,
|
onAddComment: PropTypes.func,
|
||||||
onAddToStudioClicked: PropTypes.func,
|
onAddToStudioClicked: PropTypes.func,
|
||||||
onAddToStudioClosed: PropTypes.func,
|
onAddToStudioClosed: PropTypes.func,
|
||||||
|
onCopyProjectLink: PropTypes.func,
|
||||||
onDeleteComment: PropTypes.func,
|
onDeleteComment: PropTypes.func,
|
||||||
onFavoriteClicked: PropTypes.func,
|
onFavoriteClicked: PropTypes.func,
|
||||||
onLoadMore: PropTypes.func,
|
onLoadMore: PropTypes.func,
|
||||||
|
|
|
@ -7,6 +7,8 @@ const PropTypes = require('prop-types');
|
||||||
const connect = require('react-redux').connect;
|
const connect = require('react-redux').connect;
|
||||||
const injectIntl = require('react-intl').injectIntl;
|
const injectIntl = require('react-intl').injectIntl;
|
||||||
const parser = require('scratch-parser');
|
const parser = require('scratch-parser');
|
||||||
|
const copy = require('clipboard-copy');
|
||||||
|
|
||||||
const Page = require('../../components/page/www/page.jsx');
|
const Page = require('../../components/page/www/page.jsx');
|
||||||
const storage = require('../../lib/storage.js').default;
|
const storage = require('../../lib/storage.js').default;
|
||||||
const log = require('../../lib/log');
|
const log = require('../../lib/log');
|
||||||
|
@ -37,6 +39,7 @@ class Preview extends React.Component {
|
||||||
'addEventListeners',
|
'addEventListeners',
|
||||||
'fetchCommunityData',
|
'fetchCommunityData',
|
||||||
'handleAddComment',
|
'handleAddComment',
|
||||||
|
'handleCopyProjectLink',
|
||||||
'handleDeleteComment',
|
'handleDeleteComment',
|
||||||
'handleToggleStudio',
|
'handleToggleStudio',
|
||||||
'handleFavoriteToggle',
|
'handleFavoriteToggle',
|
||||||
|
@ -387,6 +390,11 @@ class Preview extends React.Component {
|
||||||
this.props.user.token
|
this.props.user.token
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
handleCopyProjectLink () {
|
||||||
|
// Use the pathname so we do not have to update this if path changes
|
||||||
|
// Also do not include hash or query params
|
||||||
|
copy(`${window.location.origin}${window.location.pathname}`);
|
||||||
|
}
|
||||||
initCounts (favorites, loves) {
|
initCounts (favorites, loves) {
|
||||||
this.setState({
|
this.setState({
|
||||||
favoriteCount: favorites,
|
favoriteCount: favorites,
|
||||||
|
@ -462,6 +470,7 @@ class Preview extends React.Component {
|
||||||
onAddComment={this.handleAddComment}
|
onAddComment={this.handleAddComment}
|
||||||
onAddToStudioClicked={this.handleAddToStudioClick}
|
onAddToStudioClicked={this.handleAddToStudioClick}
|
||||||
onAddToStudioClosed={this.handleAddToStudioClose}
|
onAddToStudioClosed={this.handleAddToStudioClose}
|
||||||
|
onCopyProjectLink={this.handleCopyProjectLink}
|
||||||
onDeleteComment={this.handleDeleteComment}
|
onDeleteComment={this.handleDeleteComment}
|
||||||
onFavoriteClicked={this.handleFavoriteToggle}
|
onFavoriteClicked={this.handleFavoriteToggle}
|
||||||
onLoadMore={this.handleLoadMore}
|
onLoadMore={this.handleLoadMore}
|
||||||
|
|
|
@ -47,7 +47,10 @@ const Subactions = props => (
|
||||||
)}
|
)}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
}
|
}
|
||||||
<Button className="action-button copy-link-button">
|
<Button
|
||||||
|
className="action-button copy-link-button"
|
||||||
|
onClick={props.onCopyProjectLink}
|
||||||
|
>
|
||||||
<FormattedMessage id="general.copyLink" />
|
<FormattedMessage id="general.copyLink" />
|
||||||
</Button>
|
</Button>
|
||||||
{(props.canReport) &&
|
{(props.canReport) &&
|
||||||
|
@ -80,6 +83,7 @@ Subactions.propTypes = {
|
||||||
canReport: PropTypes.bool,
|
canReport: PropTypes.bool,
|
||||||
onAddToStudioClicked: PropTypes.func,
|
onAddToStudioClicked: PropTypes.func,
|
||||||
onAddToStudioClosed: PropTypes.func,
|
onAddToStudioClosed: PropTypes.func,
|
||||||
|
onCopyProjectLink: PropTypes.func,
|
||||||
onReportClicked: PropTypes.func.isRequired,
|
onReportClicked: PropTypes.func.isRequired,
|
||||||
onReportClose: PropTypes.func.isRequired,
|
onReportClose: PropTypes.func.isRequired,
|
||||||
onReportSubmit: PropTypes.func.isRequired,
|
onReportSubmit: PropTypes.func.isRequired,
|
||||||
|
|
Loading…
Reference in a new issue