11require ( './ProjectsToolBar.scss' )
22
33import React , { PropTypes , Component } from 'react'
4+ import { Link } from 'react-router'
45import { connect } from 'react-redux'
56import cn from 'classnames'
67import _ from 'lodash'
7- import Modal from 'react-modal'
88import { SearchBar } from 'appirio-tech-react-components'
99import Filters from './Filters'
1010
11- import ModalControl from '../ModalControl'
12- import SVGIconImage from '../SVGIconImage'
13- import CoderBot from '../CoderBot/CoderBot'
14- import ProjectWizard from '../../projects/create/components/ProjectWizard'
15-
16- import { createProjectWithStatus as createProjectAction } from '../../projects/actions/project'
1711import { projectSuggestions , loadProjects } from '../../projects/actions/loadProjects'
1812import {
1913 ROLE_CONNECT_COPILOT ,
2014 ROLE_CONNECT_MANAGER ,
21- ROLE_ADMINISTRATOR ,
22- PROJECT_STATUS_IN_REVIEW
15+ ROLE_ADMINISTRATOR
2316} from '../../config/constants'
2417
2518
@@ -28,18 +21,14 @@ class ProjectsToolBar extends Component {
2821 constructor ( props ) {
2922 super ( props )
3023 this . state = {
31- isCreateProjectModalVisible : false ,
3224 errorCreatingProject : false ,
3325 isFilterVisible : false
3426 }
3527 this . applyFilters = this . applyFilters . bind ( this )
3628 this . toggleFilter = this . toggleFilter . bind ( this )
37- this . showCreateProjectDialog = this . showCreateProjectDialog . bind ( this )
38- this . hideCreateProjectDialog = this . hideCreateProjectDialog . bind ( this )
3929 this . handleTermChange = this . handleTermChange . bind ( this )
4030 this . handleSearch = this . handleSearch . bind ( this )
4131 this . handleMyProjectsFilter = this . handleMyProjectsFilter . bind ( this )
42- this . createProject = this . createProject . bind ( this )
4332 this . onLeave = this . onLeave . bind ( this )
4433 }
4534
@@ -51,7 +40,6 @@ class ProjectsToolBar extends Component {
5140 this . setState ( {
5241 isProjectDirty : false
5342 } , ( ) => {
54- this . hideCreateProjectDialog ( )
5543 this . props . router . push ( '/projects/' + nextProps . project . id )
5644 } )
5745 } else {
@@ -103,26 +91,6 @@ class ProjectsToolBar extends Component {
10391 this . applyFilters ( { memberOnly : event . target . checked } )
10492 }
10593
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-
12694 applyFilters ( filter ) {
12795 const criteria = _ . assign ( { } , this . props . criteria , filter )
12896 if ( criteria && criteria . keyword ) {
@@ -155,62 +123,27 @@ class ProjectsToolBar extends Component {
155123 this . props . loadProjects ( criteria , page )
156124 }
157125
158- createProject ( project ) {
159- this . props . createProjectAction ( project , PROJECT_STATUS_IN_REVIEW )
160- }
161-
162126 shouldComponentUpdate ( nextProps , nextState ) {
163127 const { user, criteria, creatingProject, projectCreationError, searchTermTag } = this . props
164- const { isCreateProjectModalVisible , errorCreatingProject, isFilterVisible } = this . state
128+ const { errorCreatingProject, isFilterVisible } = this . state
165129 return nextProps . user . handle !== user . handle
166130 || JSON . stringify ( nextProps . criteria ) !== JSON . stringify ( criteria )
167131 || nextProps . creatingProject !== creatingProject
168132 || nextProps . projectCreationError !== projectCreationError
169133 || nextProps . searchTermTag !== searchTermTag
170- || nextState . isCreateProjectModalVisible !== isCreateProjectModalVisible
171134 || nextState . errorCreatingProject !== errorCreatingProject
172135 || nextState . isFilterVisible !== isFilterVisible
173136 }
174137
175138 render ( ) {
176139 const { logo, userMenu, userRoles, criteria, isPowerUser } = this . props
177- const { isCreateProjectModalVisible , errorCreatingProject , isFilterVisible } = this . state
140+ const { isFilterVisible } = this . state
178141 const isLoggedIn = userRoles && userRoles . length
179142
180143 const noOfFilters = _ . keys ( criteria ) . length - 1 // -1 for default sort criteria
181144
182145 return (
183146 < 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 >
214147 < div className = "primary-toolbar" >
215148 { logo }
216149 {
@@ -240,7 +173,7 @@ class ProjectsToolBar extends Component {
240173 {
241174 ! ! isLoggedIn &&
242175 < div >
243- < a onClick = { this . showCreateProjectDialog } href = "javascript: " className = "tc-btn tc-btn-sm tc-btn-primary" > + New Project</ a >
176+ < Link to = "/new-project " className = "tc-btn tc-btn-sm tc-btn-primary" > + New Project</ Link >
244177 </ div >
245178 }
246179 { userMenu }
@@ -289,6 +222,6 @@ const mapStateToProps = ({ projectSearchSuggestions, searchTerm, projectSearch,
289222 }
290223}
291224
292- const actionsToBind = { projectSuggestions, loadProjects, createProjectAction }
225+ const actionsToBind = { projectSuggestions, loadProjects }
293226
294227export default connect ( mapStateToProps , actionsToBind ) ( ProjectsToolBar )
0 commit comments