Quick actions fix

Summary: Fixes T2345.

Test Plan: Tested manually

Reviewers: bengotow

Reviewed By: bengotow

Maniphest Tasks: T2345

Differential Revision: https://phab.nylas.com/D1886
This commit is contained in:
EthanBlackburn 2015-08-13 14:56:22 -07:00
parent e8b1e98e60
commit 685fd2fc69
4 changed files with 37 additions and 4 deletions

View file

@ -4,19 +4,25 @@ React = require 'react'
Utils,
Thread,
ArchiveThreadHelper,
CategoryStore,
ChangeFolderTask,
ChangeLabelsTask,
NamespaceStore} = require 'nylas-exports'
class ThreadListQuickActions extends React.Component
@displayName: 'ThreadListQuickActions'
@propTypes:
thread: React.PropTypes.object
categoryId: React.PropTypes.integer
render: =>
actions = []
actions.push <div key="reply" className="action action-reply" onClick={@_onReply}></div>
actions.push <div key="fwd" className="action action-forward" onClick={@_onForward}></div>
if not @props.thread.hasCategoryName('archive')
if @_shouldDisplayArchiveButton()
actions.push <div key="archive" className="action action-archive" onClick={@_onArchive}></div>
else if NamespaceStore.current().usesLabels() and @props.categoryId == CategoryStore.getStandardCategory('all').id
actions.push <div key="trash" className="action action-trash" onClick={@_onTrash}></div>
<div className="inner">
{actions}
@ -25,6 +31,29 @@ class ThreadListQuickActions extends React.Component
shouldComponentUpdate: (newProps, newState) ->
newProps.thread.id isnt @props?.thread.id
_shouldDisplayArchiveButton: =>
if @props.categoryId != CategoryStore.getStandardCategory('archive')?.id and @props.categoryId != CategoryStore.getStandardCategory('trash')?.id
if NamespaceStore.current().usesLabels()
if @props.thread.labels.length == 1 and (@props.thread.labels[0].name == "archive" or @props.thread.labels[0].name == "all")
return false
return true
else if @props.thread.folders.length == 1 and @props.thread.folders[0].name == "archive"
return false
return true
return false
_onTrash: (event) =>
params = {
thread: @props.thread,
labelsToRemove: [CategoryStore.byId(@props.categoryId)],
labelsToAdd: [CategoryStore.getStandardCategory("trash")]
}
Actions.queueTask(new ChangeLabelsTask(params))
# Don't trigger the thread row click
event.stopPropagation()
_onForward: (event) =>
Actions.composeForward({thread: @props.thread, popout: true})
# Don't trigger the thread row click
@ -36,8 +65,8 @@ class ThreadListQuickActions extends React.Component
event.stopPropagation()
_onArchive: (event) =>
task = ArchiveThreadHelper.getArchiveTask([@props.thread])
Actions.queueTask(task)
archiveTask = ArchiveThreadHelper.getArchiveTask([@props.thread])
Actions.queueTask(archiveTask)
# Don't trigger the thread row click
event.stopPropagation()

View file

@ -116,7 +116,8 @@ class ThreadList extends React.Component
c5 = new ListTabular.Column
name: "HoverActions"
resolver: (thread) =>
<ThreadListQuickActions thread={thread}/>
currentCategoryId = FocusedCategoryStore.categoryId()
<ThreadListQuickActions thread={thread} categoryId={currentCategoryId}/>
@wideColumns = [c1, c2, c3, c4, c5]

View file

@ -224,6 +224,9 @@
.action.action-archive {
background: url(../static/images/thread-list-quick-actions/ic-quick-button-archive@2x.png) top left no-repeat;
}
.action.action-trash {
background: url(../static/images/thread-list-quick-actions/ic-quick-button-trash@2x.png) top left no-repeat;
}
}
.thread-list .list-item:hover .list-column-HoverActions {
width: 0;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB