Implement auto-saving

This commit is contained in:
Yuya Ochiai
2017-02-15 22:07:10 +09:00
parent 90623bcf84
commit 3447d49cbd
4 changed files with 125 additions and 29 deletions

View File

@@ -0,0 +1,33 @@
const React = require('react');
const {Alert} = require('react-bootstrap');
function AutoSaveIndicator(props) {
const {savingState, errorMessage, ...rest} = props;
return (
<Alert
className='AutoSaveIndicator'
{...rest}
bsStyle={props.savingState === 'error' ? 'danger' : 'info'}
>
{(() => {
switch (props.savingState) {
case 'saving':
return 'Saving...';
case 'saved':
return 'Saved!';
case 'error':
return props.errorMessage;
default:
return '';
}
})()}
</Alert>
);
}
AutoSaveIndicator.propTypes = {
savingState: React.PropTypes.string.isRequired,
errorMessage: React.PropTypes.string
};
module.exports = AutoSaveIndicator;