diff --git a/exports/ui-components.coffee b/exports/ui-components.coffee
index f99d80fbd..fdca0c489 100644
--- a/exports/ui-components.coffee
+++ b/exports/ui-components.coffee
@@ -8,6 +8,8 @@ module.exports =
Flexbox: require '../src/components/flexbox'
RetinaImg: require '../src/components/retina-img'
ListTabular: require '../src/components/list-tabular'
- ModelList: require '../src/components/model-list'
+ MultiselectList: require '../src/components/multiselect-list'
+ MultiselectActionBar: require '../src/components/multiselect-action-bar'
ResizableRegion: require '../src/components/resizable-region'
TokenizingTextField: require '../src/components/tokenizing-text-field'
+ EventedIFrame: require '../src/components/evented-iframe'
\ No newline at end of file
diff --git a/internal_packages/account-sidebar/lib/account-sidebar-divider-item.cjsx b/internal_packages/account-sidebar/lib/account-sidebar-divider-item.cjsx
index baad406a9..be4cedb2e 100644
--- a/internal_packages/account-sidebar/lib/account-sidebar-divider-item.cjsx
+++ b/internal_packages/account-sidebar/lib/account-sidebar-divider-item.cjsx
@@ -4,5 +4,7 @@ React = require 'react'
module.exports =
AccountSidebarDividerItem = React.createClass
+ displayName: 'AccountSidebarDividerItem'
+
render: ->
{@props.label}
diff --git a/internal_packages/account-sidebar/lib/account-sidebar-sheet-item.cjsx b/internal_packages/account-sidebar/lib/account-sidebar-sheet-item.cjsx
new file mode 100644
index 000000000..6d4216f8a
--- /dev/null
+++ b/internal_packages/account-sidebar/lib/account-sidebar-sheet-item.cjsx
@@ -0,0 +1,21 @@
+React = require 'react'
+{Actions, Utils, WorkspaceStore} = require 'inbox-exports'
+{RetinaImg} = require 'ui-components'
+
+module.exports =
+AccountSidebarSheetItem = React.createClass
+ displayName: 'AccountSidebarSheetItem'
+
+ render: ->
+ classSet = React.addons.classSet
+ 'item': true
+ 'selected': @props.select
+
+
+
+ {@props.item.name}
+
+
+ _onClick: (event) ->
+ event.preventDefault()
+ Actions.selectRootSheet(@props.item)
diff --git a/internal_packages/account-sidebar/lib/account-sidebar-store.coffee b/internal_packages/account-sidebar/lib/account-sidebar-store.coffee
index e335fac23..b1dcf74db 100644
--- a/internal_packages/account-sidebar/lib/account-sidebar-store.coffee
+++ b/internal_packages/account-sidebar/lib/account-sidebar-store.coffee
@@ -2,6 +2,7 @@ Reflux = require 'reflux'
_ = require 'underscore-plus'
{DatabaseStore,
NamespaceStore,
+ WorkspaceStore,
Actions,
Tag,
Message,
@@ -14,17 +15,17 @@ AccountSidebarStore = Reflux.createStore
@_registerListeners()
@_populate()
- # Keep a cache of unread counts since requesting the number from the
- # server is a fairly expensive operation.
- @_unreadCountCache = {}
- @localDraftsTag = new Tag({id: "drafts", name: "Local Drafts"})
-
-
########### PUBLIC #####################################################
sections: ->
@_sections
+ selected: ->
+ if WorkspaceStore.rootSheet() is WorkspaceStore.Sheet.Threads
+ FocusedTagStore.tag()
+ else
+ WorkspaceStore.rootSheet()
+
########### PRIVATE ####################################################
_setStoreDefaults: ->
@@ -33,6 +34,8 @@ AccountSidebarStore = Reflux.createStore
_registerListeners: ->
@listenTo DatabaseStore, @_onDataChanged
@listenTo NamespaceStore, @_onNamespaceChanged
+ @listenTo WorkspaceStore, @_onWorkspaceChanged
+ @listenTo FocusedTagStore, @_onFocusChange
_populate: ->
namespace = NamespaceStore.current()
@@ -44,7 +47,9 @@ AccountSidebarStore = Reflux.createStore
# We ignore the server drafts so we can use our own localDrafts
tags = _.reject tags, (tag) -> tag.id is "drafts"
- tags.push(@localDraftsTag)
+
+ # We ignore the trash tag because you can't trash anything
+ tags = _.reject tags, (tag) -> tag.id is "trash"
mainTagIDs = ['inbox', 'drafts', 'sent', 'archive']
mainTags = _.filter tags, (tag) -> _.contains(mainTagIDs, tag.id)
@@ -57,10 +62,14 @@ AccountSidebarStore = Reflux.createStore
# Sort user tags by name
userTags = _.sortBy(userTags, 'name')
+ # Find root views, add the Views section
+ rootSheets = _.filter WorkspaceStore.Sheet, (sheet) -> sheet.root and sheet.name
+
lastSections = @_sections
@_sections = [
- { label: 'Mailboxes', tags: mainTags },
- { label: 'Tags', tags: userTags },
+ { label: 'Mailboxes', items: mainTags, type: 'tag' },
+ { label: 'Views', items: rootSheets, type: 'sheet' },
+ { label: 'Tags', items: userTags, type: 'tag' },
]
@trigger(@)
@@ -83,7 +92,6 @@ AccountSidebarStore = Reflux.createStore
@localDraftsTag.unreadCount = count
@trigger(@)
-
_refetchFromAPI: ->
namespace = NamespaceStore.current()
return unless namespace
@@ -96,6 +104,12 @@ AccountSidebarStore = Reflux.createStore
@_populateInboxCount()
@_populate()
+ _onWorkspaceChanged: ->
+ @_populate()
+
+ _onFocusChange: ->
+ @trigger(@)
+
_onDataChanged: (change) ->
@populateInboxCountDebounced ?= _.debounce ->
@_populateInboxCount()
diff --git a/internal_packages/account-sidebar/lib/account-sidebar-tag-item.cjsx b/internal_packages/account-sidebar/lib/account-sidebar-tag-item.cjsx
index e8b58b483..8aa28f79b 100644
--- a/internal_packages/account-sidebar/lib/account-sidebar-tag-item.cjsx
+++ b/internal_packages/account-sidebar/lib/account-sidebar-tag-item.cjsx
@@ -1,32 +1,32 @@
React = require 'react'
-{Actions, Utils} = require 'inbox-exports'
+{Actions, Utils, WorkspaceStore} = require 'inbox-exports'
{RetinaImg} = require 'ui-components'
module.exports =
AccountSidebarTagItem = React.createClass
+ displayName: 'AccountSidebarTagItem'
+
+ shouldComponentUpdate: (nextProps) ->
+ @props?.item.id isnt nextProps.item.id or
+ @props?.item.unreadCount isnt nextProps.item.unreadCount or
+ @props?.select isnt nextProps.select
+
render: ->
unread = []
- if @props.tag.unreadCount > 0
- unread = {@props.tag.unreadCount}
-
- name = if @props.tag.name is "drafts" then "Local Drafts" else @props.tag.name
+ if @props.item.unreadCount > 0
+ unread = {@props.item.unreadCount}
classSet = React.addons.classSet
'item': true
- 'item-tag': true
'selected': @props.select
-
-
-
{name}
+
+
+ {@props.item.name}
{unread}
_onClick: (event) ->
event.preventDefault()
-
- if @props.tag.id is 'drafts'
- Actions.selectView('drafts')
- else
- Actions.selectView('threads')
- Actions.focusTag(@props.tag)
+ Actions.selectRootSheet(WorkspaceStore.Sheet.Threads)
+ Actions.focusTag(@props.item)
diff --git a/internal_packages/account-sidebar/lib/account-sidebar.cjsx b/internal_packages/account-sidebar/lib/account-sidebar.cjsx
index fa455fd38..2405e1dc2 100644
--- a/internal_packages/account-sidebar/lib/account-sidebar.cjsx
+++ b/internal_packages/account-sidebar/lib/account-sidebar.cjsx
@@ -1,7 +1,8 @@
React = require 'react'
-{Actions, FocusedTagStore} = require("inbox-exports")
+{Actions} = require("inbox-exports")
SidebarDividerItem = require("./account-sidebar-divider-item")
SidebarTagItem = require("./account-sidebar-tag-item")
+SidebarSheetItem = require("./account-sidebar-sheet-item")
SidebarStore = require ("./account-sidebar-store")
module.exports =
@@ -13,14 +14,12 @@ AccountSidebar = React.createClass
componentDidMount: ->
@unsubscribe = SidebarStore.listen @_onStoreChange
- @unsubscribe_focus = FocusedTagStore.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
- @unsubscribe_focus() if @unsubscribe_focus
render: ->