Mailspring/internal_packages/account-sidebar/lib/components/account-switcher.cjsx
Juan Tejada 78665c5fec fix(sidebar): Handle edge cases for sidebar shortcuts
Summary:
- Update menus and shortcuts correclt when accounts change or focused
  accounts change
- Move menu logic into SidebarCommands to remove duplicated logic
- Make `Window` menu also contain checkboxes

Test Plan: - Manual

Reviewers: evan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2534
2016-02-05 14:25:07 -08:00

48 lines
1.2 KiB
CoffeeScript

React = require 'react'
{Actions} = require 'nylas-exports'
{RetinaImg} = require 'nylas-component-kit'
AccountCommands = require '../account-commands'
class AccountSwitcher extends React.Component
@displayName: 'AccountSwitcher'
@propTypes:
accounts: React.PropTypes.array.isRequired
focusedAccounts: React.PropTypes.array.isRequired
_makeMenuTemplate: =>
template = AccountCommands.menuTemplate(
@props.accounts,
@props.focusedAccounts,
clickHandlers: true
)
template = template.concat [
{type: 'separator'}
{label: 'Manage Accounts...', click: @_onManageAccounts}
]
return template
# Handlers
_onManageAccounts: =>
Actions.switchPreferencesTab('Accounts')
Actions.openPreferences()
_onShowMenu: =>
remote = require('electron').remote
Menu = remote.Menu
menu = Menu.buildFromTemplate(@_makeMenuTemplate())
menu.popup()
render: =>
<div className="account-switcher" onMouseDown={@_onShowMenu}>
<RetinaImg
style={width: 13, height: 14}
name="account-switcher-dropdown.png"
mode={RetinaImg.Mode.ContentDark} />
</div>
module.exports = AccountSwitcher