Skip to content

Commit 28d3c19

Browse files
committed
disable cloud for scratch preview projects
1 parent f172fe4 commit 28d3c19

File tree

2 files changed

+37
-14
lines changed

2 files changed

+37
-14
lines changed

src/containers/green-flag-overlay.jsx

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Box from '../components/box/box.jsx';
1010
import greenFlag from '../components/green-flag/icon--green-flag.svg';
1111
import {setStartedState} from '../reducers/vm-status.js';
1212
import {FormattedMessage} from 'react-intl';
13-
import ProjectAnalyticsHOC from '../lib/project-analytics-hoc.jsx'; // Import HOC
13+
import ProjectAnalyticsHOC from '../lib/project-analytics-hoc.jsx';
1414

1515
import styles from '../components/stage/stage.css';
1616

@@ -37,31 +37,50 @@ class GreenFlagOverlay extends React.Component {
3737
render () {
3838
// Check if project has cloud vars and user is generic 'player' or empty string (not logged in)
3939
const isGuest = !this.props.username || this.props.username === 'player';
40-
const showCloudWarning = this.props.hasCloudVariables && isGuest;
40+
41+
const showScratchCloudWarning = this.props.hasCloudVariables && this.props.isScratchProject;
42+
const showGuestCloudWarning = !showScratchCloudWarning && this.props.hasCloudVariables && isGuest;
43+
44+
const anyWarning = showScratchCloudWarning || showGuestCloudWarning;
4145

4246
return (
4347
<Box
4448
className={classNames(
4549
this.props.wrapperClass,
46-
{[styles.greenFlagOverlayWithWarning]: showCloudWarning}
50+
{[styles.greenFlagOverlayWithWarning]: anyWarning}
4751
)}
4852
onClick={this.handleClick}
4953
>
50-
{showCloudWarning && (
54+
{anyWarning && (
5155
<div className={styles.cloudWarningContent}>
5256
<div className={styles.cloudWarningText}>
5357
<span className={styles.cloudWarningTextRed}>
54-
<FormattedMessage
55-
defaultMessage="Multiplayer Features: "
56-
id="gui.greenFlagOverlay.cloudTitle"
57-
/>
58+
{showScratchCloudWarning ? (
59+
<FormattedMessage
60+
defaultMessage="Scratch Preview: "
61+
id="gui.greenFlagOverlay.scratchCloudTitle"
62+
/>
63+
) : (
64+
<FormattedMessage
65+
defaultMessage="Multiplayer Features: "
66+
id="gui.greenFlagOverlay.cloudTitle"
67+
/>
68+
)}
5869
</span>
5970
<span>
60-
<FormattedMessage
61-
// eslint-disable-next-line max-len
62-
defaultMessage="This project uses cloud variables. To play online or interact with others, you must log in."
63-
id="gui.greenFlagOverlay.cloudWarning"
64-
/>
71+
{showScratchCloudWarning ? (
72+
<FormattedMessage
73+
// eslint-disable-next-line max-len
74+
defaultMessage="Cloud variables do not work for Scratch Preview Projects. Please remix this project to use multiplayer features."
75+
id="gui.greenFlagOverlay.scratchCloudWarning"
76+
/>
77+
) : (
78+
<FormattedMessage
79+
// eslint-disable-next-line max-len
80+
defaultMessage="This project uses cloud variables. To play online or interact with others, you must log in."
81+
id="gui.greenFlagOverlay.cloudWarning"
82+
/>
83+
)}
6584
</span>
6685
</div>
6786
</div>
@@ -84,13 +103,15 @@ GreenFlagOverlay.propTypes = {
84103
wrapperClass: PropTypes.string,
85104
onStarted: PropTypes.func,
86105
hasCloudVariables: PropTypes.bool,
106+
isScratchProject: PropTypes.bool,
87107
username: PropTypes.string,
88108
onGreenFlagClickAnalytics: PropTypes.func.isRequired
89109
};
90110

91111
const mapStateToProps = state => ({
92112
vm: state.scratchGui.vm,
93113
hasCloudVariables: state.scratchGui.tw.hasCloudVariables,
114+
isScratchProject: state.scratchGui.projectState.isScratchProject,
94115
username: state.scratchGui.tw.username,
95116
projectRunning: state.scratchGui.vmStatus.running
96117
});

src/lib/cloud-manager-hoc.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ const cloudManagerHOC = function (WrappedComponent) {
8383
props.vm &&
8484
props.projectId &&
8585
props.hasCloudPermission &&
86-
!props.cloudVariablesDisabledByUser
86+
!props.cloudVariablesDisabledByUser &&
87+
!props.isScratchProject // disable for scratch preview projects
8788
);
8889
}
8990
shouldConnect (props) {
@@ -201,6 +202,7 @@ const cloudManagerHOC = function (WrappedComponent) {
201202
cloudVariablesDisabledByUser: !state.scratchGui.tw.cloud,
202203
isShowingWithId: getIsShowingWithId(loadingState),
203204
projectId: state.scratchGui.projectState.projectId,
205+
isScratchProject: state.scratchGui.projectState.isScratchProject,
204206
// if you're editing someone else's project, you can't modify cloud data
205207
canModifyCloudData: (!state.scratchGui.mode.hasEverEnteredEditor || ownProps.canSave) &&
206208
// possible security concern if the program attempts to encode webcam data over cloud variables

0 commit comments

Comments
 (0)