Mailspring/internal_packages/thread-list/lib/thread-list-quick-actions.cjsx
Evan Morikawa a20b979208 feat(analytics): add analytics for change mail tasks
Summary:
Adds the following new events:

- Threads Moved to Folder
  - isArchive
  - source
  - folderType
  - folderDisplayName
  - numThreads
  - numMessages
  - description
  - isUndo

- Threads Changed Labels
  - isArchive
  - source
  - labelTypesToAdd
  - labelTypesToRemove
  - labelDisplayNamesToAdd
  - labelDisplayNamesToRemove
  - numThreads
  - numMessages
  - description
  - isUndo

- Threads Starred
  - source
  - numThreads
  - description
  - isUndo

- Threads Unstarred
  - source
  - numThreads
  - description
  - isUndo

- Threads Marked as Read
  - source
  - numThreads
  - description
  - isUndo

- Threads Marked as Unread
  - source
  - numThreads
  - description
  - isUndo

Each new action has a "source" property that's one of the following:
- Category Picker: New Category
- Category Picker: Existing Category
- Toolbar Button: Message List
- Toolbar Button: Thread List
- Send and Archive
- Context Menu: Thread List
- Thread List Icon
- Quick Actions: Thread List
- Swipe
- Keyboard Shortcut
- Dragged Out of List
- Snooze Move
- Important Icon
- Label Remove Icon
- Thread Selected
- Mail Rules
- Dragged Into List

Test Plan: manual

Reviewers: juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3760
2017-01-24 12:22:33 -05:00

65 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: =>
allowed = FocusedPerspectiveStore.current().canArchiveThreads([@props.thread])
return <span /> unless allowed
<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
source: "Quick Actions: Thread List"
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: =>
allowed = FocusedPerspectiveStore.current().canMoveThreadsTo([@props.thread], 'trash')
return <span /> unless allowed
<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
source: "Quick Actions: Thread List"
threads: [@props.thread]
Actions.queueTasks(tasks)
# Don't trigger the thread row click
event.stopPropagation()
module.exports = { ThreadArchiveQuickAction, ThreadTrashQuickAction }