diff --git a/app/assets/stylesheets/application.scss.erb b/app/assets/stylesheets/application.scss.erb index 14457520..52b0fc29 100644 --- a/app/assets/stylesheets/application.scss.erb +++ b/app/assets/stylesheets/application.scss.erb @@ -786,7 +786,6 @@ label { width: 32px; } .sidebarAccountBox { - display: none; height: auto; } .authenticated .sidebarAccountBox { diff --git a/frontend/src/Metamaps/GlobalUI/Account.js b/frontend/src/Metamaps/GlobalUI/Account.js deleted file mode 100644 index 59d9527d..00000000 --- a/frontend/src/Metamaps/GlobalUI/Account.js +++ /dev/null @@ -1,44 +0,0 @@ -/* global $ */ - -import Filter from '../Filter' - -const Account = { - isOpen: false, - changing: false, - init: function() { - var self = Account - $('body').click(self.close) - }, - toggleBox: function(event) { - var self = Account - if (self.isOpen) self.close() - else self.open() - event.stopPropagation() - }, - open: function() { - var self = Account - $('.sidebarAccountIcon .tooltipsUnder').addClass('hide') - if (!self.isOpen && !self.changing) { - self.changing = true - $('.sidebarAccountBox').fadeIn(200, function() { - self.changing = false - self.isOpen = true - $('.sidebarAccountBox #user_email').focus() - }) - } - }, - close: function() { - var self = Account - $('.sidebarAccountIcon .tooltipsUnder').removeClass('hide') - if (!self.changing) { - self.changing = true - $('.sidebarAccountBox #user_email').blur() - $('.sidebarAccountBox').fadeOut(200, function() { - self.changing = false - self.isOpen = false - }) - } - } -} - -export default Account diff --git a/frontend/src/Metamaps/GlobalUI/ReactApp.js b/frontend/src/Metamaps/GlobalUI/ReactApp.js index 8539adee..eccdaa8a 100644 --- a/frontend/src/Metamaps/GlobalUI/ReactApp.js +++ b/frontend/src/Metamaps/GlobalUI/ReactApp.js @@ -7,7 +7,6 @@ import { merge } from 'lodash' import { notifyUser } from './index.js' import ImportDialog from './ImportDialog' -import Account from './Account' import Active from '../Active' import DataModel from '../DataModel' import { ExploreMaps, ChatView, TopicCard } from '../Views' @@ -103,8 +102,7 @@ const ReactApp = { mobileTitle: self.mobileTitle, mobileTitleWidth: self.mobileTitleWidth, mobileTitleClick: (e) => Active.Map && InfoBox.toggleBox(e), - openInviteLightbox: () => self.openLightbox('invite'), - toggleAccountBox: Account.toggleBox + openInviteLightbox: () => self.openLightbox('invite') }, self.getMapProps(), self.getTopicProps(), diff --git a/frontend/src/Metamaps/GlobalUI/index.js b/frontend/src/Metamaps/GlobalUI/index.js index 7e77ff7d..b2dd6654 100644 --- a/frontend/src/Metamaps/GlobalUI/index.js +++ b/frontend/src/Metamaps/GlobalUI/index.js @@ -7,7 +7,6 @@ import Create from '../Create' import ReactApp from './ReactApp' import Search from './Search' import CreateMap from './CreateMap' -import Account from './Account' import ImportDialog from './ImportDialog' const GlobalUI = { @@ -20,7 +19,6 @@ const GlobalUI = { self.ReactApp.init(serverData, self.openLightbox) self.CreateMap.init(serverData) - self.Account.init(serverData) self.ImportDialog.init(serverData, self.openLightbox, self.closeLightbox) self.Search.init(serverData) @@ -153,5 +151,5 @@ const GlobalUI = { } } -export { ReactApp, Search, CreateMap, Account, ImportDialog } +export { ReactApp, Search, CreateMap, ImportDialog } export default GlobalUI diff --git a/frontend/src/Metamaps/index.js b/frontend/src/Metamaps/index.js index 7a55017a..12fcbe60 100644 --- a/frontend/src/Metamaps/index.js +++ b/frontend/src/Metamaps/index.js @@ -9,7 +9,7 @@ import DataModel from './DataModel' import Debug from './Debug' import Filter from './Filter' import GlobalUI, { - ReactApp, Search, CreateMap, ImportDialog, Account as GlobalUIAccount + ReactApp, Search, CreateMap, ImportDialog } from './GlobalUI' import Import from './Import' import JIT from './JIT' @@ -45,7 +45,6 @@ Metamaps.GlobalUI = GlobalUI Metamaps.GlobalUI.ReactApp = ReactApp Metamaps.GlobalUI.Search = Search Metamaps.GlobalUI.CreateMap = CreateMap -Metamaps.GlobalUI.Account = GlobalUIAccount Metamaps.GlobalUI.ImportDialog = ImportDialog Metamaps.Import = Import Metamaps.JIT = JIT diff --git a/frontend/src/components/App/AccountMenu.js b/frontend/src/components/App/AccountMenu.js index d1f772ec..99ab9301 100644 --- a/frontend/src/components/App/AccountMenu.js +++ b/frontend/src/components/App/AccountMenu.js @@ -1,9 +1,16 @@ import React, { Component, PropTypes } from 'react' +import onClickOutsideAddon from 'react-onclickoutside' + class AccountMenu extends Component { static propTypes = { currentUser: PropTypes.object, - onInviteClick: PropTypes.func + onInviteClick: PropTypes.func, + closeBox: PropTypes.func + } + + handleClickOutside = () => { + this.props.closeBox() } render () { @@ -37,4 +44,4 @@ class AccountMenu extends Component { } } -export default AccountMenu +export default onClickOutsideAddon(AccountMenu) diff --git a/frontend/src/components/App/LoginForm.js b/frontend/src/components/App/LoginForm.js index a6b3ae77..670b2bcb 100644 --- a/frontend/src/components/App/LoginForm.js +++ b/frontend/src/components/App/LoginForm.js @@ -1,8 +1,11 @@ import React, { Component, PropTypes } from 'react' +import onClickOutsideAddon from 'react-onclickoutside' + class LoginForm extends Component { static propTypes = { - loginFormAuthToken: PropTypes.string + loginFormAuthToken: PropTypes.string, + closeBox: PropTypes.func } constructor(props) { @@ -15,13 +18,21 @@ class LoginForm extends Component { this.setState({token}) } + emailInputDidMount(node) { + node.focus() + } + + handleClickOutside = () => { + this.props.closeBox() + } + render () { return
- +
@@ -43,4 +54,4 @@ class LoginForm extends Component { } } -export default LoginForm +export default onClickOutsideAddon(LoginForm) diff --git a/frontend/src/components/App/UpperRightUI.js b/frontend/src/components/App/UpperRightUI.js index 2fe72e29..e8494b54 100644 --- a/frontend/src/components/App/UpperRightUI.js +++ b/frontend/src/components/App/UpperRightUI.js @@ -9,16 +9,25 @@ class UpperRightUI extends Component { currentUser: PropTypes.object, signInPage: PropTypes.bool, unreadNotificationsCount: PropTypes.number, - openInviteLightbox: PropTypes.func, - onClickAccount: PropTypes.func + openInviteLightbox: PropTypes.func } - static contextTypes = { - location: PropTypes.object + constructor(props) { + super(props) + this.state = {accountBoxOpen: false} + } + + reset = () => { + this.setState({accountBoxOpen: false}) + } + + toggleAccountBox = () => { + this.setState({accountBoxOpen: !this.state.accountBoxOpen}) } render () { - const { currentUser, signInPage, unreadNotificationsCount, openInviteLightbox, onClickAccount } = this.props + const { currentUser, signInPage, unreadNotificationsCount, openInviteLightbox } = this.props + const { accountBoxOpen } = this.state return
{currentUser &&
@@ -29,17 +38,17 @@ class UpperRightUI extends Component { } {!signInPage &&
-
+
Account
{currentUser && } {!currentUser && 'SIGN IN'} {!currentUser &&
}
-
+ {accountBoxOpen &&
{currentUser - ? - : } -
+ ? + : } +
}
}
diff --git a/frontend/src/components/App/index.js b/frontend/src/components/App/index.js index ddf9f16c..22d327a2 100644 --- a/frontend/src/components/App/index.js +++ b/frontend/src/components/App/index.js @@ -16,7 +16,6 @@ class App extends Component { mobileTitleWidth: PropTypes.number, mobileTitleClick: PropTypes.func, openInviteLightbox: PropTypes.func, - toggleAccountBox: PropTypes.func, map: PropTypes.object, userRequested: PropTypes.bool, requestAnswered: PropTypes.bool, @@ -36,7 +35,7 @@ class App extends Component { render () { const { children, toast, unreadNotificationsCount, openInviteLightbox, mobile, mobileTitle, mobileTitleWidth, mobileTitleClick, location, - toggleAccountBox, map, userRequested, requestAnswered, requestApproved, + map, userRequested, requestAnswered, requestApproved, onRequestAccess } = this.props const { pathname } = location || {} // this fixes a bug that happens otherwise when you logout @@ -57,8 +56,7 @@ class App extends Component { {!mobile && } + signInPage={pathname === '/login'} />} {!mobile && currentUser &&
} {children}