@@ -13,13 +13,14 @@ var Notifications = React.createClass({
13
13
mixins : [
14
14
Reflux . connect ( NotificationsStore , 'notifications' ) ,
15
15
Reflux . listenTo ( Actions . getNotifications . completed , 'completedNotifications' ) ,
16
- Reflux . listenTo ( Actions . getNotifications . failed , 'completedNotifications ' )
16
+ Reflux . listenTo ( Actions . getNotifications . failed , 'failedNotifications ' )
17
17
] ,
18
18
19
19
getInitialState : function ( ) {
20
20
return {
21
21
notifications : [ ] ,
22
- loading : true
22
+ loading : true ,
23
+ errors : false
23
24
} ;
24
25
} ,
25
26
@@ -28,36 +29,58 @@ var Notifications = React.createClass({
28
29
} ,
29
30
30
31
completedNotifications : function ( ) {
31
- this . setState ( { loading : false } ) ;
32
+ this . setState ( {
33
+ loading : false ,
34
+ errors : false
35
+ } ) ;
36
+ } ,
37
+
38
+ failedNotifications : function ( ) {
39
+ this . setState ( {
40
+ loading : false ,
41
+ errors : true
42
+ } ) ;
32
43
} ,
33
44
34
45
render : function ( ) {
35
- var notifications ;
46
+ var notifications , errors ;
36
47
var wrapperClass = 'container-fluid main-container notifications' ;
37
48
38
- if ( _ . isEmpty ( this . state . notifications ) ) {
39
- wrapperClass += ' all-read ' ;
40
- notifications = (
49
+ if ( this . state . errors ) {
50
+ wrapperClass += ' errored ' ;
51
+ errors = (
41
52
< div >
42
- < h2 > There are no notifications for you .</ h2 >
43
- < h3 > All clean! </ h3 >
44
- < img className = 'img-responsive emoji' src = 'images/rocket .png' />
53
+ < h3 > Oops something went wrong .</ h3 >
54
+ < h4 > Couldn't get your notifications. </ h4 >
55
+ < img className = 'img-responsive emoji' src = 'images/error .png' />
45
56
</ div >
46
57
) ;
47
58
} else {
48
- notifications = (
49
- this . state . notifications . map ( function ( obj ) {
50
- var repoFullName = obj [ 0 ] . repository . full_name ;
51
- return < Repository repo = { obj } repoName = { repoFullName } key = { repoFullName } /> ;
52
- } )
53
- ) ;
59
+ if ( _ . isEmpty ( this . state . notifications ) ) {
60
+ wrapperClass += ' all-read' ;
61
+ notifications = (
62
+ < div >
63
+ < h2 > There are no notifications for you.</ h2 >
64
+ < h3 > All clean!</ h3 >
65
+ < img className = 'img-responsive emoji' src = 'images/all-read.png' />
66
+ </ div >
67
+ ) ;
68
+ } else {
69
+ notifications = (
70
+ this . state . notifications . map ( function ( obj ) {
71
+ var repoFullName = obj [ 0 ] . repository . full_name ;
72
+ return < Repository repo = { obj } repoName = { repoFullName } key = { repoFullName } /> ;
73
+ } )
74
+ ) ;
75
+ }
54
76
}
55
77
56
78
return (
57
79
< div className = { wrapperClass } >
58
80
< Loading className = 'loading-container' shouldShow = { this . state . loading } >
59
81
< div className = 'loading-text' > working on it</ div >
60
82
</ Loading >
83
+ { errors }
61
84
{ notifications }
62
85
</ div >
63
86
) ;
0 commit comments