Skip to content

Commit 6cf5354

Browse files
committed
feat: use platform prop instead of isScratchDesktop
1 parent 70819a0 commit 6cf5354

File tree

9 files changed

+18
-52
lines changed

9 files changed

+18
-52
lines changed

packages/scratch-gui/src/components/cards/cards.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ Cards.propTypes = {
423423
onShowAll: PropTypes.func,
424424
onShrinkExpandCards: PropTypes.func.isRequired,
425425
onStartDrag: PropTypes.func,
426-
platform: PropTypes.string,
426+
platform: PropTypes.oneOf(Object.keys(PLATFORM)),
427427
step: PropTypes.number.isRequired,
428428
x: PropTypes.number,
429429
y: PropTypes.number

packages/scratch-gui/src/components/gui/gui.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import costumesIcon from './icon--costumes.svg';
4343
import soundsIcon from './icon--sounds.svg';
4444
import DebugModal from '../debug-modal/debug-modal.jsx';
4545
import {setPlatform} from '../../reducers/platform.js';
46+
import {PLATFORM} from '../../lib/platform.js';
4647

4748
const messages = defineMessages({
4849
addExtension: {
@@ -466,7 +467,7 @@ GUIComponent.propTypes = {
466467
onTelemetryModalOptIn: PropTypes.func,
467468
onTelemetryModalOptOut: PropTypes.func,
468469
onToggleLoginOpen: PropTypes.func,
469-
platform: PropTypes.string,
470+
platform: PropTypes.oneOf(Object.keys(PLATFORM)),
470471
renderLogin: PropTypes.func,
471472
showComingSoon: PropTypes.bool,
472473
soundsTabVisible: PropTypes.bool,

packages/scratch-gui/src/components/menu-bar/menu-bar.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ MenuBar.propTypes = {
966966
onShare: PropTypes.func,
967967
onStartSelectingFileUpload: PropTypes.func,
968968
onToggleLoginOpen: PropTypes.func,
969-
platform: PropTypes.string,
969+
platform: PropTypes.oneOf(Object.keys(PLATFORM)),
970970
projectTitle: PropTypes.string,
971971
renderLogin: PropTypes.func,
972972
settingsMenuOpen: PropTypes.bool,

packages/scratch-gui/src/containers/cards.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919

2020
import CardsComponent from '../components/cards/cards.jsx';
2121
import {loadImageData} from '../lib/libraries/decks/translate-image.js';
22+
import {PLATFORM} from '../lib/platform.js';
2223

2324
class Cards extends React.Component {
2425
componentDidMount () {
@@ -40,7 +41,7 @@ class Cards extends React.Component {
4041

4142
Cards.propTypes = {
4243
locale: PropTypes.string.isRequired,
43-
platform: PropTypes.string
44+
platform: PropTypes.oneOf(Object.keys(PLATFORM))
4445
};
4546

4647
const mapStateToProps = state => ({

packages/scratch-gui/src/containers/gui.jsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,14 @@ import vmListenerHOC from '../lib/vm-listener-hoc.jsx';
3939
import vmManagerHOC from '../lib/vm-manager-hoc.jsx';
4040
import cloudManagerHOC from '../lib/cloud-manager-hoc.jsx';
4141
import systemPreferencesHOC from '../lib/system-preferences-hoc.jsx';
42+
import {PLATFORM} from '../lib/platform.js';
4243

4344
import GUIComponent from '../components/gui/gui.jsx';
44-
import {setIsScratchDesktop} from '../lib/isScratchDesktop.js';
4545
import {GUIStoragePropType} from '../gui-config';
4646
import {AccountMenuOptionsPropTypes} from '../lib/account-menu-options';
4747

4848
class GUI extends React.Component {
4949
componentDidMount () {
50-
setIsScratchDesktop(this.props.isScratchDesktop);
5150
this.props.onStorageInit(this.props.storage.scratchStorage);
5251
this.props.onVmInit(this.props.vm);
5352
this.props.storage.setProjectMetadata?.(this.props.projectId);
@@ -83,7 +82,6 @@ class GUI extends React.Component {
8382
cloudHost,
8483
error,
8584
isError,
86-
isScratchDesktop,
8785
isShowingProject,
8886
onProjectLoaded,
8987
onStorageInit,
@@ -122,8 +120,6 @@ GUI.propTypes = {
122120
intl: intlShape,
123121
isError: PropTypes.bool,
124122
isLoading: PropTypes.bool,
125-
// TODO: Use platform prop
126-
isScratchDesktop: PropTypes.bool,
127123
isShowingProject: PropTypes.bool,
128124
isTotallyNormal: PropTypes.bool,
129125
loadingStateVisible: PropTypes.bool,
@@ -132,7 +128,7 @@ GUI.propTypes = {
132128
onStorageInit: PropTypes.func,
133129
onUpdateProjectId: PropTypes.func,
134130
onVmInit: PropTypes.func,
135-
platform: PropTypes.string,
131+
platform: PropTypes.oneOf(Object.keys(PLATFORM)),
136132
setPlatform: PropTypes.func.isRequired,
137133
projectHost: PropTypes.string,
138134
projectId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
@@ -145,7 +141,6 @@ GUI.propTypes = {
145141
};
146142

147143
GUI.defaultProps = {
148-
isScratchDesktop: false,
149144
isTotallyNormal: false,
150145
onStorageInit: () => {},
151146
onProjectLoaded: () => {},

packages/scratch-gui/src/containers/tips-library.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import decksLibraryContent from '../lib/libraries/decks/index.jsx';
77
import tutorialTags from '../lib/libraries/tutorial-tags';
88

99
import analytics from '../lib/analytics';
10-
import {isScratchDesktop} from '../lib/isScratchDesktop';
10+
import {PLATFORM} from '../lib/platform.js';
1111

1212
import LibraryComponent from '../components/library/library.jsx';
1313

@@ -73,11 +73,11 @@ class TipsLibrary extends React.PureComponent {
7373
const isProjectTutorial = Object.prototype.hasOwnProperty.call(deck, 'requiredProjectId');
7474
const isVideoOnlyTutorial = decksLibraryContent[id].steps.filter(s => s.title).length === 0;
7575

76-
if (isProjectTutorial && (this.props.hideTutorialProjects || isScratchDesktop())) {
76+
if (isProjectTutorial && (this.props.hideTutorialProjects || this.props.platform === PLATFORM.DESKTOP)) {
7777
return false;
7878
}
7979

80-
if (isVideoOnlyTutorial && isScratchDesktop()) {
80+
if (isVideoOnlyTutorial && this.props.platform === PLATFORM.DESKTOP) {
8181
return false;
8282
}
8383

@@ -117,13 +117,15 @@ TipsLibrary.propTypes = {
117117
onActivateDeck: PropTypes.func.isRequired,
118118
onRequestClose: PropTypes.func,
119119
projectId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
120+
platform: PropTypes.oneOf(Object.keys(PLATFORM)),
120121
visible: PropTypes.bool,
121122
hideTutorialProjects: PropTypes.bool
122123
};
123124

124125
const mapStateToProps = state => ({
125126
visible: state.scratchGui.modals.tipsLibrary,
126-
projectId: state.scratchGui.projectState.projectId
127+
projectId: state.scratchGui.projectState.projectId,
128+
platform: state.scratchGui.platform.platform
127129
});
128130

129131
const mapDispatchToProps = dispatch => ({

packages/scratch-gui/src/lib/isScratchDesktop.js

Lines changed: 0 additions & 35 deletions
This file was deleted.

packages/scratch-gui/src/playground/render-gui-standalone.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {EditorState, createStandaloneRoot, setAppElement} from '../index-standalone';
22
import HashParserHOC from '../lib/hash-parser-hoc.jsx';
3+
import {PLATFORM} from '../lib/platform.js';
34

45
import log from '../lib/log.js';
56

@@ -60,7 +61,7 @@ export default appTarget => {
6061
if (simulateScratchDesktop) {
6162
gui.render({
6263
canEditTitle: true,
63-
isScratchDesktop: true,
64+
platform: PLATFORM.DESKTOP,
6465
showTelemetryModal: true,
6566
canSave: false,
6667
onTelemetryModalCancel: handleTelemetryModalCancel,

packages/scratch-gui/src/playground/render-gui.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import AppStateHOC from '../lib/app-state-hoc.jsx';
66
import GUI from '../containers/gui.jsx';
77
import HashParserHOC from '../lib/hash-parser-hoc.jsx';
88
import log from '../lib/log.js';
9+
import {PLATFORM} from '../lib/platform.js';
910

1011
const onClickLogo = () => {
1112
window.location = 'https://scratch.mit.edu';
@@ -66,7 +67,7 @@ export default appTarget => {
6667
simulateScratchDesktop ?
6768
<WrappedGui
6869
canEditTitle
69-
isScratchDesktop
70+
platform={PLATFORM.DESKTOP}
7071
showTelemetryModal
7172
canSave={false}
7273
onTelemetryModalCancel={handleTelemetryModalCancel}

0 commit comments

Comments
 (0)