mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 01:25:52 -05:00
moved and renamed linkUrl to keep url generation in one place
This commit is contained in:
parent
d5e2ed69ad
commit
6a3110e24e
5 changed files with 17 additions and 15 deletions
|
@ -22,7 +22,6 @@ class SocialModal extends React.Component {
|
||||||
'handleCopyProjectLink',
|
'handleCopyProjectLink',
|
||||||
'hideEmbedResult',
|
'hideEmbedResult',
|
||||||
'hideLinkResult',
|
'hideLinkResult',
|
||||||
'linkUrl',
|
|
||||||
'setEmbedTextarea',
|
'setEmbedTextarea',
|
||||||
'setLinkTextarea'
|
'setLinkTextarea'
|
||||||
]);
|
]);
|
||||||
|
@ -67,9 +66,6 @@ class SocialModal extends React.Component {
|
||||||
this.setState({showLinkResult: false});
|
this.setState({showLinkResult: false});
|
||||||
this.linkCopyTimeoutId = null;
|
this.linkCopyTimeoutId = null;
|
||||||
}
|
}
|
||||||
linkUrl () {
|
|
||||||
return `${window.location.origin}${window.location.pathname}`;
|
|
||||||
}
|
|
||||||
setEmbedTextarea (textarea) {
|
setEmbedTextarea (textarea) {
|
||||||
this.embedTextarea = textarea;
|
this.embedTextarea = textarea;
|
||||||
return textarea;
|
return textarea;
|
||||||
|
@ -98,7 +94,7 @@ class SocialModal extends React.Component {
|
||||||
fbUrl={social.facebookIntentLink(projectId)}
|
fbUrl={social.facebookIntentLink(projectId)}
|
||||||
googleClassroomUrl={social.googleClassroomIntentLink(projectId)}
|
googleClassroomUrl={social.googleClassroomIntentLink(projectId)}
|
||||||
isOpen={this.props.isOpen}
|
isOpen={this.props.isOpen}
|
||||||
linkUrl={this.linkUrl()}
|
projectUrl={social.projectUrl(projectId)}
|
||||||
setEmbedTextarea={this.setEmbedTextarea}
|
setEmbedTextarea={this.setEmbedTextarea}
|
||||||
setLinkTextarea={this.setLinkTextarea}
|
setLinkTextarea={this.setLinkTextarea}
|
||||||
showEmbedResult={this.state.showEmbedResult}
|
showEmbedResult={this.state.showEmbedResult}
|
||||||
|
|
|
@ -15,10 +15,10 @@ const SocialModalPresentation = ({
|
||||||
embedHtml,
|
embedHtml,
|
||||||
intl,
|
intl,
|
||||||
isOpen,
|
isOpen,
|
||||||
linkUrl,
|
|
||||||
onCopyEmbed,
|
onCopyEmbed,
|
||||||
onCopyProjectLink,
|
onCopyProjectLink,
|
||||||
onRequestClose,
|
onRequestClose,
|
||||||
|
projectUrl,
|
||||||
setEmbedTextarea,
|
setEmbedTextarea,
|
||||||
setLinkTextarea,
|
setLinkTextarea,
|
||||||
showEmbedResult,
|
showEmbedResult,
|
||||||
|
@ -72,7 +72,7 @@ const SocialModalPresentation = ({
|
||||||
className="social-form social-input"
|
className="social-form social-input"
|
||||||
name="link"
|
name="link"
|
||||||
ref={textarea => setLinkTextarea(textarea)}
|
ref={textarea => setLinkTextarea(textarea)}
|
||||||
value={linkUrl}
|
value={projectUrl}
|
||||||
/>
|
/>
|
||||||
</FlexRow>
|
</FlexRow>
|
||||||
</div>
|
</div>
|
||||||
|
@ -122,10 +122,10 @@ SocialModalPresentation.propTypes = {
|
||||||
embedHtml: PropTypes.string,
|
embedHtml: PropTypes.string,
|
||||||
intl: intlShape,
|
intl: intlShape,
|
||||||
isOpen: PropTypes.bool,
|
isOpen: PropTypes.bool,
|
||||||
linkUrl: PropTypes.string,
|
|
||||||
onCopyEmbed: PropTypes.func,
|
onCopyEmbed: PropTypes.func,
|
||||||
onCopyProjectLink: PropTypes.func,
|
onCopyProjectLink: PropTypes.func,
|
||||||
onRequestClose: PropTypes.func,
|
onRequestClose: PropTypes.func,
|
||||||
|
projectUrl: PropTypes.string,
|
||||||
setEmbedTextarea: PropTypes.func,
|
setEmbedTextarea: PropTypes.func,
|
||||||
setLinkTextarea: PropTypes.func,
|
setLinkTextarea: PropTypes.func,
|
||||||
showEmbedResult: PropTypes.bool,
|
showEmbedResult: PropTypes.bool,
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
module.exports = {};
|
module.exports = {};
|
||||||
|
|
||||||
|
module.exports.projectUrl = projectId => {
|
||||||
|
if (projectId) {
|
||||||
|
return `https://scratch.mit.edu/projects/${projectId}`;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
};
|
||||||
|
|
||||||
module.exports.embedHtml = projectId => {
|
module.exports.embedHtml = projectId => {
|
||||||
if (projectId) {
|
if (projectId) {
|
||||||
return `<iframe src="https://scratch.mit.edu/projects/${projectId}/embed" ` +
|
return `<iframe src="https://scratch.mit.edu/projects/${projectId}/embed" ` +
|
||||||
|
|
|
@ -382,6 +382,12 @@ class Preview extends React.Component {
|
||||||
handleAddToStudioClose () {
|
handleAddToStudioClose () {
|
||||||
this.setState({addToStudioOpen: false});
|
this.setState({addToStudioOpen: false});
|
||||||
}
|
}
|
||||||
|
handleSocialClick () {
|
||||||
|
this.setState({socialOpen: true});
|
||||||
|
}
|
||||||
|
handleSocialClose () {
|
||||||
|
this.setState({socialOpen: false});
|
||||||
|
}
|
||||||
handleReportSubmit (formData) {
|
handleReportSubmit (formData) {
|
||||||
const submit = data => this.props.reportProject(this.state.projectId, data, this.props.user.token);
|
const submit = data => this.props.reportProject(this.state.projectId, data, this.props.user.token);
|
||||||
if (this.getProjectThumbnail) {
|
if (this.getProjectThumbnail) {
|
||||||
|
@ -580,12 +586,6 @@ class Preview extends React.Component {
|
||||||
this.props.user.token
|
this.props.user.token
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
handleSocialClick () {
|
|
||||||
this.setState({socialOpen: true});
|
|
||||||
}
|
|
||||||
handleSocialClose () {
|
|
||||||
this.setState({socialOpen: false});
|
|
||||||
}
|
|
||||||
initCounts (favorites, loves) {
|
initCounts (favorites, loves) {
|
||||||
this.setState({
|
this.setState({
|
||||||
favoriteCount: favorites,
|
favoriteCount: favorites,
|
||||||
|
|
|
@ -3,7 +3,6 @@ const connect = require('react-redux').connect;
|
||||||
const defaults = require('lodash.defaultsdeep');
|
const defaults = require('lodash.defaultsdeep');
|
||||||
const PropTypes = require('prop-types');
|
const PropTypes = require('prop-types');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
// const formik = require('formik');
|
|
||||||
|
|
||||||
const api = require('../../lib/api');
|
const api = require('../../lib/api');
|
||||||
const injectIntl = require('../../lib/intl.jsx').injectIntl;
|
const injectIntl = require('../../lib/intl.jsx').injectIntl;
|
||||||
|
|
Loading…
Reference in a new issue