Skip to content

Commit 3feb4a7

Browse files
author
Vikas Agarwal
committed
Github issue#1267, Navigation small updates
— new project return target should be project page (starting point) on Exit/Cancel
1 parent 218d189 commit 3feb4a7

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

src/components/TopBar/NewProjectNavLink.jsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@ import { Link } from 'react-router-dom'
33
import SVGIconImage from '../SVGIconImage'
44
import './NewProjectNavLink.scss'
55

6-
const NewProjectNavLink = ({ compact=false }) => {
6+
const NewProjectNavLink = ({ compact=false, returnUrl }) => {
77
if (compact) {
88
return (
9-
<Link to="/new-project" className="new-project-link">
9+
<Link to={{
10+
pathname: '/new-project',
11+
search: returnUrl ? '?returnUrl=' + returnUrl : ''
12+
}} className="new-project-link">
1013
<div className="new-project-icon"><SVGIconImage filePath="ui-16px-1_bold-add" /></div>
1114
</Link>
1215
)
1316
} else {
1417
return (
1518
<div className="new-project-link">
16-
<Link to="/new-project" className="tc-btn tc-btn-sm tc-btn-primary">+ New Project</Link>
19+
<Link to={{
20+
pathname: '/new-project',
21+
search: returnUrl ? '?returnUrl=' + returnUrl : '',
22+
}} className="tc-btn tc-btn-sm tc-btn-primary">+ New Project</Link>
1723
</div>
1824
)
1925
}

src/components/TopBar/ProjectToolBar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class ProjectToolBar extends React.Component {
7171
}
7272
</ul>
7373
</nav>}
74-
<NewProjectNavLink compact />
74+
<NewProjectNavLink compact returnUrl={window.location.href} />
7575
{ userMenu }
7676
</div>
7777
</div>

src/projects/create/containers/CreateContainer.jsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import _ from 'lodash'
22
import Cookies from 'js-cookie'
3+
import qs from 'query-string'
34
import React, { PropTypes } from 'react'
45
import { withRouter } from 'react-router-dom'
56
import { connect } from 'react-redux'
@@ -178,16 +179,21 @@ class CreateConainer extends React.Component {
178179
}
179180

180181
closeWizard() {
181-
const { userRoles } = this.props
182+
const { userRoles, location } = this.props
182183
const isLoggedIn = userRoles && userRoles.length > 0
183184
// calls leave handler
184185
this.onLeave()
185-
if (isLoggedIn) {
186-
this.props.history.push('/projects')
186+
const returnUrl = _.get(qs.parse(location.search), 'returnUrl', null)
187+
if (returnUrl) {
188+
window.location = returnUrl
187189
} else {
188-
// this.props.history.push('/')
189-
// FIXME ideally we should push on router
190-
window.location = window.location.origin
190+
if (isLoggedIn) {
191+
this.props.history.push('/projects')
192+
} else {
193+
this.props.history.push('/')
194+
// FIXME ideally we should push on router
195+
// window.location = window.location.origin
196+
}
191197
}
192198
}
193199

0 commit comments

Comments
 (0)