mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 20:44:30 +08:00
79b6c1d94a
Summary: Things still to come: - General tab - Signatures tab (potentially remove and land) Adding emacs things to gitignore Adding progress. iterating on html/css is incredibly painful Added layout for accounts page. Adding layout for appearance page layout for shortcuts preferences page adding layount for notifications menu Adding signatures layout WIP WIP - tab switching, accounts tab WIP ALL THE THINGS Keymap template support (Gmail / outlook, etc.) Test Plan: No tests atm Reviewers: evan Differential Revision: https://phab.nylas.com/D1890
73 lines
2.1 KiB
CoffeeScript
73 lines
2.1 KiB
CoffeeScript
React = require 'react'
|
|
_ = require 'underscore'
|
|
{RetinaImg, Flexbox} = require 'nylas-component-kit'
|
|
|
|
PreferencesStore = require './preferences-store'
|
|
PreferencesHeader = require './preferences-header'
|
|
|
|
class Preferences extends React.Component
|
|
@displayName: 'Preferences'
|
|
|
|
constructor: (@props) ->
|
|
@state = _.extend @getStateFromStores(),
|
|
activeTab: PreferencesStore.tabs()[0]
|
|
|
|
componentDidMount: =>
|
|
@unlisteners = []
|
|
@unlisteners.push PreferencesStore.listen =>
|
|
@setState(@getStateFromStores())
|
|
@unlisteners.push atom.config.observe null, (val) =>
|
|
@setState(@getStateFromStores())
|
|
|
|
componentWillUnmount: =>
|
|
unlisten() for unlisten in @unlisteners
|
|
|
|
componentDidUpdate: =>
|
|
if @state.tabs.length > 0 and not @state.activeTab
|
|
@setState(activeTab: @state.tabs[0])
|
|
|
|
getStateFromStores: =>
|
|
config: @getConfigWithMutators()
|
|
tabs: PreferencesStore.tabs()
|
|
|
|
getConfigWithMutators: =>
|
|
_.extend atom.config.get(), {
|
|
get: (key) =>
|
|
atom.config.get(key)
|
|
set: (key, value) =>
|
|
atom.config.set(key, value)
|
|
return
|
|
toggle: (key) =>
|
|
atom.config.set(key, !atom.config.get(key))
|
|
return
|
|
contains: (key, val) =>
|
|
vals = atom.config.get(key)
|
|
return false unless vals and vals instanceof Array
|
|
return val in vals
|
|
toggleContains: (key, val) =>
|
|
vals = atom.config.get(key)
|
|
vals = [] unless vals and vals instanceof Array
|
|
if val in vals
|
|
atom.config.set(key, _.without(vals, val))
|
|
else
|
|
atom.config.set(key, vals.concat([val]))
|
|
return
|
|
}
|
|
|
|
render: =>
|
|
if @state.activeTab
|
|
bodyElement = <@state.activeTab.component config={@state.config} />
|
|
else
|
|
bodyElement = <div>No Tab Active</div>
|
|
|
|
<div className="preferences-wrap">
|
|
<PreferencesHeader tabs={@state.tabs}
|
|
activeTab={@state.activeTab}
|
|
changeActiveTab={@_onChangeActiveTab}/>
|
|
{bodyElement}
|
|
</div>
|
|
|
|
_onChangeActiveTab: (tab) =>
|
|
@setState(activeTab: tab)
|
|
|
|
module.exports = Preferences
|