Merge pull request #892 from colinking/hoveractions_injectable

Move quick actions inside of flexbox with injectable component set
This commit is contained in:
Ben Gotow 2016-01-05 10:53:23 -08:00
commit 9f8791762d
3 changed files with 44 additions and 24 deletions

View file

@ -4,32 +4,22 @@ React = require 'react'
TaskFactory, TaskFactory,
FocusedMailViewStore} = require 'nylas-exports' FocusedMailViewStore} = require 'nylas-exports'
class ThreadListQuickActions extends React.Component class ThreadArchiveQuickAction extends React.Component
@displayName: 'ThreadListQuickActions' @displayName: 'ThreadArchiveQuickAction'
@propTypes: @propTypes:
thread: React.PropTypes.object thread: React.PropTypes.object
render: => render: =>
mailViewFilter = FocusedMailViewStore.mailView() mailViewFilter = FocusedMailViewStore.mailView()
archive = null archive = null
remove = null
if mailViewFilter?.canArchiveThreads() if mailViewFilter?.canArchiveThreads()
archive = <div key="archive" archive = <div key="archive"
title="Archive" title="Archive"
style={{ order: 110 }}
className="btn action action-archive" className="btn action action-archive"
onClick={@_onArchive}></div> onClick={@_onArchive}></div>
return archive
if mailViewFilter?.canTrashThreads()
trash = <div key="remove"
title="Trash"
className='btn action action-trash'
onClick={@_onRemove}></div>
<div className="inner">
{archive}
{trash}
</div>
shouldComponentUpdate: (newProps, newState) -> shouldComponentUpdate: (newProps, newState) ->
newProps.thread.id isnt @props?.thread.id newProps.thread.id isnt @props?.thread.id
@ -43,6 +33,26 @@ class ThreadListQuickActions extends React.Component
# Don't trigger the thread row click # Don't trigger the thread row click
event.stopPropagation() event.stopPropagation()
class ThreadTrashQuickAction extends React.Component
@displayName: 'ThreadTrashQuickAction'
@propTypes:
thread: React.PropTypes.object
render: =>
mailViewFilter = FocusedMailViewStore.mailView()
trash = null
if mailViewFilter?.canTrashThreads()
trash = <div key="remove"
title="Trash"
style={{ order: 100 }}
className='btn action action-trash'
onClick={@_onRemove}></div>
return trash
shouldComponentUpdate: (newProps, newState) ->
newProps.thread.id isnt @props?.thread.id
_onRemove: (event) => _onRemove: (event) =>
task = TaskFactory.taskForMovingToTrash task = TaskFactory.taskForMovingToTrash
threads: [@props.thread] threads: [@props.thread]
@ -52,4 +62,4 @@ class ThreadListQuickActions extends React.Component
# Don't trigger the thread row click # Don't trigger the thread row click
event.stopPropagation() event.stopPropagation()
module.exports = ThreadListQuickActions module.exports = { ThreadArchiveQuickAction, ThreadTrashQuickAction }

View file

@ -19,9 +19,9 @@ classNames = require 'classnames'
CategoryStore, CategoryStore,
FocusedContentStore, FocusedContentStore,
FocusedMailViewStore} = require 'nylas-exports' FocusedMailViewStore} = require 'nylas-exports'
ThreadListParticipants = require './thread-list-participants' ThreadListParticipants = require './thread-list-participants'
ThreadListQuickActions = require './thread-list-quick-actions' {ThreadArchiveQuickAction,
ThreadTrashQuickAction} = require './thread-list-quick-actions'
ThreadListStore = require './thread-list-store' ThreadListStore = require './thread-list-store'
ThreadListIcon = require './thread-list-icon' ThreadListIcon = require './thread-list-icon'
@ -137,7 +137,20 @@ class ThreadList extends React.Component
c5 = new ListTabular.Column c5 = new ListTabular.Column
name: "HoverActions" name: "HoverActions"
resolver: (thread) => resolver: (thread) =>
<ThreadListQuickActions thread={thread} /> <div className="inner">
<InjectedComponentSet
key="injected-component-set"
inline={true}
containersRequired={false}
children=
{[
<ThreadTrashQuickAction key="thread-trash-quick-action" thread={thread} />
<ThreadArchiveQuickAction key="thread-arhive-quick-action" thread={thread} />
]}
matching={role: "ThreadListQuickAction"}
className="thread-injected-quick-actions"
exposedProps={thread: thread}/>
</div>
@wideColumns = [c1, c2, c3, c4, c5] @wideColumns = [c1, c2, c3, c4, c5]

View file

@ -229,9 +229,6 @@
height: 57px; height: 57px;
margin: 9px 16px 0 16px; margin: 9px 16px 0 16px;
} }
.action:last-child {
margin-right:40px;
}
.action.action-archive { .action.action-archive {
background: url(@archive-img) center no-repeat, @background-gradient; background: url(@archive-img) center no-repeat, @background-gradient;
} }
@ -244,9 +241,6 @@ body.platform-win32 {
.action { .action {
border: 0; border: 0;
margin: 9px 0 0 0; margin: 9px 0 0 0;
&:last-child {
margin-right: 30px;
}
} }
.action.action-archive { .action.action-archive {
background: url(@archive-img) center no-repeat; background: url(@archive-img) center no-repeat;
@ -268,6 +262,9 @@ body.platform-win32 {
width:300px; width:300px;
height:100%; height:100%;
left: -300px; left: -300px;
.thread-injected-quick-actions {
margin-right: 10px;
}
} }
} }