validate form input, add proj behind scenes;closes #109
This commit is contained in:
parent
af0201eb83
commit
de4129a2dd
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -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' });
|
||||
|
|
|
@ -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?
|
||||
|
|
Loading…
Reference in New Issue