diff --git a/src/containers/tips-library.jsx b/src/containers/tips-library.jsx index 5727e19d12024565b181bc2e445a35fa855bef14..ced2f6aa041c6fa08310080f288308b5de725d56 100644 --- a/src/containers/tips-library.jsx +++ b/src/containers/tips-library.jsx @@ -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 => ({