diff --git a/client/modules/IDE/pages/MobileIDEView.jsx b/client/modules/IDE/pages/MobileIDEView.jsx index 8b1e770d..b548ffe9 100644 --- a/client/modules/IDE/pages/MobileIDEView.jsx +++ b/client/modules/IDE/pages/MobileIDEView.jsx @@ -46,13 +46,6 @@ const NavItem = styled.li` position: relative; `; -const headerNavOptions = [ - { icon: PreferencesIcon, title: 'Preferences', href: '/mobile/preferences', }, - { icon: PreferencesIcon, title: 'Examples', href: '/mobile/p5/sketches' }, - { icon: PreferencesIcon, title: 'Original Editor', href: '/', }, -]; - - const MobileIDEView = (props) => { const { preferences, @@ -75,12 +68,27 @@ const MobileIDEView = (props) => { showRuntimeErrorWarning, hideRuntimeErrorWarning, startSketch, + user } = props; const [tmController, setTmController] = useState(null); // eslint-disable-line + const { username } = user; + const navOptionsLoggedIn = [ + { icon: PreferencesIcon, title: 'Preferences', href: '/mobile/preferences', }, + { icon: PreferencesIcon, title: 'My Stuff', href: `/mobile/${username}/sketches` }, + { icon: PreferencesIcon, title: 'Examples', href: '/mobile/p5/sketches' }, + { icon: PreferencesIcon, title: 'Original Editor', href: '/', }, + ]; - const [triggerNavDropdown, NavDropDown] = useAsModal(); + const navOptionsLoggedOut = [ + { icon: PreferencesIcon, title: 'Preferences', href: '/mobile/preferences', }, + { icon: PreferencesIcon, title: 'Examples', href: '/mobile/p5/sketches' }, + { icon: PreferencesIcon, title: 'Original Editor', href: '/', }, + ]; + + + const [triggerNavDropdown, NavDropDown] = useAsModal(); return ( diff --git a/client/routes.jsx b/client/routes.jsx index 4aba9a81..ed72bcf7 100644 --- a/client/routes.jsx +++ b/client/routes.jsx @@ -58,13 +58,18 @@ const routes = store => ( - - + + + + + + + ); diff --git a/server/routes/server.routes.js b/server/routes/server.routes.js index 247d80b1..8d90fc45 100644 --- a/server/routes/server.routes.js +++ b/server/routes/server.routes.js @@ -162,6 +162,44 @@ if (process.env.MOBILE_ENABLED) { exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html)) )); }); + + router.get('/mobile/:username/assets', (req, res) => { + userExists(req.params.username, (exists) => { + const isLoggedInUser = req.user && req.user.username === req.params.username; + const canAccess = exists && isLoggedInUser; + return canAccess ? + 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; + const canAccess = exists && isLoggedInUser; + return canAccess ? + res.send(renderIndex()) : + get404Sketch(html => res.send(html)); + }); + }); + + router.get('/:username/collections/create', (req, res) => { + userExists(req.params.username, 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)) + )); + }); + + router.get('/:username/collections', (req, res) => { + userExists(req.params.username, exists => ( + exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html)) + )); + }); } export default router;