diff --git a/client/modules/User/pages/DashboardView.jsx b/client/modules/User/pages/DashboardView.jsx index 3c7cddc178..d0a6c6fde0 100644 --- a/client/modules/User/pages/DashboardView.jsx +++ b/client/modules/User/pages/DashboardView.jsx @@ -30,6 +30,10 @@ class DashboardView extends React.Component { super(props); this.closeAccountPage = this.closeAccountPage.bind(this); this.gotoHomePage = this.gotoHomePage.bind(this); + this.toggleCollectionCreate = this.toggleCollectionCreate.bind(this); + this.state = { + collectionCreateVisible: false + }; } componentDidMount() { @@ -68,15 +72,12 @@ class DashboardView extends React.Component { return this.props.user.username === this.props.params.username; } - isCollectionCreate() { - const path = this.props.location.pathname; - return /collections\/create$/.test(path); + toggleCollectionCreate() { + this.setState((prevState) => ({ + collectionCreateVisible: !prevState.collectionCreateVisible + })); } - returnToDashboard = () => { - browserHistory.push(`/${this.ownerName()}/collections`); - }; - renderActionButton(tabKey, username, t) { switch (tabKey) { case TabKey.assets: @@ -85,7 +86,7 @@ class DashboardView extends React.Component { return ( this.isOwner() && ( - @@ -148,10 +149,10 @@ class DashboardView extends React.Component { {this.renderContent(currentTab, username)} - {this.isCollectionCreate() && ( + {this.state.collectionCreateVisible && ( diff --git a/client/routes.jsx b/client/routes.jsx index 321cd786c8..d405c0c7e4 100644 --- a/client/routes.jsx +++ b/client/routes.jsx @@ -98,8 +98,6 @@ const routes = (store) => ( path="/:username/collections" component={mobileFirst(MobileDashboardView, DashboardView)} /> - - { res.send(renderIndex()); }); -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))