Skip to content
Snippets Groups Projects
Commit 910d2b37 authored by Paul Kaplan's avatar Paul Kaplan
Browse files

Make the requiredProjectId work with the online editor

parent 9c736fa8
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,12 @@ 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
......@@ -42,18 +48,15 @@ class TipsLibrary extends React.PureComponent {
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}?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 => ({
......@@ -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 => ({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment