mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 12:40:08 +08:00
866805f835
- Refactors some of the old code which was 💩
- Makes SidbarSection a factory for different types of items for the
OutlineView
- Decided not to create a OutlineViewItem.Model class since the only
purpose it would serve would be to validate getters for props or for
documentation, both of which are already done via React.PropTypes.
- Adds sections when looking at unified inbox and integrates with new
mailbox perspecitve interface
- Updates OutlineViewItem a bit + styles
- Tests missing
48 lines
1.2 KiB
CoffeeScript
48 lines
1.2 KiB
CoffeeScript
_ = require 'underscore'
|
|
React = require 'react'
|
|
{OutlineView, ScrollRegion} = require 'nylas-component-kit'
|
|
SidebarStore = require '../sidebar-store'
|
|
|
|
|
|
class AccountSidebar extends React.Component
|
|
@displayName: 'AccountSidebar'
|
|
|
|
@containerRequired: false
|
|
@containerStyles:
|
|
minWidth: 165
|
|
maxWidth: 210
|
|
|
|
constructor: (@props) ->
|
|
@state = @_getStateFromStores()
|
|
|
|
componentDidMount: =>
|
|
@unsubscribers = []
|
|
@unsubscribers.push SidebarStore.listen @_onStoreChange
|
|
|
|
componentWillUnmount: =>
|
|
unsubscribe() for unsubscribe in @unsubscribers
|
|
|
|
_onStoreChange: =>
|
|
@setState @_getStateFromStores()
|
|
|
|
_getStateFromStores: =>
|
|
standardSection: SidebarStore.standardSection()
|
|
userSections: SidebarStore.userSections()
|
|
|
|
_renderUserSections: (sections) =>
|
|
sections.map (section) =>
|
|
<OutlineView key={section.title} {...section} />
|
|
|
|
render: =>
|
|
standardSection = @state.standardSection
|
|
userSections = @state.userSections
|
|
|
|
<ScrollRegion className="account-sidebar" >
|
|
<div className="account-sidebar-sections">
|
|
<OutlineView {...standardSection} />
|
|
{@_renderUserSections(userSections)}
|
|
</div>
|
|
</ScrollRegion>
|
|
|
|
|
|
module.exports = AccountSidebar
|