-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpanel.jsx
More file actions
83 lines (73 loc) · 2.1 KB
/
panel.jsx
File metadata and controls
83 lines (73 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// libs
import _ from 'lodash';
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
// components
import ContentBox from 'components/core/content-box';
import NotificationItem from '../activity-notifications/item';
import { PrimaryButton } from 'components/core/button';
export default class NotificationPanel extends React.Component {
static propTypes = {
notifications: PropTypes.array.isRequired,
displayed: PropTypes.bool,
markAsRead: PropTypes.func.isRequired,
markAsReadAndClose: PropTypes.func.isRequired
};
static defaultProps = {
displayed: false
}
get items() {
const items = this.props.notifications;
if (_.isEmpty(items)) {
return (
<div className="fc-activity-notifications__empty-message">
Nothing to see here yet!
</div>
);
} else {
return items.map(item => {
return (<NotificationItem item={item} key={`notification-item-${item.id}`} />);
});
}
}
get footer() {
const items = this.props.notifications;
const shouldBeDisabled = _.isEmpty(items);
const buttonClassName = classNames('fc-activity-notifications__footer-button', {
'_disabled': shouldBeDisabled
});
return (
<div className="fc-activity-notifications__footer">
<PrimaryButton onClick={this.props.markAsReadAndClose}
className={buttonClassName}
disabled={shouldBeDisabled}>
Mark All As Read
</PrimaryButton>
</div>
);
}
get body() {
if (this.props.displayed) {
return (
<div>
<div className="fc-activity-notifications__overlay"
onClick={this.props.markAsRead}>
</div>
<ContentBox title="Notifications"
className="fc-activity-notifications__box"
footer={this.footer}>
{this.items }
</ContentBox>
</div>
);
}
}
render() {
return (
<div className="fc-activity-notifications__panel">
{ this.body }
</div>
);
}
}