11var React = require ( 'react' ) ;
22var Reflux = require ( 'reflux' ) ;
3+ var Router = require ( 'react-router' ) ;
4+
35var ipc = window . require ( 'ipc' ) ;
46
57var Actions = require ( '../actions/actions' ) ;
68var AuthStore = require ( '../stores/auth' ) ;
79
810var Navigation = React . createClass ( {
911 mixins : [
12+ Router . State ,
1013 Reflux . connect ( AuthStore , 'authStatus' ) ,
1114 Reflux . listenTo ( Actions . getNotifications . completed , 'refreshDone' ) ,
1215 Reflux . listenTo ( Actions . getNotifications . failed , 'refreshDone' )
@@ -42,18 +45,26 @@ var Navigation = React.createClass({
4245 this . setState ( { loading : false } ) ;
4346 } ,
4447
48+ goToSettings : function ( ) {
49+ this . context . router . transitionTo ( 'settings' ) ;
50+ } ,
51+
4552 logOut : function ( ) {
4653 Actions . logout ( ) ;
4754 this . context . router . transitionTo ( 'login' ) ;
4855 ipc . sendChannel ( 'update-icon' , 'IconPlain' ) ;
4956 } ,
5057
58+ goBack : function ( ) {
59+ this . context . router . transitionTo ( 'notifications' ) ;
60+ } ,
61+
5162 appQuit : function ( ) {
5263 ipc . sendChannel ( 'app-quit' ) ;
5364 } ,
5465
5566 render : function ( ) {
56- var refreshIcon , logoutIcon ;
67+ var refreshIcon , logoutIcon , backIcon , settingsIcon , quitIcon ;
5768 var loadingClass = this . state . loading ? 'fa fa-refresh fa-spin' : 'fa fa-refresh' ;
5869
5970 if ( this . state . authStatus ) {
@@ -63,18 +74,34 @@ var Navigation = React.createClass({
6374 logoutIcon = (
6475 < i className = 'fa fa-sign-out' onClick = { this . logOut } />
6576 ) ;
77+ settingsIcon = (
78+ < i className = 'fa fa-cog' onClick = { this . goToSettings } />
79+ ) ;
80+ } else {
81+ quitIcon = (
82+ < i className = 'fa fa-power-off' onClick = { this . appQuit } />
83+ ) ;
84+ }
85+ if ( this . getPath ( ) === '/settings' ) {
86+ backIcon = (
87+ < i onClick = { this . goBack } className = 'fa fa-chevron-left' />
88+ ) ;
6689 }
6790
6891 return (
6992 < div className = 'container-fluid' >
7093 < div className = 'row navigation' >
71- < div className = 'col-xs-4 left' > { refreshIcon } </ div >
94+ < div className = 'col-xs-4 left' >
95+ { backIcon }
96+ { refreshIcon }
97+ </ div >
7298 < div className = 'col-xs-4 logo' >
7399 < img className = 'img-responsive' src = 'images/logo-hor-white.png' />
74100 </ div >
75101 < div className = 'col-xs-4 right' >
102+ { settingsIcon }
76103 { logoutIcon }
77- < i className = "fa fa-power-off" onClick = { this . appQuit } />
104+ { quitIcon }
78105 </ div >
79106 </ div >
80107 </ div >
0 commit comments