mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-14 13:44:41 +08:00
f12896d54f
Summary: - In Gmail all threads /must/ belong to either All Mail, Trash and Spam, and they are mutually exclusive, so we need to make sure that any add/remove label operation still guarantees that constraint - Update ChangeLabelsTask to modify the set of labels to add and remove based on this rule - Update tasksFor archiving, moving to trash and moving to spam so they don't affect any other labels in the thread, as gmail does. - Removing from view /will/ remove any current labels, but will also move between all mail and trash as needed - Remove Inbox, Trash and Spam from the CategoryPicker, as Gmail does Test Plan: - Unit tests Reviewers: drew, evan, bengotow Reviewed By: drew, evan, bengotow Differential Revision: https://phab.nylas.com/D2715
62 lines
1.7 KiB
CoffeeScript
62 lines
1.7 KiB
CoffeeScript
React = require 'react'
|
|
{Actions,
|
|
CategoryStore,
|
|
TaskFactory,
|
|
AccountStore,
|
|
FocusedPerspectiveStore} = require 'nylas-exports'
|
|
|
|
class ThreadArchiveQuickAction extends React.Component
|
|
@displayName: 'ThreadArchiveQuickAction'
|
|
@propTypes:
|
|
thread: React.PropTypes.object
|
|
|
|
render: =>
|
|
canArchiveThreads = FocusedPerspectiveStore.current().canArchiveThreads([@props.thread])
|
|
return <span /> unless canArchiveThreads
|
|
|
|
<div
|
|
key="archive"
|
|
title="Archive"
|
|
style={{ order: 100 }}
|
|
className="btn action action-archive"
|
|
onClick={@_onArchive} />
|
|
|
|
shouldComponentUpdate: (newProps, newState) ->
|
|
newProps.thread.id isnt @props?.thread.id
|
|
|
|
_onArchive: (event) =>
|
|
tasks = TaskFactory.tasksForArchiving
|
|
threads: [@props.thread]
|
|
Actions.queueTasks(tasks)
|
|
|
|
# Don't trigger the thread row click
|
|
event.stopPropagation()
|
|
|
|
class ThreadTrashQuickAction extends React.Component
|
|
@displayName: 'ThreadTrashQuickAction'
|
|
@propTypes:
|
|
thread: React.PropTypes.object
|
|
|
|
render: =>
|
|
canTrashThreads = FocusedPerspectiveStore.current().canTrashThreads([@props.thread])
|
|
return <span /> unless canTrashThreads
|
|
|
|
<div
|
|
key="remove"
|
|
title="Trash"
|
|
style={{ order: 110 }}
|
|
className='btn action action-trash'
|
|
onClick={@_onRemove} />
|
|
|
|
shouldComponentUpdate: (newProps, newState) ->
|
|
newProps.thread.id isnt @props?.thread.id
|
|
|
|
_onRemove: (event) =>
|
|
tasks = TaskFactory.tasksForMovingToTrash
|
|
threads: [@props.thread]
|
|
Actions.queueTasks(tasks)
|
|
|
|
# Don't trigger the thread row click
|
|
event.stopPropagation()
|
|
|
|
module.exports = { ThreadArchiveQuickAction, ThreadTrashQuickAction }
|