1
0
mirror of https://github.com/stolksdorf/homebrewery.git synced 2025-12-25 15:51:33 +00:00

new error ahndler nearly done

This commit is contained in:
Scott Tolksdorf
2016-05-19 08:35:37 -04:00
parent e7f1083edb
commit 52ff2e41e6
2 changed files with 45 additions and 8 deletions

View File

@@ -107,7 +107,8 @@ var EditPage = React.createClass({
save : function(){ save : function(){
this.debounceSave.cancel(); this.debounceSave.cancel();
this.setState({ this.setState({
isSaving : true isSaving : true,
errors : null
}); });
request request
@@ -117,17 +118,35 @@ var EditPage = React.createClass({
title : this.state.title title : this.state.title
}) })
.end((err, res) => { .end((err, res) => {
this.savedBrew = res.body; if(err){
this.setState({ this.setState({
isPending : false, errors : err,
isSaving : false, })
errors : err, }else{
lastUpdated : res.body.updatedAt this.savedBrew = res.body;
}) this.setState({
isPending : false,
isSaving : false,
lastUpdated : res.body.updatedAt
})
}
}) })
}, },
renderSaveButton : function(){ renderSaveButton : function(){
//if(this.state.errors){
return <Nav.item className='save error' icon="fa-warning">
Oops!
<div className='errorContainer'>
Looks like there was a problem saving. <br />
Report the issue <a target='_blank' href={'https://github.com/stolksdorf/naturalcrit/issues/new?body='+
encodeURIComponent(JSON.stringify(this.state.errors, null, ' '))}>
here
</a>.
</div>
</Nav.item>
//}
if(this.state.isSaving){ if(this.state.isSaving){
return <Nav.item className='save' icon="fa-spinner fa-spin">saving...</Nav.item> return <Nav.item className='save' icon="fa-spinner fa-spin">saving...</Nav.item>
} }

View File

@@ -7,6 +7,24 @@
color : #666; color : #666;
cursor : initial; cursor : initial;
} }
&.error{
position: relative;
background-color: @red;
.errorContainer{
position: absolute;
top: 29px;
background-color: #333;
padding: 8px;
width: 120px;
left: -20px;
z-index: 1000;
a{
color : @teal;
}
}
}
} }
} }