mirror of
https://github.com/vale981/Vulcan
synced 2025-03-09 12:16:37 -04:00
40 lines
No EOL
858 B
JavaScript
40 lines
No EOL
858 B
JavaScript
import React, { PropTypes, Component } from 'react';
|
|
import { Alert } from 'react-bootstrap';
|
|
|
|
import Core from "meteor/nova:core";
|
|
const Messages = Core.Messages;
|
|
|
|
class Flash extends Component{
|
|
|
|
constructor() {
|
|
super();
|
|
this.dismissFlash = this.dismissFlash.bind(this);
|
|
}
|
|
|
|
componentDidMount() {
|
|
Messages.markAsSeen(this.props.message._id);
|
|
}
|
|
|
|
dismissFlash(e) {
|
|
e.preventDefault();
|
|
Messages.clear(this.props.message._id);
|
|
}
|
|
|
|
render() {
|
|
|
|
let type = this.props.message.type;
|
|
type = type === "error" ? "danger" : type; // if type is "error", use "danger" instead
|
|
|
|
return (
|
|
<Alert className="flash-message" bsStyle={type} onDismiss={this.dismissFlash}>
|
|
{this.props.message.content}
|
|
</Alert>
|
|
)
|
|
}
|
|
}
|
|
|
|
Flash.propTypes = {
|
|
message: React.PropTypes.object.isRequired
|
|
}
|
|
|
|
module.exports = Flash; |