Skip to content

Commit 2e7fbe0

Browse files
authored
Merge pull request #1819 from Ajaya1000/bug/create-new-collection-popop-fixing
[#1804] create new collection pop-up fixing
2 parents 5e0af56 + 73236af commit 2e7fbe0

File tree

3 files changed

+11
-29
lines changed

3 files changed

+11
-29
lines changed

Diff for: client/modules/User/pages/DashboardView.jsx

+11-10
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ class DashboardView extends React.Component {
3030
super(props);
3131
this.closeAccountPage = this.closeAccountPage.bind(this);
3232
this.gotoHomePage = this.gotoHomePage.bind(this);
33+
this.toggleCollectionCreate = this.toggleCollectionCreate.bind(this);
34+
this.state = {
35+
collectionCreateVisible: false
36+
};
3337
}
3438

3539
componentDidMount() {
@@ -68,15 +72,12 @@ class DashboardView extends React.Component {
6872
return this.props.user.username === this.props.params.username;
6973
}
7074

71-
isCollectionCreate() {
72-
const path = this.props.location.pathname;
73-
return /collections\/create$/.test(path);
75+
toggleCollectionCreate() {
76+
this.setState((prevState) => ({
77+
collectionCreateVisible: !prevState.collectionCreateVisible
78+
}));
7479
}
7580

76-
returnToDashboard = () => {
77-
browserHistory.push(`/${this.ownerName()}/collections`);
78-
};
79-
8081
renderActionButton(tabKey, username, t) {
8182
switch (tabKey) {
8283
case TabKey.assets:
@@ -85,7 +86,7 @@ class DashboardView extends React.Component {
8586
return (
8687
this.isOwner() && (
8788
<React.Fragment>
88-
<Button to={`/${username}/collections/create`}>
89+
<Button onClick={this.toggleCollectionCreate}>
8990
{t('DashboardView.CreateCollection')}
9091
</Button>
9192
<CollectionSearchbar />
@@ -148,10 +149,10 @@ class DashboardView extends React.Component {
148149
{this.renderContent(currentTab, username)}
149150
</div>
150151
</main>
151-
{this.isCollectionCreate() && (
152+
{this.state.collectionCreateVisible && (
152153
<Overlay
153154
title={this.props.t('DashboardView.CreateCollectionOverlay')}
154-
closeOverlay={this.returnToDashboard}
155+
closeOverlay={this.toggleCollectionCreate}
155156
>
156157
<CollectionCreate />
157158
</Overlay>

Diff for: client/routes.jsx

-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ const routes = (store) => (
9898
path="/:username/collections"
9999
component={mobileFirst(MobileDashboardView, DashboardView)}
100100
/>
101-
102-
<Route path="/:username/collections/create" component={DashboardView} />
103101
<Route
104102
path="/:username/collections/:collection_id"
105103
component={CollectionView}

Diff for: server/routes/server.routes.js

-17
Original file line numberDiff line numberDiff line change
@@ -121,23 +121,6 @@ router.get('/about', (req, res) => {
121121
res.send(renderIndex());
122122
});
123123

124-
router.get('/:username/collections/create', (req, res) => {
125-
userExists(req.params.username, (exists) => {
126-
const isLoggedInUser =
127-
req.user && req.user.username === req.params.username;
128-
const canAccess = exists && isLoggedInUser;
129-
return canAccess
130-
? res.send(renderIndex())
131-
: get404Sketch((html) => res.send(html));
132-
});
133-
});
134-
135-
router.get('/:username/collections/create', (req, res) => {
136-
userExists(req.params.username, (exists) =>
137-
exists ? res.send(renderIndex()) : get404Sketch((html) => res.send(html))
138-
);
139-
});
140-
141124
router.get('/:username/collections/:id', (req, res) => {
142125
collectionForUserExists(req.params.username, req.params.id, (exists) =>
143126
exists ? res.send(renderIndex()) : get404Sketch((html) => res.send(html))

0 commit comments

Comments
 (0)