Mailspring/internal_packages/thread-list/lib/thread-list-icon.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

69 lines
1.9 KiB
CoffeeScript

_ = require 'underscore'
React = require 'react'
{DraftHelpers,
Actions,
Thread,
ChangeStarredTask,
ExtensionRegistry,
AccountStore} = require 'nylas-exports'
class ThreadListIcon extends React.Component
@displayName: 'ThreadListIcon'
@propTypes:
thread: React.PropTypes.object
_extensionsIconClassNames: =>
return ExtensionRegistry.ThreadList.extensions()
.filter((ext) => ext.cssClassNamesForThreadListIcon?)
.reduce(((prev, ext) => prev + ' ' + ext.cssClassNamesForThreadListIcon(@props.thread)), '')
.trim()
_iconClassNames: =>
if !@props.thread
return 'thread-icon-star-on-hover'
extensionIconClassNames = @_extensionsIconClassNames()
if extensionIconClassNames.length > 0
return extensionIconClassNames
if @props.thread.starred
return 'thread-icon-star'
if @props.thread.unread
return 'thread-icon-unread thread-icon-star-on-hover'
msgs = @_nonDraftMessages()
last = msgs[msgs.length - 1]
if msgs.length > 1 and last.from[0]?.isMe()
if DraftHelpers.isForwardedMessage(last)
return 'thread-icon-forwarded thread-icon-star-on-hover'
else
return 'thread-icon-replied thread-icon-star-on-hover'
return 'thread-icon-none thread-icon-star-on-hover'
_nonDraftMessages: =>
msgs = @props.thread.__messages
return [] unless msgs and msgs instanceof Array
msgs = _.filter msgs, (m) -> m.serverId and not m.draft
return msgs
shouldComponentUpdate: (nextProps) =>
return false if nextProps.thread is @props.thread
true
render: =>
<div className="thread-icon #{@_iconClassNames()}"
title="Star"
onClick={@_onToggleStar}></div>
_onToggleStar: (event) =>
task = new ChangeStarredTask(thread: @props.thread, starred: !@props.thread.starred, source: "Thread List Icon")
Actions.queueTask(task)
# Don't trigger the thread row click
event.stopPropagation()
module.exports = ThreadListIcon