mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-13 21:24:58 +08:00
48 lines
1.1 KiB
Text
48 lines
1.1 KiB
Text
|
React = require 'react'
|
||
|
_ = require 'underscore'
|
||
|
{OutlineView, ScrollRegion} = require 'nylas-component-kit'
|
||
|
AccountSidebarStore = require '../account-sidebar-store'
|
||
|
SidebarSection = require './sidebar-section'
|
||
|
|
||
|
|
||
|
class AccountSidebar extends React.Component
|
||
|
@displayName: 'AccountSidebar'
|
||
|
|
||
|
@containerRequired: false
|
||
|
@containerStyles:
|
||
|
minWidth: 165
|
||
|
maxWidth: 210
|
||
|
|
||
|
constructor: (@props) ->
|
||
|
@state = @_getStateFromStores()
|
||
|
|
||
|
componentDidMount: =>
|
||
|
@unsubscribers = []
|
||
|
@unsubscribers.push AccountSidebarStore.listen @_onStoreChange
|
||
|
|
||
|
componentWillUnmount: =>
|
||
|
unsubscribe() for unsubscribe in @unsubscribers
|
||
|
|
||
|
_onStoreChange: =>
|
||
|
@setState @_getStateFromStores()
|
||
|
|
||
|
_getStateFromStores: =>
|
||
|
sections: [
|
||
|
AccountSidebarStore.mailboxesSection()
|
||
|
AccountSidebarStore.categoriesSection()
|
||
|
]
|
||
|
|
||
|
_renderSections: =>
|
||
|
@state.sections.map (section) =>
|
||
|
<OutlineView key={section.label} {...section} />
|
||
|
|
||
|
render: =>
|
||
|
<ScrollRegion style={flex:1} id="account-sidebar">
|
||
|
<div className="account-sidebar-sections">
|
||
|
{@_renderSections()}
|
||
|
</div>
|
||
|
</ScrollRegion>
|
||
|
|
||
|
|
||
|
module.exports = AccountSidebar
|