From f98919e69b358bf281b59e8541f36a989640812f Mon Sep 17 00:00:00 2001 From: Andrew Nicolaou Date: Mon, 9 Sep 2019 18:52:54 +0200 Subject: [PATCH] Logged in user can use "Add to collection" menu item --- client/components/Nav.jsx | 13 +++++++++++++ client/modules/IDE/pages/IDEView.jsx | 15 +++++++++++++++ client/routes.jsx | 1 + server/routes/server.routes.js | 24 ++++++++++++------------ 4 files changed, 41 insertions(+), 12 deletions(-) diff --git a/client/components/Nav.jsx b/client/components/Nav.jsx index e88c85da..51ed9664 100644 --- a/client/components/Nav.jsx +++ b/client/components/Nav.jsx @@ -326,6 +326,19 @@ class Nav extends React.PureComponent { Open } + {__process.env.UI_COLLECTIONS_ENABLED && + this.props.user.authenticated && + this.props.project.id && +
  • + + Add to Collection + +
  • } { __process.env.EXAMPLES_ENABLED &&
  • } + {this.props.location.pathname.match(/add-to-collection$/) && + + + + } {this.props.ide.shareModalVisible && ( + diff --git a/server/routes/server.routes.js b/server/routes/server.routes.js index eb428ce2..ddec0c22 100644 --- a/server/routes/server.routes.js +++ b/server/routes/server.routes.js @@ -27,12 +27,24 @@ router.get('/projects/:project_id', (req, res) => { )); }); +router.get('/:username/sketches/:project_id/add-to-collection', (req, res) => { + projectForUserExists(req.params.username, req.params.project_id, exists => ( + exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html)) + )); +}); + router.get('/:username/sketches/:project_id', (req, res) => { projectForUserExists(req.params.username, req.params.project_id, exists => ( exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html)) )); }); +router.get('/:username/sketches', (req, res) => { + userExists(req.params.username, exists => ( + exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html)) + )); +}); + router.get('/:username/full/:project_id', (req, res) => { projectForUserExists(req.params.username, req.params.project_id, exists => ( exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html)) @@ -106,12 +118,6 @@ router.get('/feedback', (req, res) => { res.send(renderIndex()); }); -router.get('/:username/sketches', (req, res) => { - userExists(req.params.username, exists => ( - exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html)) - )); -}); - router.get('/:username/collections/create', (req, res) => { userExists(req.params.username, (exists) => { const isLoggedInUser = req.user && req.user.username === req.params.username; @@ -128,12 +134,6 @@ router.get('/:username/collections/create', (req, res) => { )); }); -router.get('/:username/sketches/:project_id/add-to-collection', (req, res) => { - projectForUserExists(req.params.username, req.params.project_id, exists => ( - exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html)) - )); -}); - router.get('/:username/collections/:id', (req, res) => { collectionForUserExists(req.params.username, req.params.id, exists => ( exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html))