Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/containers/tips-library.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,28 @@ class TipsLibrary extends React.PureComponent {
]);
}
handleItemSelect (item) {
analytics.event({
category: 'library',
action: 'Select How-to',
label: item.id
});

/*
Support tutorials that require specific starter projects.
If a tutorial declares "requiredProjectId", check that the URL contains
it. If it is not, open a new page with this tutorial and project id.

TODO remove this at first opportunity. If this is still here after HOC2018,
blame Eric R. Andrew is also on record saying "this is temporary".
UPDATE well now Paul is wrapped into this as well. Sigh...
eventually we will find a solution that doesn't involve loading a whole project
*/
if (item.requiredProjectId && window.location.href.indexOf(item.requiredProjectId) === -1) {
const urlParams = `?tutorial=${item.urlId}#${item.requiredProjectId}`;
return window.open(window.location.pathname + urlParams, '_blank');
if (item.requiredProjectId && (item.requiredProjectId !== this.props.projectId)) {
const urlParams = `/projects/${item.requiredProjectId}/editor?tutorial=${item.urlId}`;
return window.open(window.location.origin + urlParams, '_blank');
}

this.props.onActivateDeck(item.id);
analytics.event({
category: 'library',
action: 'Select How-to',
label: item.id
});
}
render () {
const decksLibraryThumbnailData = Object.keys(decksLibraryContent).map(id => ({
Expand Down Expand Up @@ -87,11 +90,13 @@ TipsLibrary.propTypes = {
intl: intlShape.isRequired,
onActivateDeck: PropTypes.func.isRequired,
onRequestClose: PropTypes.func,
projectId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
visible: PropTypes.bool
};

const mapStateToProps = state => ({
visible: state.scratchGui.modals.tipsLibrary
visible: state.scratchGui.modals.tipsLibrary,
projectId: state.scratchGui.projectState.projectId
});

const mapDispatchToProps = dispatch => ({
Expand Down