mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 04:25:31 +08:00
a3b45cf33a
Summary: Update a few more packages to deactivate properly Miscelaneous fixes Initial commit of new settings package WIP WIP - can load and unload and install / uninstall Click to create new boilerplate package, package updating Test Plan: Run tests Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D1582
50 lines
1.2 KiB
CoffeeScript
50 lines
1.2 KiB
CoffeeScript
React = require 'react'
|
|
_ = require "underscore"
|
|
{Flexbox} = require 'nylas-component-kit'
|
|
classNames = require 'classnames'
|
|
|
|
Tabs = require './tabs'
|
|
SettingsActions = require './settings-actions'
|
|
SettingsStore = require './settings-store'
|
|
|
|
class SettingsTabs extends React.Component
|
|
@displayName: 'SettingsTabs'
|
|
|
|
@propTypes:
|
|
'onChange': React.PropTypes.Func
|
|
|
|
@containerRequired: false
|
|
@containerStyles:
|
|
minWidth: 200
|
|
maxWidth: 290
|
|
|
|
constructor: (@props) ->
|
|
@state = @_getStateFromStores()
|
|
|
|
render: ->
|
|
<ul className="settings-view-tabs">
|
|
{@_renderItems()}
|
|
</ul>
|
|
|
|
_renderItems: ->
|
|
Tabs.map ({name, key, icon}, idx) =>
|
|
classes = classNames
|
|
'tab': true
|
|
'active': idx is @state.tabIndex
|
|
<li key={key} className={classes} onClick={ => SettingsActions.selectTabIndex(idx)}>{name}</li>
|
|
|
|
componentDidMount: =>
|
|
@_unsubscribers = []
|
|
@_unsubscribers.push SettingsStore.listen(@_onChange)
|
|
|
|
componentWillUnmount: =>
|
|
unsubscribe() for unsubscribe in @_unsubscribers
|
|
|
|
_getStateFromStores: =>
|
|
tabIndex: SettingsStore.tabIndex()
|
|
|
|
_onChange: =>
|
|
@setState(@_getStateFromStores())
|
|
|
|
|
|
module.exports = SettingsTabs
|