2015-07-22 05:16:11 +08:00
|
|
|
_ = require 'underscore'
|
|
|
|
React = require 'react'
|
|
|
|
|
2015-07-24 02:47:46 +08:00
|
|
|
{Utils,
|
2015-09-11 01:34:09 +08:00
|
|
|
Label,
|
|
|
|
Folder,
|
2015-07-24 02:47:46 +08:00
|
|
|
Thread,
|
|
|
|
Actions,
|
2015-07-22 05:16:11 +08:00
|
|
|
TaskQueue,
|
2015-10-22 01:38:00 +08:00
|
|
|
TaskFactory,
|
feat(accounts): Kill namespaces, long live accounts
Summary:
This diff replaces the Namespace object with the Account object, and changes all references to namespace_id => account_id, etc. The endpoints are now `/threads` instead of `/n/<id>/threads`.
This diff also adds preliminary support for multiple accounts. When you log in, we now log you in to all the attached accounts on edgehill server. From the preferences panel, you can auth with / unlink additional accounts. Shockingly, this all seems to pretty much work.
When replying to a thread, you cannot switch from addresses. However, when creating a new message in a popout composer, you can change the from address and the SaveDraftTask will delete/re-root the draft on the new account.
Search bar doesn't need to do full refresh on clear if it never committed
Allow drafts to be switched to a different account when not in reply to an existing thread
Fix edge case where ChangeMailTask throws exception if no models are modified during performLocal
Show many dots for many accounts in long polling status bar
add/remove accounts from prefs
Spec fixes!
Test Plan: Run tests, none broken!
Reviewers: evan, dillon
Reviewed By: evan, dillon
Differential Revision: https://phab.nylas.com/D1928
2015-08-22 06:29:58 +08:00
|
|
|
AccountStore,
|
2015-09-11 01:34:09 +08:00
|
|
|
CategoryStore,
|
|
|
|
DatabaseStore,
|
2015-07-24 02:47:46 +08:00
|
|
|
WorkspaceStore,
|
2015-09-11 01:34:09 +08:00
|
|
|
SyncbackCategoryTask,
|
|
|
|
TaskQueueStatusStore,
|
2016-01-09 06:58:31 +08:00
|
|
|
FocusedPerspectiveStore} = require 'nylas-exports'
|
2015-07-22 05:16:11 +08:00
|
|
|
|
|
|
|
{Menu,
|
|
|
|
Popover,
|
2015-07-24 02:47:46 +08:00
|
|
|
RetinaImg,
|
2015-11-07 03:47:06 +08:00
|
|
|
KeyCommandsRegion,
|
2015-07-24 02:47:46 +08:00
|
|
|
LabelColorizer} = require 'nylas-component-kit'
|
2015-07-22 05:16:11 +08:00
|
|
|
|
|
|
|
# This changes the category on one or more threads.
|
|
|
|
class CategoryPicker extends React.Component
|
|
|
|
@displayName: "CategoryPicker"
|
|
|
|
@containerRequired: false
|
|
|
|
|
|
|
|
constructor: (@props) ->
|
|
|
|
@state = _.extend @_recalculateState(@props), searchValue: ""
|
|
|
|
|
2015-07-24 02:47:46 +08:00
|
|
|
@contextTypes:
|
|
|
|
sheetDepth: React.PropTypes.number
|
|
|
|
|
2016-01-09 01:31:24 +08:00
|
|
|
# If the threads we're picking categories for change, (like when they
|
|
|
|
# get their categories updated), we expect our parents to pass us new
|
|
|
|
# props. We don't listen to the DatabaseStore ourselves.
|
2015-07-22 05:16:11 +08:00
|
|
|
componentWillReceiveProps: (nextProps) ->
|
|
|
|
@setState @_recalculateState(nextProps)
|
|
|
|
|
|
|
|
componentWillUnmount: =>
|
|
|
|
return unless @unsubscribers
|
|
|
|
unsubscribe() for unsubscribe in @unsubscribers
|
2015-11-07 03:47:06 +08:00
|
|
|
|
|
|
|
_keymapHandlers: ->
|
|
|
|
"application:change-category": @_onOpenCategoryPopover
|
2015-07-22 05:16:11 +08:00
|
|
|
|
|
|
|
render: =>
|
2016-01-09 01:31:24 +08:00
|
|
|
btnClasses = "btn btn-toolbar"
|
|
|
|
btnClasses += " btn-disabled" if @state.disabled
|
|
|
|
button = <button className={btnClasses} title={tooltip}>
|
|
|
|
<RetinaImg name={img} mode={RetinaImg.Mode.ContentIsMask}/>
|
|
|
|
</button>
|
|
|
|
return button if @state.disabled or not @_account?
|
2015-07-24 02:47:46 +08:00
|
|
|
|
feat(accounts): Kill namespaces, long live accounts
Summary:
This diff replaces the Namespace object with the Account object, and changes all references to namespace_id => account_id, etc. The endpoints are now `/threads` instead of `/n/<id>/threads`.
This diff also adds preliminary support for multiple accounts. When you log in, we now log you in to all the attached accounts on edgehill server. From the preferences panel, you can auth with / unlink additional accounts. Shockingly, this all seems to pretty much work.
When replying to a thread, you cannot switch from addresses. However, when creating a new message in a popout composer, you can change the from address and the SaveDraftTask will delete/re-root the draft on the new account.
Search bar doesn't need to do full refresh on clear if it never committed
Allow drafts to be switched to a different account when not in reply to an existing thread
Fix edge case where ChangeMailTask throws exception if no models are modified during performLocal
Show many dots for many accounts in long polling status bar
add/remove accounts from prefs
Spec fixes!
Test Plan: Run tests, none broken!
Reviewers: evan, dillon
Reviewed By: evan, dillon
Differential Revision: https://phab.nylas.com/D1928
2015-08-22 06:29:58 +08:00
|
|
|
if @_account?.usesLabels()
|
2015-10-22 02:33:33 +08:00
|
|
|
img = "toolbar-tag.png"
|
2015-07-24 02:47:46 +08:00
|
|
|
tooltip = "Apply Labels"
|
|
|
|
placeholder = "Label as"
|
feat(accounts): Kill namespaces, long live accounts
Summary:
This diff replaces the Namespace object with the Account object, and changes all references to namespace_id => account_id, etc. The endpoints are now `/threads` instead of `/n/<id>/threads`.
This diff also adds preliminary support for multiple accounts. When you log in, we now log you in to all the attached accounts on edgehill server. From the preferences panel, you can auth with / unlink additional accounts. Shockingly, this all seems to pretty much work.
When replying to a thread, you cannot switch from addresses. However, when creating a new message in a popout composer, you can change the from address and the SaveDraftTask will delete/re-root the draft on the new account.
Search bar doesn't need to do full refresh on clear if it never committed
Allow drafts to be switched to a different account when not in reply to an existing thread
Fix edge case where ChangeMailTask throws exception if no models are modified during performLocal
Show many dots for many accounts in long polling status bar
add/remove accounts from prefs
Spec fixes!
Test Plan: Run tests, none broken!
Reviewers: evan, dillon
Reviewed By: evan, dillon
Differential Revision: https://phab.nylas.com/D1928
2015-08-22 06:29:58 +08:00
|
|
|
else if @_account?.usesFolders()
|
2015-10-22 02:33:33 +08:00
|
|
|
img = "toolbar-movetofolder.png"
|
2015-07-24 02:47:46 +08:00
|
|
|
tooltip = "Move to Folder"
|
|
|
|
placeholder = "Move to folder"
|
|
|
|
else
|
|
|
|
img = ""
|
|
|
|
tooltip = ""
|
|
|
|
placeholder = ""
|
|
|
|
|
|
|
|
if @state.isPopoverOpen then tooltip = ""
|
|
|
|
|
2015-07-22 05:16:11 +08:00
|
|
|
headerComponents = [
|
|
|
|
<input type="text"
|
|
|
|
tabIndex="1"
|
|
|
|
key="textfield"
|
|
|
|
className="search"
|
2015-07-24 02:47:46 +08:00
|
|
|
placeholder={placeholder}
|
2015-07-22 05:16:11 +08:00
|
|
|
value={@state.searchValue}
|
|
|
|
onChange={@_onSearchValueChange}/>
|
|
|
|
]
|
|
|
|
|
2015-11-07 03:47:06 +08:00
|
|
|
<KeyCommandsRegion globalHandlers={@_keymapHandlers()}>
|
|
|
|
<Popover className="category-picker"
|
|
|
|
ref="popover"
|
|
|
|
onOpened={@_onPopoverOpened}
|
|
|
|
onClosed={@_onPopoverClosed}
|
|
|
|
direction="down-align-left"
|
|
|
|
style={order: -103}
|
|
|
|
buttonComponent={button}>
|
|
|
|
<Menu ref="menu"
|
|
|
|
headerComponents={headerComponents}
|
|
|
|
footerComponents={[]}
|
|
|
|
items={@state.categoryData}
|
|
|
|
itemKey={ (item) -> item.id }
|
|
|
|
itemContent={@_renderItemContent}
|
|
|
|
onSelect={@_onSelectCategory}
|
|
|
|
defaultSelectedIndex={if @state.searchValue is "" then -1 else 0}
|
|
|
|
/>
|
|
|
|
</Popover>
|
|
|
|
</KeyCommandsRegion>
|
2015-07-22 05:16:11 +08:00
|
|
|
|
2015-07-24 02:47:46 +08:00
|
|
|
_onOpenCategoryPopover: =>
|
2015-07-22 05:16:11 +08:00
|
|
|
return unless @_threads().length > 0
|
2015-07-24 02:47:46 +08:00
|
|
|
return unless @context.sheetDepth is WorkspaceStore.sheetStack().length - 1
|
2015-07-22 05:16:11 +08:00
|
|
|
@refs.popover.open()
|
2015-07-24 02:47:46 +08:00
|
|
|
return
|
|
|
|
|
2015-08-04 08:05:31 +08:00
|
|
|
_renderItemContent: (item) =>
|
|
|
|
if item.divider
|
2015-09-11 01:34:09 +08:00
|
|
|
return <Menu.Item key={item.id} divider={item.divider} />
|
|
|
|
else if item.newCategoryItem
|
|
|
|
return @_renderCreateNewItem(item)
|
|
|
|
|
feat(accounts): Kill namespaces, long live accounts
Summary:
This diff replaces the Namespace object with the Account object, and changes all references to namespace_id => account_id, etc. The endpoints are now `/threads` instead of `/n/<id>/threads`.
This diff also adds preliminary support for multiple accounts. When you log in, we now log you in to all the attached accounts on edgehill server. From the preferences panel, you can auth with / unlink additional accounts. Shockingly, this all seems to pretty much work.
When replying to a thread, you cannot switch from addresses. However, when creating a new message in a popout composer, you can change the from address and the SaveDraftTask will delete/re-root the draft on the new account.
Search bar doesn't need to do full refresh on clear if it never committed
Allow drafts to be switched to a different account when not in reply to an existing thread
Fix edge case where ChangeMailTask throws exception if no models are modified during performLocal
Show many dots for many accounts in long polling status bar
add/remove accounts from prefs
Spec fixes!
Test Plan: Run tests, none broken!
Reviewers: evan, dillon
Reviewed By: evan, dillon
Differential Revision: https://phab.nylas.com/D1928
2015-08-22 06:29:58 +08:00
|
|
|
if @_account?.usesLabels()
|
2015-08-04 08:05:31 +08:00
|
|
|
icon = @_renderCheckbox(item)
|
feat(accounts): Kill namespaces, long live accounts
Summary:
This diff replaces the Namespace object with the Account object, and changes all references to namespace_id => account_id, etc. The endpoints are now `/threads` instead of `/n/<id>/threads`.
This diff also adds preliminary support for multiple accounts. When you log in, we now log you in to all the attached accounts on edgehill server. From the preferences panel, you can auth with / unlink additional accounts. Shockingly, this all seems to pretty much work.
When replying to a thread, you cannot switch from addresses. However, when creating a new message in a popout composer, you can change the from address and the SaveDraftTask will delete/re-root the draft on the new account.
Search bar doesn't need to do full refresh on clear if it never committed
Allow drafts to be switched to a different account when not in reply to an existing thread
Fix edge case where ChangeMailTask throws exception if no models are modified during performLocal
Show many dots for many accounts in long polling status bar
add/remove accounts from prefs
Spec fixes!
Test Plan: Run tests, none broken!
Reviewers: evan, dillon
Reviewed By: evan, dillon
Differential Revision: https://phab.nylas.com/D1928
2015-08-22 06:29:58 +08:00
|
|
|
else if @_account?.usesFolders()
|
2015-08-04 08:05:31 +08:00
|
|
|
icon = @_renderFolderIcon(item)
|
2015-07-24 02:47:46 +08:00
|
|
|
else return <span></span>
|
|
|
|
|
|
|
|
<div className="category-item">
|
|
|
|
{icon}
|
|
|
|
<div className="category-display-name">
|
2015-08-04 08:05:31 +08:00
|
|
|
{@_renderBoldedSearchResults(item)}
|
2015-07-24 02:47:46 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2015-09-11 01:34:09 +08:00
|
|
|
_renderCreateNewItem: ({searchValue, name}) =>
|
|
|
|
if @_account?.usesLabels()
|
|
|
|
picName = "tag"
|
|
|
|
else if @_account?.usesFolders()
|
|
|
|
picName = "folder"
|
|
|
|
|
|
|
|
<div className="category-item category-create-new">
|
|
|
|
<RetinaImg className={"category-create-new-#{picName}"}
|
|
|
|
name={"#{picName}.png"}
|
|
|
|
mode={RetinaImg.Mode.ContentIsMask} />
|
|
|
|
<div className="category-display-name">
|
|
|
|
<strong>“{searchValue}”</strong> (create new)
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2015-08-04 08:05:31 +08:00
|
|
|
_renderCheckbox: (item) ->
|
2015-07-24 02:47:46 +08:00
|
|
|
styles = {}
|
2015-08-04 08:05:31 +08:00
|
|
|
styles.backgroundColor = item.backgroundColor
|
2015-07-24 02:47:46 +08:00
|
|
|
|
2015-08-04 08:05:31 +08:00
|
|
|
if item.usage is 0
|
2015-07-24 02:47:46 +08:00
|
|
|
checkStatus = <span></span>
|
2015-08-04 08:05:31 +08:00
|
|
|
else if item.usage < item.numThreads
|
2015-07-24 02:47:46 +08:00
|
|
|
checkStatus = <RetinaImg
|
|
|
|
className="check-img dash"
|
|
|
|
name="tagging-conflicted.png"
|
|
|
|
mode={RetinaImg.Mode.ContentPreserve}
|
2015-08-04 08:05:31 +08:00
|
|
|
onClick={=> @_onSelectCategory(item)}/>
|
2015-07-24 02:47:46 +08:00
|
|
|
else
|
|
|
|
checkStatus = <RetinaImg
|
|
|
|
className="check-img check"
|
|
|
|
name="tagging-checkmark.png"
|
|
|
|
mode={RetinaImg.Mode.ContentPreserve}
|
2015-08-04 08:05:31 +08:00
|
|
|
onClick={=> @_onSelectCategory(item)}/>
|
2015-07-24 02:47:46 +08:00
|
|
|
|
|
|
|
<div className="check-wrap" style={styles}>
|
|
|
|
<RetinaImg
|
|
|
|
className="check-img check"
|
|
|
|
name="tagging-checkbox.png"
|
|
|
|
mode={RetinaImg.Mode.ContentPreserve}
|
2015-08-04 08:05:31 +08:00
|
|
|
onClick={=> @_onSelectCategory(item)}/>
|
2015-07-24 02:47:46 +08:00
|
|
|
{checkStatus}
|
|
|
|
</div>
|
|
|
|
|
2015-08-04 08:05:31 +08:00
|
|
|
_renderFolderIcon: (item) ->
|
|
|
|
<RetinaImg name={"#{item.name}.png"} fallback={'folder.png'} mode={RetinaImg.Mode.ContentIsMask} />
|
2015-07-24 02:47:46 +08:00
|
|
|
|
2015-08-04 08:05:31 +08:00
|
|
|
_renderBoldedSearchResults: (item) ->
|
|
|
|
name = item.display_name
|
2015-07-24 02:47:46 +08:00
|
|
|
searchTerm = (@state.searchValue ? "").trim()
|
|
|
|
|
|
|
|
return name if searchTerm.length is 0
|
|
|
|
|
|
|
|
re = Utils.wordSearchRegExp(searchTerm)
|
|
|
|
parts = name.split(re).map (part) ->
|
|
|
|
# The wordSearchRegExp looks for a leading non-word character to
|
|
|
|
# deterine if it's a valid place to search. As such, we need to not
|
|
|
|
# include that leading character as part of our match.
|
|
|
|
if re.test(part)
|
|
|
|
if /\W/.test(part[0])
|
|
|
|
return <span>{part[0]}<strong>{part[1..-1]}</strong></span>
|
|
|
|
else
|
|
|
|
return <strong>{part}</strong>
|
|
|
|
else return part
|
|
|
|
return <span>{parts}</span>
|
2015-07-22 05:16:11 +08:00
|
|
|
|
2015-08-04 08:05:31 +08:00
|
|
|
_onSelectCategory: (item) =>
|
2015-10-22 01:38:00 +08:00
|
|
|
threads = @_threads()
|
|
|
|
|
|
|
|
return unless threads.length > 0
|
feat(accounts): Kill namespaces, long live accounts
Summary:
This diff replaces the Namespace object with the Account object, and changes all references to namespace_id => account_id, etc. The endpoints are now `/threads` instead of `/n/<id>/threads`.
This diff also adds preliminary support for multiple accounts. When you log in, we now log you in to all the attached accounts on edgehill server. From the preferences panel, you can auth with / unlink additional accounts. Shockingly, this all seems to pretty much work.
When replying to a thread, you cannot switch from addresses. However, when creating a new message in a popout composer, you can change the from address and the SaveDraftTask will delete/re-root the draft on the new account.
Search bar doesn't need to do full refresh on clear if it never committed
Allow drafts to be switched to a different account when not in reply to an existing thread
Fix edge case where ChangeMailTask throws exception if no models are modified during performLocal
Show many dots for many accounts in long polling status bar
add/remove accounts from prefs
Spec fixes!
Test Plan: Run tests, none broken!
Reviewers: evan, dillon
Reviewed By: evan, dillon
Differential Revision: https://phab.nylas.com/D1928
2015-08-22 06:29:58 +08:00
|
|
|
return unless @_account
|
2015-07-22 05:16:11 +08:00
|
|
|
@refs.menu.setSelectedItem(null)
|
|
|
|
|
2015-10-22 01:38:00 +08:00
|
|
|
if item.newCategoryItem
|
2016-01-09 01:31:24 +08:00
|
|
|
CategoryClass = @_account.categoryClass()
|
2015-10-22 01:57:42 +08:00
|
|
|
category = new CategoryClass
|
2015-10-22 01:38:00 +08:00
|
|
|
displayName: @state.searchValue,
|
2016-01-09 01:31:24 +08:00
|
|
|
accountId: @_account.id
|
2015-10-22 01:57:42 +08:00
|
|
|
|
2015-10-22 01:38:00 +08:00
|
|
|
syncbackTask = new SyncbackCategoryTask({category})
|
|
|
|
TaskQueueStatusStore.waitForPerformRemote(syncbackTask).then =>
|
|
|
|
DatabaseStore.findBy(category.constructor, clientId: category.clientId).then (category) =>
|
|
|
|
applyTask = TaskFactory.taskForApplyingCategory
|
|
|
|
threads: threads
|
|
|
|
category: category
|
|
|
|
Actions.queueTask(applyTask)
|
|
|
|
Actions.queueTask(syncbackTask)
|
|
|
|
|
|
|
|
else if item.usage is threads.length
|
|
|
|
applyTask = TaskFactory.taskForRemovingCategory
|
|
|
|
threads: threads
|
|
|
|
category: item.category
|
|
|
|
Actions.queueTask(applyTask)
|
2015-07-22 05:16:11 +08:00
|
|
|
|
2015-08-04 08:05:31 +08:00
|
|
|
else
|
2015-10-22 01:38:00 +08:00
|
|
|
applyTask = TaskFactory.taskForApplyingCategory
|
|
|
|
threads: threads
|
|
|
|
category: item.category
|
|
|
|
Actions.queueTask(applyTask)
|
2015-07-22 05:16:11 +08:00
|
|
|
|
2015-07-24 02:47:46 +08:00
|
|
|
@refs.popover.close()
|
2015-07-22 05:16:11 +08:00
|
|
|
|
|
|
|
_onSearchValueChange: (event) =>
|
|
|
|
@setState @_recalculateState(@props, searchValue: event.target.value)
|
|
|
|
|
|
|
|
_onPopoverOpened: =>
|
|
|
|
@setState @_recalculateState(@props, searchValue: "")
|
2015-07-24 02:47:46 +08:00
|
|
|
@setState isPopoverOpen: true
|
|
|
|
|
|
|
|
_onPopoverClosed: =>
|
|
|
|
@setState isPopoverOpen: false
|
2015-07-22 05:16:11 +08:00
|
|
|
|
|
|
|
_recalculateState: (props=@props, {searchValue}={}) =>
|
2016-01-09 01:31:24 +08:00
|
|
|
threads = @_threads(props)
|
|
|
|
@_account = AccountStore.accountForItems(threads)
|
|
|
|
return {disabled: true} unless @_account
|
|
|
|
|
2015-07-22 05:16:11 +08:00
|
|
|
searchValue = searchValue ? @state?.searchValue ? ""
|
2016-01-09 01:31:24 +08:00
|
|
|
numThreads = threads.length
|
2015-07-24 02:47:46 +08:00
|
|
|
if numThreads is 0
|
2015-07-22 05:16:11 +08:00
|
|
|
return {categoryData: [], searchValue}
|
2015-08-04 08:05:31 +08:00
|
|
|
|
2015-12-03 03:43:37 +08:00
|
|
|
if @_account.usesLabels()
|
2016-01-09 01:31:24 +08:00
|
|
|
categories = CategoryStore.categories(@_account)
|
2015-12-03 03:43:37 +08:00
|
|
|
else
|
2016-01-09 01:31:24 +08:00
|
|
|
categories = CategoryStore.standardCategories(@_account)
|
2015-12-03 03:43:37 +08:00
|
|
|
.concat([{divider: true, id: "category-divider"}])
|
2016-01-09 01:31:24 +08:00
|
|
|
.concat(CategoryStore.userCategories(@_account))
|
2015-07-24 02:47:46 +08:00
|
|
|
|
2015-07-22 05:16:11 +08:00
|
|
|
usageCount = @_categoryUsageCount(props, categories)
|
2015-07-24 02:47:46 +08:00
|
|
|
|
|
|
|
allInInbox = @_allInInbox(usageCount, numThreads)
|
|
|
|
|
|
|
|
displayData = {usageCount, numThreads}
|
|
|
|
|
2015-07-22 05:16:11 +08:00
|
|
|
categoryData = _.chain(categories)
|
2015-07-24 02:47:46 +08:00
|
|
|
.filter(_.partial(@_isUserFacing, allInInbox))
|
2015-07-22 05:16:11 +08:00
|
|
|
.filter(_.partial(@_isInSearch, searchValue))
|
2015-08-04 08:05:31 +08:00
|
|
|
.map(_.partial(@_itemForCategory, displayData))
|
2015-07-22 05:16:11 +08:00
|
|
|
.value()
|
|
|
|
|
2015-09-11 01:34:09 +08:00
|
|
|
if searchValue.length > 0
|
|
|
|
newItemData =
|
|
|
|
searchValue: searchValue
|
|
|
|
newCategoryItem: true
|
|
|
|
id: "category-create-new"
|
|
|
|
categoryData.push(newItemData)
|
|
|
|
|
2016-01-09 01:31:24 +08:00
|
|
|
return {categoryData, searchValue, disabled: false}
|
2015-07-22 05:16:11 +08:00
|
|
|
|
|
|
|
_categoryUsageCount: (props, categories) =>
|
|
|
|
categoryUsageCount = {}
|
|
|
|
_.flatten(@_threads(props).map(@_threadCategories)).forEach (category) ->
|
|
|
|
categoryUsageCount[category.id] ?= 0
|
|
|
|
categoryUsageCount[category.id] += 1
|
|
|
|
return categoryUsageCount
|
|
|
|
|
|
|
|
_isInSearch: (searchValue, category) ->
|
2015-07-24 02:47:46 +08:00
|
|
|
return Utils.wordSearchRegExp(searchValue).test(category.displayName)
|
|
|
|
|
|
|
|
_isUserFacing: (allInInbox, category) =>
|
|
|
|
hiddenCategories = []
|
2016-01-09 06:58:31 +08:00
|
|
|
currentCategoryId = FocusedPerspectiveStore.current()?.categoryId()
|
2015-10-03 06:01:26 +08:00
|
|
|
|
feat(accounts): Kill namespaces, long live accounts
Summary:
This diff replaces the Namespace object with the Account object, and changes all references to namespace_id => account_id, etc. The endpoints are now `/threads` instead of `/n/<id>/threads`.
This diff also adds preliminary support for multiple accounts. When you log in, we now log you in to all the attached accounts on edgehill server. From the preferences panel, you can auth with / unlink additional accounts. Shockingly, this all seems to pretty much work.
When replying to a thread, you cannot switch from addresses. However, when creating a new message in a popout composer, you can change the from address and the SaveDraftTask will delete/re-root the draft on the new account.
Search bar doesn't need to do full refresh on clear if it never committed
Allow drafts to be switched to a different account when not in reply to an existing thread
Fix edge case where ChangeMailTask throws exception if no models are modified during performLocal
Show many dots for many accounts in long polling status bar
add/remove accounts from prefs
Spec fixes!
Test Plan: Run tests, none broken!
Reviewers: evan, dillon
Reviewed By: evan, dillon
Differential Revision: https://phab.nylas.com/D1928
2015-08-22 06:29:58 +08:00
|
|
|
if @_account?.usesLabels()
|
2015-12-03 03:43:37 +08:00
|
|
|
hiddenCategories = ["all", "drafts", "sent", "archive", "starred", "important"]
|
|
|
|
hiddenCategories.push("inbox") if allInInbox
|
2015-07-24 02:47:46 +08:00
|
|
|
return false if category.divider
|
feat(accounts): Kill namespaces, long live accounts
Summary:
This diff replaces the Namespace object with the Account object, and changes all references to namespace_id => account_id, etc. The endpoints are now `/threads` instead of `/n/<id>/threads`.
This diff also adds preliminary support for multiple accounts. When you log in, we now log you in to all the attached accounts on edgehill server. From the preferences panel, you can auth with / unlink additional accounts. Shockingly, this all seems to pretty much work.
When replying to a thread, you cannot switch from addresses. However, when creating a new message in a popout composer, you can change the from address and the SaveDraftTask will delete/re-root the draft on the new account.
Search bar doesn't need to do full refresh on clear if it never committed
Allow drafts to be switched to a different account when not in reply to an existing thread
Fix edge case where ChangeMailTask throws exception if no models are modified during performLocal
Show many dots for many accounts in long polling status bar
add/remove accounts from prefs
Spec fixes!
Test Plan: Run tests, none broken!
Reviewers: evan, dillon
Reviewed By: evan, dillon
Differential Revision: https://phab.nylas.com/D1928
2015-08-22 06:29:58 +08:00
|
|
|
else if @_account?.usesFolders()
|
2015-07-24 02:47:46 +08:00
|
|
|
hiddenCategories = ["drafts", "sent"]
|
|
|
|
|
|
|
|
return (category.name not in hiddenCategories) and (category.id isnt currentCategoryId)
|
|
|
|
|
|
|
|
_allInInbox: (usageCount, numThreads) ->
|
2016-01-09 01:31:24 +08:00
|
|
|
return unless @_account?
|
|
|
|
inbox = CategoryStore.getStandardCategory(@_account, "inbox")
|
2015-09-10 06:20:34 +08:00
|
|
|
return false unless inbox
|
2015-07-24 02:47:46 +08:00
|
|
|
return usageCount[inbox.id] is numThreads
|
|
|
|
|
2015-08-04 08:05:31 +08:00
|
|
|
_itemForCategory: ({usageCount, numThreads}, category) ->
|
2015-07-24 02:47:46 +08:00
|
|
|
return category if category.divider
|
2015-08-04 08:05:31 +08:00
|
|
|
|
|
|
|
item = category.toJSON()
|
|
|
|
item.category = category
|
|
|
|
item.backgroundColor = LabelColorizer.backgroundColorDark(category)
|
|
|
|
item.usage = usageCount[category.id] ? 0
|
|
|
|
item.numThreads = numThreads
|
|
|
|
item
|
2015-07-22 05:16:11 +08:00
|
|
|
|
|
|
|
_threadCategories: (thread) =>
|
feat(accounts): Kill namespaces, long live accounts
Summary:
This diff replaces the Namespace object with the Account object, and changes all references to namespace_id => account_id, etc. The endpoints are now `/threads` instead of `/n/<id>/threads`.
This diff also adds preliminary support for multiple accounts. When you log in, we now log you in to all the attached accounts on edgehill server. From the preferences panel, you can auth with / unlink additional accounts. Shockingly, this all seems to pretty much work.
When replying to a thread, you cannot switch from addresses. However, when creating a new message in a popout composer, you can change the from address and the SaveDraftTask will delete/re-root the draft on the new account.
Search bar doesn't need to do full refresh on clear if it never committed
Allow drafts to be switched to a different account when not in reply to an existing thread
Fix edge case where ChangeMailTask throws exception if no models are modified during performLocal
Show many dots for many accounts in long polling status bar
add/remove accounts from prefs
Spec fixes!
Test Plan: Run tests, none broken!
Reviewers: evan, dillon
Reviewed By: evan, dillon
Differential Revision: https://phab.nylas.com/D1928
2015-08-22 06:29:58 +08:00
|
|
|
if @_account.usesLabels()
|
2015-07-22 05:16:11 +08:00
|
|
|
return (thread.labels ? [])
|
feat(accounts): Kill namespaces, long live accounts
Summary:
This diff replaces the Namespace object with the Account object, and changes all references to namespace_id => account_id, etc. The endpoints are now `/threads` instead of `/n/<id>/threads`.
This diff also adds preliminary support for multiple accounts. When you log in, we now log you in to all the attached accounts on edgehill server. From the preferences panel, you can auth with / unlink additional accounts. Shockingly, this all seems to pretty much work.
When replying to a thread, you cannot switch from addresses. However, when creating a new message in a popout composer, you can change the from address and the SaveDraftTask will delete/re-root the draft on the new account.
Search bar doesn't need to do full refresh on clear if it never committed
Allow drafts to be switched to a different account when not in reply to an existing thread
Fix edge case where ChangeMailTask throws exception if no models are modified during performLocal
Show many dots for many accounts in long polling status bar
add/remove accounts from prefs
Spec fixes!
Test Plan: Run tests, none broken!
Reviewers: evan, dillon
Reviewed By: evan, dillon
Differential Revision: https://phab.nylas.com/D1928
2015-08-22 06:29:58 +08:00
|
|
|
else if @_account.usesFolders()
|
2015-07-22 05:16:11 +08:00
|
|
|
return (thread.folders ? [])
|
|
|
|
else throw new Error("Invalid organizationUnit")
|
|
|
|
|
2015-08-04 08:05:31 +08:00
|
|
|
_threads: (props = @props) =>
|
2015-07-24 02:47:46 +08:00
|
|
|
if props.items then return (props.items ? [])
|
2015-07-22 05:16:11 +08:00
|
|
|
else if props.thread then return [props.thread]
|
|
|
|
else return []
|
|
|
|
|
|
|
|
module.exports = CategoryPicker
|