mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 12:40:08 +08:00
e09d3e3e75
Summary: This diff centralizes logic for creating common tasks for things like moving to trash, archive, etc. TaskFactory exposes a set of convenience methods and hides the whole "and also remove the current label" business from the user. This diff also formally separates the concept of "moving to trash" and "archiving" so that "remove" isn't used in an unclear way. I also refactored where selection is managed. Previously you'd fire some action like archiveSelection and it'd clear the selection, but if you selected some items and used another method to archive a few, they were still selected. The selection is now bound to the ModelView as intended, so if items are removed from the modelView, they are removed from it's attached selection. This means that it shouldn't /technically/ be possible to have selected items which are not in view. I haven't refactored the tests yet. They are likely broken... Fix next/prev logic Test Plan: Run tests Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D2157
35 lines
988 B
CoffeeScript
35 lines
988 B
CoffeeScript
_ = require 'underscore'
|
|
React = require 'react'
|
|
{RetinaImg} = require 'nylas-component-kit'
|
|
{Actions,
|
|
TaskFactory,
|
|
DOMUtils,
|
|
FocusedMailViewStore} = require 'nylas-exports'
|
|
|
|
class ThreadArchiveButton extends React.Component
|
|
@displayName: "ThreadArchiveButton"
|
|
@containerRequired: false
|
|
|
|
@propTypes:
|
|
thread: React.PropTypes.object.isRequired
|
|
|
|
render: =>
|
|
return false unless FocusedMailViewStore.mailView()?.canArchiveThreads()
|
|
|
|
<button className="btn btn-toolbar btn-archive"
|
|
style={order: -107}
|
|
data-tooltip="Archive"
|
|
onClick={@_onArchive}>
|
|
<RetinaImg name="toolbar-archive.png" mode={RetinaImg.Mode.ContentIsMask}/>
|
|
</button>
|
|
|
|
_onArchive: (e) =>
|
|
return unless DOMUtils.nodeIsVisible(e.currentTarget)
|
|
task = TaskFactory.taskForArchiving
|
|
threads: [@props.thread],
|
|
fromView: FocusedMailViewStore.mailView()
|
|
Actions.queueTask(task)
|
|
e.stopPropagation()
|
|
|
|
|
|
module.exports = ThreadArchiveButton
|