mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-15 14:20:38 +08:00
a9aaab9f38
Summary: - Refactors account-sidebar internal package: - Separates into smaller react components - Makes DisclosureTriangle its own independent component - Adds data to AccountSidebarStore to allow removal or addition of items for a specific section of the sidebar - Adds button and input and css styles to create categories - Adds context menu to destroy a category - Adds new method to CategoryStore to get the icon name for the categories of the current account - Removes some unused code Test Plan: Manual Reviewers: evan, bengotow Reviewed By: bengotow Differential Revision: https://phab.nylas.com/D2283
55 lines
1.5 KiB
CoffeeScript
55 lines
1.5 KiB
CoffeeScript
React = require 'react'
|
|
_ = require 'underscore'
|
|
{ScrollRegion} = require 'nylas-component-kit'
|
|
AccountSidebarStore = require './account-sidebar-store'
|
|
AccountSidebarSection = require './account-sidebar-section'
|
|
|
|
|
|
class AccountSidebar extends React.Component
|
|
@displayName: 'AccountSidebar'
|
|
|
|
@containerRequired: false
|
|
@containerStyles:
|
|
minWidth: 165
|
|
maxWidth: 210
|
|
|
|
constructor: (@props) ->
|
|
@state = @_getStateFromStores()
|
|
@state.collapsed = NylasEnv.config.get('core.accountSidebarCollapsed') ? {}
|
|
|
|
componentDidMount: =>
|
|
@unsubscribers = []
|
|
@unsubscribers.push AccountSidebarStore.listen @_onStoreChange
|
|
|
|
componentWillUnmount: =>
|
|
unsubscribe() for unsubscribe in @unsubscribers
|
|
|
|
render: =>
|
|
<ScrollRegion style={flex:1} id="account-sidebar">
|
|
<div className="account-sidebar-sections">
|
|
{@_sections()}
|
|
</div>
|
|
</ScrollRegion>
|
|
|
|
_sections: =>
|
|
@state.sections.map (section) =>
|
|
<AccountSidebarSection
|
|
key={section.label}
|
|
section={section}
|
|
collapsed={@state.collapsed}
|
|
selected={@state.selected}
|
|
onToggleCollapsed={@_onToggleCollapsed} />
|
|
_onStoreChange: =>
|
|
@setState @_getStateFromStores()
|
|
|
|
_onToggleCollapsed: (itemId) =>
|
|
collapsed = _.clone(@state.collapsed)
|
|
collapsed[itemId] = !collapsed[itemId]
|
|
NylasEnv.config.set('core.accountSidebarCollapsed', collapsed)
|
|
@setState({collapsed})
|
|
|
|
_getStateFromStores: =>
|
|
sections: AccountSidebarStore.sections()
|
|
selected: AccountSidebarStore.selected()
|
|
|
|
module.exports = AccountSidebar
|