// The CreateProject component is a two-step wizard. // // The first step sets up basic project details, with the option of selecting // a depot location for the project. // // The second step is basically our user management view. var AppActions = require('../actions/AppActions'); var DepotTree = require('./DepotTree.jsx'); var Projects = require('../stores/Projects'); var React = require('react'); var ReactBootstrap = require('react-bootstrap'); var ButtonInput = ReactBootstrap.ButtonInput; var Col = ReactBootstrap.Col; var Grid = ReactBootstrap.Grid; var Input = ReactBootstrap.Input; var Panel = ReactBootstrap.Panel; var Row = ReactBootstrap.Row; var CreateProject = React.createClass({ getInitialState: function() { return { useDepot: false }; }, componentDidMount: function() { Projects.addProjectCreatedListener(this.handleProjectCreated); Projects.addProjectCreationFailedListener(this.handleProjectCreationFailed); }, componentWillUnmount: function() { Projects.removeProjectCreatedListener(this.handleProjectCreated); Projects.removeProjectCreationFailedListener(this.handleProjectCreationFailed); }, render: function() { var existingForm; if (this.state.useDepot) { existingForm = (
) } else { existingForm = (
); } return (

Create Project

{existingForm}
); }, handleFormSubmit: function(event) { // TODO we likely want to update local state and trigger validation instead // of passing values directly to the callback if (this.state.useDepot) { AppActions.createProject( this.refs.name.getValue(), this.refs.description.getValue(), "//" + this.state.depotDir.pathId.join('/') ); } else { AppActions.createProject( this.refs.name.getValue(), this.refs.description.getValue()); } event.stopPropagation(); event.preventDefault(); }, handleProjectCreated: function() { AppActions.changeLocation({ projectList: 'my' }); }, handleProjectCreationFailed: function() { alert('Oops, project creation failed!'); }, changeUseDepot: function() { this.setState({ useDepot: !this.state.useDepot }); }, depotDirSelected: function(dir) { this.setState({ depotDir: dir }); } }); module.exports = CreateProject;