mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-10-06 11:16:10 +08:00
fix(account-switcher): Add Account > Manage Accounts
This commit is contained in:
parent
75bcfed95e
commit
801c7a4c35
5 changed files with 40 additions and 20 deletions
|
@ -63,7 +63,7 @@ class AccountSwitcher extends React.Component
|
||||||
|
|
||||||
_renderNewAccountOption: =>
|
_renderNewAccountOption: =>
|
||||||
<div className="item secondary-item new-account-option"
|
<div className="item secondary-item new-account-option"
|
||||||
onClick={@_onAddAccount}
|
onClick={@_onManageAccounts}
|
||||||
tabIndex={999}>
|
tabIndex={999}>
|
||||||
<div style={float: 'left'}>
|
<div style={float: 'left'}>
|
||||||
<RetinaImg name="icon-accounts-addnew.png"
|
<RetinaImg name="icon-accounts-addnew.png"
|
||||||
|
@ -72,7 +72,7 @@ class AccountSwitcher extends React.Component
|
||||||
style={width: 28, height: 28, marginTop: -10} />
|
style={width: 28, height: 28, marginTop: -10} />
|
||||||
</div>
|
</div>
|
||||||
<div className="name" style={lineHeight: "110%", textTransform: 'none'}>
|
<div className="name" style={lineHeight: "110%", textTransform: 'none'}>
|
||||||
Add account…
|
Manage accounts…
|
||||||
</div>
|
</div>
|
||||||
<div style={clear: "both"}></div>
|
<div style={clear: "both"}></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -114,8 +114,8 @@ class AccountSwitcher extends React.Component
|
||||||
Actions.selectAccountId(account.id)
|
Actions.selectAccountId(account.id)
|
||||||
@setState(showing: false)
|
@setState(showing: false)
|
||||||
|
|
||||||
_onAddAccount: =>
|
_onManageAccounts: =>
|
||||||
require('ipc').send('command', 'application:add-account')
|
Actions.openPreferences({tab: 'Accounts'})
|
||||||
@setState(showing: false)
|
@setState(showing: false)
|
||||||
|
|
||||||
_getStateFromStores: =>
|
_getStateFromStores: =>
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
|
PreferencesStore = require './preferences-store'
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
activate: (@state={}) ->
|
activate: (@state={}) ->
|
||||||
ipc = require 'ipc'
|
ipc = require 'ipc'
|
||||||
React = require 'react'
|
React = require 'react'
|
||||||
Preferences = require('./preferences')
|
{Actions} = require('nylas-exports')
|
||||||
|
|
||||||
{ReactRemote,
|
|
||||||
Actions} = require('nylas-exports')
|
|
||||||
|
|
||||||
Actions.registerPreferencesTab({
|
Actions.registerPreferencesTab({
|
||||||
icon: 'ic-settings-general.png'
|
icon: 'ic-settings-general.png'
|
||||||
|
@ -37,21 +36,30 @@ module.exports =
|
||||||
name: 'Appearance'
|
name: 'Appearance'
|
||||||
component: require './tabs/preferences-appearance'
|
component: require './tabs/preferences-appearance'
|
||||||
})
|
})
|
||||||
|
|
||||||
# Actions.registerPreferencesTab({
|
# Actions.registerPreferencesTab({
|
||||||
# icon: 'ic-settings-signatures.png'
|
# icon: 'ic-settings-signatures.png'
|
||||||
# name: 'Signatures'
|
# name: 'Signatures'
|
||||||
# component: require './tabs/preferences-signatures'
|
# component: require './tabs/preferences-signatures'
|
||||||
# })
|
# })
|
||||||
|
|
||||||
ipc.on 'open-preferences', (detail) ->
|
Actions.openPreferences.listen(@_openPreferences)
|
||||||
ReactRemote.openWindowForComponent(Preferences, {
|
ipc.on 'open-preferences', => @_openPreferences()
|
||||||
tag: 'preferences'
|
|
||||||
title: "Preferences"
|
_openPreferences: ({tab} = {}) ->
|
||||||
width: 520
|
{ReactRemote} = require('nylas-exports')
|
||||||
resizable: false
|
Preferences = require('./preferences')
|
||||||
autosize: true
|
ReactRemote.openWindowForComponent(Preferences, {
|
||||||
stylesheetRegex: /preferences/
|
tag: 'preferences'
|
||||||
})
|
title: "Preferences"
|
||||||
|
width: 520
|
||||||
|
resizable: false
|
||||||
|
autosize: true
|
||||||
|
stylesheetRegex: /preferences/
|
||||||
|
props: {
|
||||||
|
initialTab: tab
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
deactivate: ->
|
deactivate: ->
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,12 @@ class Preferences extends React.Component
|
||||||
@displayName: 'Preferences'
|
@displayName: 'Preferences'
|
||||||
|
|
||||||
constructor: (@props) ->
|
constructor: (@props) ->
|
||||||
@state = _.extend @getStateFromStores(),
|
tabs = PreferencesStore.tabs()
|
||||||
activeTab: PreferencesStore.tabs()[0]
|
if @props.initialTab
|
||||||
|
activeTab = _.find tabs, (t) => t.name is @props.initialTab
|
||||||
|
activeTab ||= tabs[0]
|
||||||
|
|
||||||
|
@state = _.extend(@getStateFromStores(), {activeTab})
|
||||||
|
|
||||||
componentDidMount: =>
|
componentDidMount: =>
|
||||||
@unlisteners = []
|
@unlisteners = []
|
||||||
|
|
|
@ -125,6 +125,14 @@ class Actions
|
||||||
###
|
###
|
||||||
@retryInitialSync: ActionScopeWorkWindow
|
@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
|
Public: Register a preferences tab, usually applied in Preferences window
|
||||||
|
|
||||||
|
|
2
src/react-remote/react-remote-parent.js
vendored
2
src/react-remote/react-remote-parent.js
vendored
|
@ -340,7 +340,7 @@ var openWindowForComponent = function(Component, options) {
|
||||||
// the browser window. When both of these things finish, we send the html
|
// the browser window. When both of these things finish, we send the html
|
||||||
// css, and any observed method invocations that occurred during the first
|
// css, and any observed method invocations that occurred during the first
|
||||||
// React cycle (componentDidMount).
|
// 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.reactid = container.firstChild.dataset.reactid,
|
||||||
target.containerReady = true;
|
target.containerReady = true;
|
||||||
target.sendHTMLIfReady();
|
target.sendHTMLIfReady();
|
||||||
|
|
Loading…
Add table
Reference in a new issue