From 319e326e007da47a6a05f4874ad9b70cb1001038 Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum <eric.rosenbaum@gmail.com> Date: Thu, 25 Oct 2018 16:42:58 -0400 Subject: [PATCH] Hack to load starter project for CN tutorial --- src/containers/tips-library.jsx | 17 ++++++++++++++++- src/lib/libraries/decks/index.jsx | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/containers/tips-library.jsx b/src/containers/tips-library.jsx index 09e34f7fa..7b2771364 100644 --- a/src/containers/tips-library.jsx +++ b/src/containers/tips-library.jsx @@ -35,6 +35,19 @@ class TipsLibrary extends React.PureComponent { ]); } handleItemSelect (item) { + /* + 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". + */ + 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'); + } + this.props.onActivateDeck(item.id); analytics.event({ category: 'library', @@ -48,7 +61,9 @@ class TipsLibrary extends React.PureComponent { id: id, name: decksLibraryContent[id].name, featured: true, - tags: decksLibraryContent[id].tags + tags: decksLibraryContent[id].tags, + urlId: decksLibraryContent[id].urlId, + requiredProjectId: decksLibraryContent[id].requiredProjectId })); if (!this.props.visible) return null; diff --git a/src/lib/libraries/decks/index.jsx b/src/lib/libraries/decks/index.jsx index 65242b170..f44f5fcb2 100644 --- a/src/lib/libraries/decks/index.jsx +++ b/src/lib/libraries/decks/index.jsx @@ -248,6 +248,7 @@ export default { id="gui.howtos.cartoon-network" /> ), + requiredProjectId: '249143200', img: libraryCartoonNetwork, steps: [{ video: 'uz5oz5h9yg' -- GitLab