🚧 add link to MyStuff when user is logged in
This commit is contained in:
parent
bf67451474
commit
42b002595b
3 changed files with 61 additions and 10 deletions
|
@ -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(<Dropdown right items={headerNavOptions} />);
|
||||
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(<Dropdown right items={username ? navOptionsLoggedIn : navOptionsLoggedOut} />);
|
||||
|
||||
return (
|
||||
<Screen fullscreen>
|
||||
|
|
|
@ -58,13 +58,18 @@ const routes = store => (
|
|||
<Route path="/:username/collections/:collection_id" component={CollectionView} />
|
||||
<Route path="/about" component={IDEView} />
|
||||
|
||||
<Route path="/mobile/:username/sketches/:project_id" component={MobileIDEView} />
|
||||
|
||||
<Route path="/mobile/:username/sketches" component={MobileDashboard} />
|
||||
<Route path="/mobile/preview" component={MobileSketchView} />
|
||||
<Route path="/mobile/preferences" component={MobilePreferences} />
|
||||
<Route path="/mobile" component={MobileIDEView} />
|
||||
|
||||
<Route path="/mobile/:username/sketches" component={MobileDashboard} />
|
||||
<Route path="/mobile/:username/sketches/:project_id" component={MobileIDEView} />
|
||||
<Route path="/mobile/:username/assets" component={userIsAuthenticated(userIsAuthorized(MobileDashboard))} />
|
||||
<Route path="/mobile/:username/collections" component={MobileDashboard} />
|
||||
<Route path="/mobile/:username/collections/create" component={MobileDashboard} />
|
||||
<Route path="/mobile/:username/collections/:collection_id" component={CollectionView} />
|
||||
|
||||
</Route>
|
||||
);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue