mirror of
https://github.com/vale981/Vulcan
synced 2025-03-10 12:36:39 -04:00
38 lines
No EOL
894 B
JavaScript
38 lines
No EOL
894 B
JavaScript
import { registerComponent } from 'meteor/vulcan:core';
|
|
import React, { PropTypes, Component } from 'react';
|
|
import { Alert } from 'react-bootstrap';
|
|
|
|
class Flash extends Component{
|
|
|
|
constructor() {
|
|
super();
|
|
this.dismissFlash = this.dismissFlash.bind(this);
|
|
}
|
|
|
|
componentDidMount() {
|
|
this.props.markAsSeen(this.props.message._id);
|
|
}
|
|
|
|
dismissFlash(e) {
|
|
e.preventDefault();
|
|
this.props.clear(this.props.message._id);
|
|
}
|
|
|
|
render() {
|
|
|
|
let flashType = this.props.message.flashType;
|
|
flashType = flashType === "error" ? "danger" : flashType; // if flashType is "error", use "danger" instead
|
|
|
|
return (
|
|
<Alert className="flash-message" bsStyle={flashType} onDismiss={this.dismissFlash}>
|
|
{this.props.message.content}
|
|
</Alert>
|
|
)
|
|
}
|
|
}
|
|
|
|
Flash.propTypes = {
|
|
message: React.PropTypes.object.isRequired
|
|
}
|
|
|
|
registerComponent('Flash', Flash); |