From b536af29be36459e197629076bd9b84bb0b005d1 Mon Sep 17 00:00:00 2001 From: vrde Date: Fri, 17 Jul 2015 15:02:44 +0200 Subject: [PATCH 1/2] Logout is now a route --- js/components/header.js | 2 +- js/components/logout_container.js | 30 ++++++++++++++++++++++++ js/components/whitelabel/prize/routes.js | 2 ++ js/routes.js | 2 ++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 js/components/logout_container.js diff --git a/js/components/header.js b/js/components/header.js index 3cf05309..28312d94 100644 --- a/js/components/header.js +++ b/js/components/header.js @@ -119,7 +119,7 @@ let Header = React.createClass({ {getLangText('Account Settings')} - {getLangText('Log out')} + {getLangText('Log out')} ); diff --git a/js/components/logout_container.js b/js/components/logout_container.js new file mode 100644 index 00000000..3753d832 --- /dev/null +++ b/js/components/logout_container.js @@ -0,0 +1,30 @@ +'use strict'; + +import React from 'react'; +import Router from 'react-router'; + +let Link = Router.Link; +import UserActions from '../actions/user_actions'; +import Alt from '../alt'; + + +let LogoutContainer = React.createClass({ + + mixins: [Router.Navigation, Router.State], + + componentDidMount() { + UserActions.logoutCurrentUser(); + Alt.flush(); + // kill intercom (with fire) + window.Intercom('shutdown'); + this.transitionTo('/'); + }, + + render() { + return null; + } + +}); + + +export default LogoutContainer; diff --git a/js/components/whitelabel/prize/routes.js b/js/components/whitelabel/prize/routes.js index 9821fc79..72513419 100644 --- a/js/components/whitelabel/prize/routes.js +++ b/js/components/whitelabel/prize/routes.js @@ -5,6 +5,7 @@ import Router from 'react-router'; import Landing from './components/landing'; import LoginContainer from './components/login_container'; +import LogoutContainer from '../../../components/logout_container'; import SignupContainer from './components/signup_container'; import PasswordResetContainer from '../../../components/password_reset_container'; import PrizeRegisterPiece from './components/register_piece'; @@ -25,6 +26,7 @@ function getRoutes(commonRoutes) { + diff --git a/js/routes.js b/js/routes.js index 8b038372..90248ef2 100644 --- a/js/routes.js +++ b/js/routes.js @@ -11,6 +11,7 @@ import PieceContainer from './components/ascribe_detail/piece_container'; import EditionContainer from './components/ascribe_detail/edition_container'; import LoginContainer from './components/login_container'; +import LogoutContainer from './components/logout_container'; import SignupContainer from './components/signup_container'; import PasswordResetContainer from './components/password_reset_container'; @@ -26,6 +27,7 @@ const COMMON_ROUTES = ( + From d298486a6f27c7e304e49c2604e24a3ce1ad581a Mon Sep 17 00:00:00 2001 From: vrde Date: Fri, 17 Jul 2015 15:09:38 +0200 Subject: [PATCH 2/2] cleanup header --- js/components/header.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/js/components/header.js b/js/components/header.js index 28312d94..b892bb5d 100644 --- a/js/components/header.js +++ b/js/components/header.js @@ -9,8 +9,6 @@ import UserStore from '../stores/user_store'; import WhitelabelActions from '../actions/whitelabel_actions'; import WhitelabelStore from '../stores/whitelabel_store'; -import Alt from '../alt'; - import Nav from 'react-bootstrap/lib/Nav'; import Navbar from 'react-bootstrap/lib/Navbar'; import CollapsibleNav from 'react-bootstrap/lib/CollapsibleNav'; @@ -31,7 +29,7 @@ let Header = React.createClass({ showAddWork: React.PropTypes.bool }, - mixins: [Router.Navigation, Router.State], + mixins: [Router.State], getDefaultProps() { return { @@ -55,14 +53,6 @@ let Header = React.createClass({ WhitelabelStore.unlisten(this.onChange); }, - handleLogout(){ - UserActions.logoutCurrentUser(); - Alt.flush(); - // kill intercom (with fire) - window.Intercom('shutdown'); - this.transitionTo('login'); - }, - getLogo(){ let logo = (