mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-10-09 04:44:32 +08:00
Delete button now appears when drafts are selected
Summary: Fixes T2230 Support for deleting multiple drafts in the local drafts view Test Plan: tested manually Reviewers: bengotow, evan Reviewed By: evan Subscribers: gleb Maniphest Tasks: T2230 Differential Revision: https://phab.nylas.com/D1714
This commit is contained in:
parent
786ae7441d
commit
a54bdc94fd
5 changed files with 48 additions and 1 deletions
25
internal_packages/thread-list/lib/draft-buttons.cjsx
Normal file
25
internal_packages/thread-list/lib/draft-buttons.cjsx
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
React = require "react/addons"
|
||||||
|
classNames = require 'classnames'
|
||||||
|
DraftListStore = require './draft-list-store'
|
||||||
|
{RetinaImg} = require 'nylas-component-kit'
|
||||||
|
{Actions, FocusedContentStore} = require "nylas-exports"
|
||||||
|
|
||||||
|
class DraftDeleteButton extends React.Component
|
||||||
|
@displayName: 'DraftDeleteButton'
|
||||||
|
@containerRequired: false
|
||||||
|
|
||||||
|
@propTypes:
|
||||||
|
selection: React.PropTypes.object.isRequired
|
||||||
|
|
||||||
|
render: ->
|
||||||
|
<button style={order:-100}
|
||||||
|
className="btn btn-toolbar"
|
||||||
|
data-tooltip="Delete"
|
||||||
|
onClick={@_destroyDraft}>
|
||||||
|
<RetinaImg name="icon-composer-trash.png" mode={RetinaImg.Mode.ContentIsMask} />
|
||||||
|
</button>
|
||||||
|
|
||||||
|
_destroyDraft: =>
|
||||||
|
Actions.deleteSelection()
|
||||||
|
|
||||||
|
module.exports = {DraftDeleteButton}
|
|
@ -1,13 +1,17 @@
|
||||||
Reflux = require 'reflux'
|
Reflux = require 'reflux'
|
||||||
_ = require 'underscore'
|
_ = require 'underscore'
|
||||||
{Message,
|
{Message,
|
||||||
|
Actions,
|
||||||
DatabaseStore,
|
DatabaseStore,
|
||||||
|
FocusedContentStore,
|
||||||
|
DestroyDraftTask,
|
||||||
DatabaseView} = require 'nylas-exports'
|
DatabaseView} = require 'nylas-exports'
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
DraftListStore = Reflux.createStore
|
DraftListStore = Reflux.createStore
|
||||||
init: ->
|
init: ->
|
||||||
@listenTo DatabaseStore, @_onDataChanged
|
@listenTo DatabaseStore, @_onDataChanged
|
||||||
|
@listenTo Actions.deleteSelection, @_onDeleteSelection
|
||||||
|
|
||||||
@_view = new DatabaseView Message,
|
@_view = new DatabaseView Message,
|
||||||
matchers: [Message.attributes.draft.equal(true)],
|
matchers: [Message.attributes.draft.equal(true)],
|
||||||
|
@ -24,3 +28,16 @@ DraftListStore = Reflux.createStore
|
||||||
containsDraft = _.some(change.objects, (msg) -> msg.draft)
|
containsDraft = _.some(change.objects, (msg) -> msg.draft)
|
||||||
return unless containsDraft
|
return unless containsDraft
|
||||||
@_view.invalidate()
|
@_view.invalidate()
|
||||||
|
|
||||||
|
_onDeleteSelection: ->
|
||||||
|
selected = @_view.selection.items()
|
||||||
|
|
||||||
|
for item in selected
|
||||||
|
DatabaseStore.localIdForModel(item).then (localId) =>
|
||||||
|
Actions.queueTask(new DestroyDraftTask(localId))
|
||||||
|
# if thread.id is focusedId
|
||||||
|
# Actions.setFocus(collection: 'thread', item: null)
|
||||||
|
# if thread.id is keyboardId
|
||||||
|
# Actions.setCursorPosition(collection: 'thread', item: null)
|
||||||
|
|
||||||
|
@_view.selection.clear()
|
||||||
|
|
|
@ -11,5 +11,4 @@ class DraftSelectionBar extends React.Component
|
||||||
className="draft-list"
|
className="draft-list"
|
||||||
collection="draft" />
|
collection="draft" />
|
||||||
|
|
||||||
|
|
||||||
module.exports = DraftSelectionBar
|
module.exports = DraftSelectionBar
|
||||||
|
|
|
@ -3,6 +3,7 @@ React = require "react"
|
||||||
{ComponentRegistry, WorkspaceStore} = require "nylas-exports"
|
{ComponentRegistry, WorkspaceStore} = require "nylas-exports"
|
||||||
|
|
||||||
{DownButton, UpButton, ThreadBulkArchiveButton, ThreadBulkStarButton} = require "./thread-buttons"
|
{DownButton, UpButton, ThreadBulkArchiveButton, ThreadBulkStarButton} = require "./thread-buttons"
|
||||||
|
{DraftDeleteButton} = require "./draft-buttons"
|
||||||
ThreadSelectionBar = require './thread-selection-bar'
|
ThreadSelectionBar = require './thread-selection-bar'
|
||||||
ThreadList = require './thread-list'
|
ThreadList = require './thread-list'
|
||||||
|
|
||||||
|
@ -41,6 +42,9 @@ module.exports =
|
||||||
ComponentRegistry.register ThreadBulkStarButton,
|
ComponentRegistry.register ThreadBulkStarButton,
|
||||||
role: 'thread:BulkAction'
|
role: 'thread:BulkAction'
|
||||||
|
|
||||||
|
ComponentRegistry.register DraftDeleteButton,
|
||||||
|
role: 'draft:BulkAction'
|
||||||
|
|
||||||
deactivate: ->
|
deactivate: ->
|
||||||
ComponentRegistry.unregister DraftList
|
ComponentRegistry.unregister DraftList
|
||||||
ComponentRegistry.unregister DraftSelectionBar
|
ComponentRegistry.unregister DraftSelectionBar
|
||||||
|
@ -49,3 +53,4 @@ module.exports =
|
||||||
ComponentRegistry.unregister ThreadBulkArchiveButton
|
ComponentRegistry.unregister ThreadBulkArchiveButton
|
||||||
ComponentRegistry.unregister DownButton
|
ComponentRegistry.unregister DownButton
|
||||||
ComponentRegistry.unregister UpButton
|
ComponentRegistry.unregister UpButton
|
||||||
|
ComponentRegistry.unregister DraftDeleteButton
|
||||||
|
|
|
@ -320,6 +320,7 @@ class Actions
|
||||||
@archiveAndPrevious: ActionScopeWindow
|
@archiveAndPrevious: ActionScopeWindow
|
||||||
@toggleStarSelection: ActionScopeWindow
|
@toggleStarSelection: ActionScopeWindow
|
||||||
@toggleStarFocused: ActionScopeWindow
|
@toggleStarFocused: ActionScopeWindow
|
||||||
|
@deleteSelection: ActionScopeWindow
|
||||||
|
|
||||||
###
|
###
|
||||||
Public: Updates the search query in the app's main search bar with the provided query text.
|
Public: Updates the search query in the app's main search bar with the provided query text.
|
||||||
|
|
Loading…
Add table
Reference in a new issue