Files
Iris/src/js/components/Notifications.js

85 lines
2.0 KiB
JavaScript
Raw Normal View History

2016-12-13 11:08:13 +13:00
import React, { PropTypes } from 'react'
import FontAwesome from 'react-fontawesome'
export default class Notifications extends React.Component{
2016-12-13 11:08:13 +13:00
constructor(props) {
super(props)
}
renderNotifications(){
if (!this.props.notifications || this.props.notifications.length <= 0) return null
2016-12-13 11:08:13 +13:00
// we only care about the last notification
var notification = this.props.notifications[this.props.notifications.length-1]
2016-12-13 11:08:13 +13:00
return (
<span>
{
this.props.notifications.map(notification => {
switch (notification.type){
case 'shortcut':
return (
2017-04-05 20:28:41 +12:00
<div className="shortcut-notification" key={notification.key}>
<FontAwesome name={notification.content} />
</div>
)
2017-04-05 20:28:41 +12:00
case 'process':
return (
2017-04-05 20:28:41 +12:00
<div className="process notification" key={notification.key}>
<FontAwesome name="close" className="close-button" onClick={ e => this.props.uiActions.cancelProcess(notification.key) } />
{ notification.content }
</div>
)
default:
return (
2017-04-05 20:28:41 +12:00
<div className={notification.type+" notification"} key={notification.key}>
<FontAwesome name="close" className="close-button" onClick={ e => this.props.uiActions.removeNotification(notification.key) } />
{ notification.content }
</div>
)
}
})
}
</span>
)
2016-12-13 11:08:13 +13:00
}
// do we want the loading of everything to be displayed?
// not likely...
renderLoader(){
if (!this.props.load_queue){
return null
}
var load_queue = this.props.load_queue
var is_loading = false
for (var key in load_queue){
if (load_queue.hasOwnProperty(key)){
is_loading = true
break
}
}
if (is_loading){
return (
<div className="notification loading">
Loading
</div>
)
} else {
return null
}
2016-12-13 11:08:13 +13:00
}
render(){
return (
<div className="notifications">
{this.renderNotifications()}
</div>
)
}
}