Mailspring/internal_packages/account-sidebar/lib/components/account-sidebar.cjsx
Juan Tejada 866805f835 More account sidebar refactor + sections for unified inbox
- 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
2016-01-18 23:22:46 -08:00

49 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