Skip to content

Commit 60a7a0a

Browse files
author
Vikas Agarwal
committed
Github issue#1234, Functions of the "Connect Logo", "Back", "Esc" buttons in logged in and logged out states
Github issue#1035, URL does not change when selecting project from "New Project" page — Removed modal view of create project wizard for logged in user.
1 parent c71006c commit 60a7a0a

File tree

2 files changed

+18
-68
lines changed

2 files changed

+18
-68
lines changed

src/components/TopBar/ProjectsToolBar.js

Lines changed: 5 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
require('./ProjectsToolBar.scss')
22

33
import React, {PropTypes, Component} from 'react'
4+
import { Link } from 'react-router'
45
import { connect } from 'react-redux'
56
import cn from 'classnames'
67
import _ from 'lodash'
7-
import Modal from 'react-modal'
88
import { SearchBar } from 'appirio-tech-react-components'
99
import Filters from './Filters'
1010

11-
import ModalControl from '../ModalControl'
1211
import SVGIconImage from '../SVGIconImage'
1312
import CoderBot from '../CoderBot/CoderBot'
14-
import ProjectWizard from '../../projects/create/components/ProjectWizard'
1513

16-
import { createProjectWithStatus as createProjectAction } from '../../projects/actions/project'
1714
import { projectSuggestions, loadProjects } from '../../projects/actions/loadProjects'
1815
import {
1916
ROLE_CONNECT_COPILOT,
@@ -28,18 +25,14 @@ class ProjectsToolBar extends Component {
2825
constructor(props) {
2926
super(props)
3027
this.state = {
31-
isCreateProjectModalVisible : false,
3228
errorCreatingProject: false,
3329
isFilterVisible: false
3430
}
3531
this.applyFilters = this.applyFilters.bind(this)
3632
this.toggleFilter = this.toggleFilter.bind(this)
37-
this.showCreateProjectDialog = this.showCreateProjectDialog.bind(this)
38-
this.hideCreateProjectDialog = this.hideCreateProjectDialog.bind(this)
3933
this.handleTermChange = this.handleTermChange.bind(this)
4034
this.handleSearch = this.handleSearch.bind(this)
4135
this.handleMyProjectsFilter = this.handleMyProjectsFilter.bind(this)
42-
this.createProject = this.createProject.bind(this)
4336
this.onLeave = this.onLeave.bind(this)
4437
}
4538

@@ -51,7 +44,6 @@ class ProjectsToolBar extends Component {
5144
this.setState({
5245
isProjectDirty : false
5346
}, () => {
54-
this.hideCreateProjectDialog()
5547
this.props.router.push('/projects/' + nextProps.project.id)
5648
})
5749
} else {
@@ -103,26 +95,6 @@ class ProjectsToolBar extends Component {
10395
this.applyFilters({memberOnly: event.target.checked})
10496
}
10597

106-
showCreateProjectDialog() {
107-
this.setState({
108-
isCreateProjectModalVisible : true
109-
})
110-
}
111-
112-
hideCreateProjectDialog() {
113-
let confirm = true
114-
if (this.state.isProjectDirty) {
115-
confirm = window.confirm('You have unsaved changes. Are you sure you want to leave?')
116-
}
117-
if (confirm === true) {
118-
this.setState({
119-
isProjectDirty: false,
120-
isCreateProjectModalVisible : false,
121-
errorCreatingProject: false
122-
})
123-
}
124-
}
125-
12698
applyFilters(filter) {
12799
const criteria = _.assign({}, this.props.criteria, filter)
128100
if (criteria && criteria.keyword) {
@@ -155,62 +127,27 @@ class ProjectsToolBar extends Component {
155127
this.props.loadProjects(criteria, page)
156128
}
157129

158-
createProject(project) {
159-
this.props.createProjectAction(project, PROJECT_STATUS_IN_REVIEW)
160-
}
161-
162130
shouldComponentUpdate(nextProps, nextState) {
163131
const { user, criteria, creatingProject, projectCreationError, searchTermTag } = this.props
164-
const { isCreateProjectModalVisible, errorCreatingProject, isFilterVisible } = this.state
132+
const { errorCreatingProject, isFilterVisible } = this.state
165133
return nextProps.user.handle !== user.handle
166134
|| JSON.stringify(nextProps.criteria) !== JSON.stringify(criteria)
167135
|| nextProps.creatingProject !== creatingProject
168136
|| nextProps.projectCreationError !== projectCreationError
169137
|| nextProps.searchTermTag !== searchTermTag
170-
|| nextState.isCreateProjectModalVisible !== isCreateProjectModalVisible
171138
|| nextState.errorCreatingProject !== errorCreatingProject
172139
|| nextState.isFilterVisible !== isFilterVisible
173140
}
174141

175142
render() {
176143
const { logo, userMenu, userRoles, criteria, isPowerUser } = this.props
177-
const { isCreateProjectModalVisible, errorCreatingProject, isFilterVisible } = this.state
144+
const { errorCreatingProject, isFilterVisible } = this.state
178145
const isLoggedIn = userRoles && userRoles.length
179146

180147
const noOfFilters = _.keys(criteria).length - 1 // -1 for default sort criteria
181148

182149
return (
183150
<div className="ProjectsToolBar">
184-
<Modal
185-
isOpen={ isCreateProjectModalVisible }
186-
className="project-creation-dialog"
187-
overlayClassName="project-creation-dialog-overlay"
188-
onRequestClose={ this.hideCreateProjectDialog }
189-
contentLabel=""
190-
>
191-
<ModalControl
192-
className="escape-button"
193-
icon={<SVGIconImage filePath="x-mark" />}
194-
label="esc"
195-
onClick={ this.hideCreateProjectDialog }
196-
/>
197-
{ !errorCreatingProject &&
198-
<ProjectWizard
199-
showModal={ false }
200-
processing={ this.props.creatingProject }
201-
createProject={ this.createProject }
202-
closeModal={ this.hideCreateProjectDialog }
203-
userRoles={ userRoles }
204-
onProjectUpdate={ (updatedProject, dirty=true) => {
205-
this.setState({
206-
isProjectDirty: dirty
207-
})
208-
}
209-
}
210-
/>
211-
}
212-
{ errorCreatingProject && <CoderBot code={ 500 } message="Unable to create project" />}
213-
</Modal>
214151
<div className="primary-toolbar">
215152
{ logo }
216153
{
@@ -240,7 +177,7 @@ class ProjectsToolBar extends Component {
240177
{
241178
!!isLoggedIn &&
242179
<div>
243-
<a onClick={ this.showCreateProjectDialog } href="javascript:" className="tc-btn tc-btn-sm tc-btn-primary">+ New Project</a>
180+
<Link to="/new-project" className="tc-btn tc-btn-sm tc-btn-primary">+ New Project</Link>
244181
</div>
245182
}
246183
{ userMenu }
@@ -289,6 +226,6 @@ const mapStateToProps = ({ projectSearchSuggestions, searchTerm, projectSearch,
289226
}
290227
}
291228

292-
const actionsToBind = { projectSuggestions, loadProjects, createProjectAction }
229+
const actionsToBind = { projectSuggestions, loadProjects }
293230

294231
export default connect(mapStateToProps, actionsToBind)(ProjectsToolBar)

src/projects/create/containers/CreateContainer.jsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class CreateConainer extends React.Component {
5858
}
5959
this.createProject = this.createProject.bind(this)
6060
this.onLeave = this.onLeave.bind(this)
61+
this.closeWizard = this.closeWizard.bind(this)
6162
}
6263

6364
componentWillReceiveProps(nextProps) {
@@ -139,12 +140,24 @@ class CreateConainer extends React.Component {
139140
})
140141
}
141142

143+
closeWizard() {
144+
const { userRoles } = this.props
145+
const isLoggedIn = userRoles && userRoles.length > 0
146+
if (isLoggedIn) {
147+
this.props.router.push("/projects")
148+
} else {
149+
this.props.router.push("/")
150+
}
151+
}
152+
142153
render() {
143154
return (
144155
<EnhancedCreateView
145156
{...this.props}
146157
createProject={ this.createProject }
147158
processing={ this.state.creatingProject }
159+
showModal={true}
160+
closeModal={ this.closeWizard }
148161
onStepChange={ (wizardStep, updatedProject) => {
149162
// type of the project
150163
let projectType = _.get(updatedProject, 'type', null)

0 commit comments

Comments
 (0)