1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-10 20:00:19 +02:00
onion/js/components/header_notification_debug.js
2015-07-08 17:06:53 +02:00

51 lines
1.3 KiB
JavaScript

'use strict';
import React from 'react';
import GlobalNotificationModel from '../models/global_notification_model';
import GlobalNotificationActions from '../actions/global_notification_actions';
import MenuItem from 'react-bootstrap/lib/MenuItem';
/*
This components purpose is to be inserted into the page's navigation in order
debug the globalnotificationsaction easily
*/
let HeaderNotificationDebug = React.createClass({
propTypes: {
show: React.PropTypes.bool
},
getInitialState() {
return {
index: 0
};
},
triggerNotification() {
if(this.state.index === 1) {
this.setState({index: 0});
} else {
this.setState({index: this.state.index + 1});
}
let actions = ['success', 'danger'];
let notification = new GlobalNotificationModel('this is a test, please ignore', actions[this.state.index]);
GlobalNotificationActions.appendGlobalNotification(notification);
},
render() {
if(this.props.show) {
return (
<MenuItem onClick={this.triggerNotification}>Notification</MenuItem>
);
} else {
return null;
}
}
});
export default HeaderNotificationDebug;