validate form input, add proj behind scenes;closes #109

This commit is contained in:
Radek Stepan 2016-01-30 12:37:55 +01:00
parent af0201eb83
commit de4129a2dd
4 changed files with 28 additions and 20 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -38,7 +38,11 @@ export default React.createClass({
// Add the project.
_onAdd() {
let [ owner, name ] = this.state.val.split('/');
let val = this.state.val;
// Validate input.
if (!/^[^\s\/]+\/[^\s\/]+$/.test(val)) return;
let [ owner, name ] = val.split('/');
actions.emit('projects.add', { owner, name });
// Redirect to the dashboard.
App.navigate({ 'to': 'projects' });

View File

@ -365,8 +365,8 @@ class ProjectsStore extends Store {
if ((idx = this.findIndex(project)) > -1) {
this.push(`list.${idx}.errors`, err);
} else {
// We are supposed to exist already.
throw 500;
// Create the stub project behind the scenes.
this.push('list', _.extend({}, project, { 'errors': [ err ] }));
}
// Notify?