2016-03-17 18:08:03 +09:00
|
|
|
import React, { PropTypes, Component } from 'react';
|
2016-03-25 10:45:28 +09:00
|
|
|
import { Alert } from 'react-bootstrap';
|
2016-03-17 18:08:03 +09:00
|
|
|
|
2016-05-22 15:23:30 +09:00
|
|
|
import { Messages } from "meteor/nova:core";
|
2016-02-23 13:10:08 +09:00
|
|
|
|
2016-03-17 18:08:03 +09:00
|
|
|
class Flash extends Component{
|
2016-02-23 13:10:08 +09:00
|
|
|
|
2016-03-27 17:30:28 +09:00
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.dismissFlash = this.dismissFlash.bind(this);
|
|
|
|
}
|
|
|
|
|
2016-02-23 13:10:08 +09:00
|
|
|
componentDidMount() {
|
2016-02-24 18:11:53 +09:00
|
|
|
Messages.markAsSeen(this.props.message._id);
|
2016-03-17 18:08:03 +09:00
|
|
|
}
|
2016-02-23 13:10:08 +09:00
|
|
|
|
2016-03-27 17:30:28 +09:00
|
|
|
dismissFlash(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
Messages.clear(this.props.message._id);
|
|
|
|
}
|
|
|
|
|
2016-02-23 13:10:08 +09:00
|
|
|
render() {
|
2016-03-25 10:45:28 +09:00
|
|
|
|
|
|
|
let type = this.props.message.type;
|
|
|
|
type = type === "error" ? "danger" : type; // if type is "error", use "danger" instead
|
|
|
|
|
2016-02-23 13:10:08 +09:00
|
|
|
return (
|
2016-03-27 17:30:28 +09:00
|
|
|
<Alert className="flash-message" bsStyle={type} onDismiss={this.dismissFlash}>
|
2016-03-25 10:45:28 +09:00
|
|
|
{this.props.message.content}
|
|
|
|
</Alert>
|
2016-02-23 13:10:08 +09:00
|
|
|
)
|
|
|
|
}
|
2016-03-17 18:08:03 +09:00
|
|
|
}
|
2016-02-23 13:10:08 +09:00
|
|
|
|
2016-03-27 17:30:28 +09:00
|
|
|
Flash.propTypes = {
|
|
|
|
message: React.PropTypes.object.isRequired
|
|
|
|
}
|
|
|
|
|
2016-02-23 13:10:08 +09:00
|
|
|
module.exports = Flash;
|