Skip to content

[#1804] create new collection pop-up fixing #1819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions client/modules/User/pages/DashboardView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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:
Expand All @@ -85,7 +86,7 @@ class DashboardView extends React.Component {
return (
this.isOwner() && (
<React.Fragment>
<Button to={`/${username}/collections/create`}>
<Button onClick={this.toggleCollectionCreate}>
{t('DashboardView.CreateCollection')}
</Button>
<CollectionSearchbar />
Expand Down Expand Up @@ -148,10 +149,10 @@ class DashboardView extends React.Component {
{this.renderContent(currentTab, username)}
</div>
</main>
{this.isCollectionCreate() && (
{this.state.collectionCreateVisible && (
<Overlay
title={this.props.t('DashboardView.CreateCollectionOverlay')}
closeOverlay={this.returnToDashboard}
closeOverlay={this.toggleCollectionCreate}
>
<CollectionCreate />
</Overlay>
Expand Down
2 changes: 0 additions & 2 deletions client/routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ const routes = (store) => (
path="/:username/collections"
component={mobileFirst(MobileDashboardView, DashboardView)}
/>

<Route path="/:username/collections/create" component={DashboardView} />
<Route
path="/:username/collections/:collection_id"
component={CollectionView}
Expand Down
17 changes: 0 additions & 17 deletions server/routes/server.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,23 +121,6 @@ router.get('/about', (req, res) => {
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))
Expand Down