Mailspring/internal_packages/account-sidebar/lib/account-sidebar.cjsx
Evan Morikawa 00c74cd1a9 WIP: This is the initial diff for new folders & labels.
Summary:
There are now two objects, Folders & Labels. These inherit from `Category`
(that's what Eben said they were using on the backend).

There are two separate tasks.

1. MoveToFolderTask
2. ApplyLabelsTask

It turns out that the semantics between the two are quite different.
The reverse operation for moving to a folder is a bit tricky.

As of 7-8-15, the Tasks are pretty much complete. I need to write tests
for them still and do some manual testing in the client.

Test Plan: Writing specs

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1724
2015-07-16 11:54:20 -04:00

65 lines
1.9 KiB
CoffeeScript

React = require 'react'
{Actions} = require("nylas-exports")
{ScrollRegion} = require("nylas-component-kit")
SidebarDividerItem = require("./account-sidebar-divider-item")
SidebarSheetItem = require("./account-sidebar-sheet-item")
AccountSidebarStore = require ("./account-sidebar-store")
AccountSidebarCategoryItem = require("./account-sidebar-category-item")
class AccountSidebar extends React.Component
@displayName: 'AccountSidebar'
@containerRequired: false
@containerStyles:
minWidth: 165
maxWidth: 207
constructor: (@props) ->
@state = @_getStateFromStores()
componentDidMount: =>
@unsubscribe = AccountSidebarStore.listen @_onStoreChange
# It's important that every React class explicitly stops listening to
# atom events before it unmounts. Thank you event-kit
# This can be fixed via a Reflux mixin
componentWillUnmount: =>
@unsubscribe() if @unsubscribe
render: =>
<ScrollRegion id="account-sidebar" className="account-sidebar">
<div className="account-sidebar-sections">
{@_sections()}
</div>
</ScrollRegion>
_sections: =>
return @state.sections.map (section) =>
<section key={section.label}>
<div className="heading">{section.label}</div>
{@_itemComponents(section)}
</section>
_itemComponents: (section) =>
section.items?.map (item) =>
if section.type is 'category'
itemClass = AccountSidebarCategoryItem
else if section.type is 'sheet'
itemClass = item.sidebarComponent ? SidebarSheetItem
else
throw new Error("Unsure how to render item type #{section.type}")
<itemClass
key={item.id ? item.type}
item={item}
select={item.id is @state.selected?.id }/>
_onStoreChange: =>
@setState @_getStateFromStores()
_getStateFromStores: =>
sections: AccountSidebarStore.sections()
selected: AccountSidebarStore.selected()
module.exports = AccountSidebar