fix(account-switcher): Add Account > Manage Accounts

This commit is contained in:
Ben Gotow 2015-09-30 12:29:56 -07:00
parent 75bcfed95e
commit 801c7a4c35
5 changed files with 40 additions and 20 deletions

View file

@ -63,7 +63,7 @@ class AccountSwitcher extends React.Component
_renderNewAccountOption: =>
<div className="item secondary-item new-account-option"
onClick={@_onAddAccount}
onClick={@_onManageAccounts}
tabIndex={999}>
<div style={float: 'left'}>
<RetinaImg name="icon-accounts-addnew.png"
@ -72,7 +72,7 @@ class AccountSwitcher extends React.Component
style={width: 28, height: 28, marginTop: -10} />
</div>
<div className="name" style={lineHeight: "110%", textTransform: 'none'}>
Add account&hellip;
Manage accounts&hellip;
</div>
<div style={clear: "both"}></div>
</div>
@ -114,8 +114,8 @@ class AccountSwitcher extends React.Component
Actions.selectAccountId(account.id)
@setState(showing: false)
_onAddAccount: =>
require('ipc').send('command', 'application:add-account')
_onManageAccounts: =>
Actions.openPreferences({tab: 'Accounts'})
@setState(showing: false)
_getStateFromStores: =>

View file

@ -1,11 +1,10 @@
PreferencesStore = require './preferences-store'
module.exports =
activate: (@state={}) ->
ipc = require 'ipc'
React = require 'react'
Preferences = require('./preferences')
{ReactRemote,
Actions} = require('nylas-exports')
{Actions} = require('nylas-exports')
Actions.registerPreferencesTab({
icon: 'ic-settings-general.png'
@ -37,21 +36,30 @@ module.exports =
name: 'Appearance'
component: require './tabs/preferences-appearance'
})
# Actions.registerPreferencesTab({
# icon: 'ic-settings-signatures.png'
# name: 'Signatures'
# component: require './tabs/preferences-signatures'
# })
ipc.on 'open-preferences', (detail) ->
ReactRemote.openWindowForComponent(Preferences, {
tag: 'preferences'
title: "Preferences"
width: 520
resizable: false
autosize: true
stylesheetRegex: /preferences/
})
Actions.openPreferences.listen(@_openPreferences)
ipc.on 'open-preferences', => @_openPreferences()
_openPreferences: ({tab} = {}) ->
{ReactRemote} = require('nylas-exports')
Preferences = require('./preferences')
ReactRemote.openWindowForComponent(Preferences, {
tag: 'preferences'
title: "Preferences"
width: 520
resizable: false
autosize: true
stylesheetRegex: /preferences/
props: {
initialTab: tab
}
})
deactivate: ->

View file

@ -9,8 +9,12 @@ class Preferences extends React.Component
@displayName: 'Preferences'
constructor: (@props) ->
@state = _.extend @getStateFromStores(),
activeTab: PreferencesStore.tabs()[0]
tabs = PreferencesStore.tabs()
if @props.initialTab
activeTab = _.find tabs, (t) => t.name is @props.initialTab
activeTab ||= tabs[0]
@state = _.extend(@getStateFromStores(), {activeTab})
componentDidMount: =>
@unlisteners = []

View file

@ -125,6 +125,14 @@ class Actions
###
@retryInitialSync: ActionScopeWorkWindow
###
Public: Open the preferences window. Pass an object with a tab name
(ie: `{tab: 'Accounts'}`) to open a specific panel.
*Scope: Window*
###
@openPreferences: ActionScopeWindow
###
Public: Register a preferences tab, usually applied in Preferences window

View file

@ -340,7 +340,7 @@ var openWindowForComponent = function(Component, options) {
// the browser window. When both of these things finish, we send the html
// css, and any observed method invocations that occurred during the first
// React cycle (componentDidMount).
React.render(React.createElement(Component), container, function() {
React.render(React.createElement(Component, options.props), container, function() {
target.reactid = container.firstChild.dataset.reactid,
target.containerReady = true;
target.sendHTMLIfReady();