Mailspring/internal_packages/thread-list/lib/main.cjsx
Ben Gotow e09d3e3e75 feat(trash): Trash for Gmail, and architectural changes for common tasks
Summary:
This diff centralizes logic for creating common tasks for things like moving to trash, archive, etc. TaskFactory exposes a set of convenience methods and hides the whole "and also remove the current label" business from the user.

This diff also formally separates the concept of "moving to trash" and "archiving" so that "remove" isn't used in an unclear way.

I also refactored where selection is managed. Previously you'd fire some action like archiveSelection and it'd clear the selection, but if you selected some items and used another method to archive a few, they were still selected. The selection is now bound to the ModelView as intended, so if items are removed from the modelView, they are removed from it's attached selection. This means that it shouldn't /technically/ be possible to have selected items which are not in view.

I haven't refactored the tests yet. They are likely broken...

Fix next/prev logic

Test Plan: Run tests

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2157
2015-10-21 10:38:00 -07:00

74 lines
2.5 KiB
CoffeeScript

_ = require 'underscore'
React = require "react"
{ComponentRegistry, WorkspaceStore} = require "nylas-exports"
{DownButton, UpButton, ThreadBulkArchiveButton, ThreadBulkTrashButton,
ThreadBulkStarButton, ThreadBulkToggleUnreadButton} = require "./thread-buttons"
{DraftDeleteButton} = require "./draft-buttons"
ThreadSelectionBar = require './thread-selection-bar'
ThreadList = require './thread-list'
DraftListSidebarItem = require './draft-list-sidebar-item'
DraftSelectionBar = require './draft-selection-bar'
DraftList = require './draft-list'
module.exports =
activate: (@state={}) ->
WorkspaceStore.defineSheet 'Drafts', {root: true},
list: ['RootSidebar', 'DraftList']
@sidebarItem = new WorkspaceStore.SidebarItem
component: DraftListSidebarItem
sheet: WorkspaceStore.Sheet.Drafts
id: 'Drafts'
name: 'Drafts'
WorkspaceStore.addSidebarItem(@sidebarItem)
ComponentRegistry.register ThreadList,
location: WorkspaceStore.Location.ThreadList
ComponentRegistry.register ThreadSelectionBar,
location: WorkspaceStore.Location.ThreadList.Toolbar
ComponentRegistry.register DraftList,
location: WorkspaceStore.Location.DraftList
ComponentRegistry.register DraftSelectionBar,
location: WorkspaceStore.Location.DraftList.Toolbar
ComponentRegistry.register DownButton,
location: WorkspaceStore.Sheet.Thread.Toolbar.Right
modes: ['list']
ComponentRegistry.register UpButton,
location: WorkspaceStore.Sheet.Thread.Toolbar.Right
modes: ['list']
ComponentRegistry.register ThreadBulkArchiveButton,
role: 'thread:BulkAction'
ComponentRegistry.register ThreadBulkTrashButton,
role: 'thread:BulkAction'
ComponentRegistry.register ThreadBulkStarButton,
role: 'thread:BulkAction'
ComponentRegistry.register ThreadBulkToggleUnreadButton,
role: 'thread:BulkAction'
ComponentRegistry.register DraftDeleteButton,
role: 'draft:BulkAction'
deactivate: ->
ComponentRegistry.unregister DraftList
ComponentRegistry.unregister DraftSelectionBar
ComponentRegistry.unregister ThreadList
ComponentRegistry.unregister ThreadSelectionBar
ComponentRegistry.unregister ThreadBulkArchiveButton
ComponentRegistry.unregister ThreadBulkTrashButton
ComponentRegistry.unregister ThreadBulkToggleUnreadButton
ComponentRegistry.unregister DownButton
ComponentRegistry.unregister UpButton
ComponentRegistry.unregister DraftDeleteButton