Skip to content

Commit e27a05f

Browse files
Merge pull request #172 from fouksf/ipr-408-hide-tutorial-projects
feat: hide the tutorials that require a project
2 parents d672fc6 + a4918b5 commit e27a05f

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ const GUIComponent = props => {
130130
tipsLibraryVisible,
131131
username,
132132
userOwnsProject,
133+
hideTutorialProjects,
133134
vm,
134135
...componentProps
135136
} = omit(props, 'dispatch');
@@ -193,7 +194,7 @@ const GUIComponent = props => {
193194
<WebGlModal isRtl={isRtl} />
194195
)}
195196
{tipsLibraryVisible ? (
196-
<TipsLibrary />
197+
<TipsLibrary hideTutorialProjects={hideTutorialProjects} />
197198
) : null}
198199
{cardsVisible ? (
199200
<Cards />
@@ -455,6 +456,7 @@ GUIComponent.propTypes = {
455456
tipsLibraryVisible: PropTypes.bool,
456457
username: PropTypes.string,
457458
userOwnsProject: PropTypes.bool,
459+
hideTutorialProjects: PropTypes.bool,
458460
vm: PropTypes.instanceOf(VM).isRequired
459461
};
460462
GUIComponent.defaultProps = {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ GUI.propTypes = {
131131
telemetryModalVisible: PropTypes.bool,
132132
username: PropTypes.string,
133133
userOwnsProject: PropTypes.bool,
134+
hideTutorialProjects: PropTypes.bool,
134135
vm: PropTypes.instanceOf(VM).isRequired
135136
};
136137

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

Lines changed: 20 additions & 8 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 {notScratchDesktop} from '../lib/isScratchDesktop';
10+
import {isScratchDesktop} from '../lib/isScratchDesktop';
1111

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

@@ -63,13 +63,24 @@ class TipsLibrary extends React.PureComponent {
6363
render () {
6464
const decksLibraryThumbnailData = Object.keys(decksLibraryContent)
6565
.filter(id => {
66-
if (notScratchDesktop()) return true; // Do not filter anything in online editor
66+
/**
67+
* Scratch desktop can't support project and video-only tutorials.
68+
* NGP can't support project tutorials.
69+
* The online editor, conversely, should show all tutorials.
70+
*/
71+
6772
const deck = decksLibraryContent[id];
68-
// Scratch Desktop doesn't want tutorials with `requiredProjectId`
69-
if (Object.prototype.hasOwnProperty.call(deck, 'requiredProjectId')) return false;
70-
// Scratch Desktop should not load tutorials that are _only_ videos
71-
if (deck.steps.filter(s => s.title).length === 0) return false;
72-
// Allow any other tutorials
73+
const isProjectTutorial = Object.prototype.hasOwnProperty.call(deck, 'requiredProjectId');
74+
const isVideoOnlyTutorial = decksLibraryContent[id].steps.filter(s => s.title).length === 0;
75+
76+
if (isProjectTutorial && (this.props.hideTutorialProjects || isScratchDesktop())) {
77+
return false;
78+
}
79+
80+
if (isVideoOnlyTutorial && isScratchDesktop()) {
81+
return false;
82+
}
83+
7384
return true;
7485
})
7586
.map(id => ({
@@ -106,7 +117,8 @@ TipsLibrary.propTypes = {
106117
onActivateDeck: PropTypes.func.isRequired,
107118
onRequestClose: PropTypes.func,
108119
projectId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
109-
visible: PropTypes.bool
120+
visible: PropTypes.bool,
121+
hideTutorialProjects: PropTypes.bool
110122
};
111123

112124
const mapStateToProps = state => ({

0 commit comments

Comments
 (0)