Mailspring/internal_packages/thread-list/lib/main.cjsx
Ben Gotow 9ffe0d74dd feat(unsafe-components): Wrap injected components, catch exceptions, clean up ComponentRegistry
Summary:
This diff gives the ComponentRegistry a cleaner, smaller API. Instead of querying by name, location or role,
it's now just location and role, and you can register components for one or more location and one or more
roles without assigning the entries in the registry separate names.

When you register with the ComponentRegistry, the syntax is also cleaner and uses the component's displayName
instead of requiring you to provide a name. You also provide the actual component when unregistering, ensuring
that you can't unregister someone else's component.

InjectedComponent and InjectedComponentSet now wrap their children in UnsafeComponent, which prevents
render/component lifecycle problems from propogating.

Existing components have been updated:

1. maxWidth / minWidth are now containerStyles.maxWidth/minWidth
2. displayName is now required to use the CR.
3. containerRequired = false can be provided to exempt a component from being wrapped in an UnsafeComponent.
   This is useful because it's slightly faster and keeps DOM flat.

This diff also makes the "Show Component Regions" more awesome. It displays column regions, since they now
use the InjectedComponentSet, and also shows for InjectedComponent as well as InjectedComponentSet.

Change ComponentRegistry syntax, lots more work on safely wrapping items. See description.

Fix for inline flexbox scenarios (message actions)

Allow ~/.inbox/packages to be symlinked to a github repo

Test Plan: Run tests!

Reviewers: evan

Reviewed By: evan

Differential Revision: https://review.inboxapp.com/D1457
2015-04-30 16:10:15 -07:00

45 lines
1.5 KiB
CoffeeScript

_ = require 'underscore-plus'
React = require "react"
{ComponentRegistry, WorkspaceStore} = require "inbox-exports"
{DownButton, UpButton, ThreadBulkArchiveButton} = require "./thread-buttons"
ThreadSelectionBar = require './thread-selection-bar'
ThreadList = require './thread-list'
DraftSelectionBar = require './draft-selection-bar'
DraftList = require './draft-list'
module.exports =
activate: (@state={}) ->
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'
deactivate: ->
ComponentRegistry.unregister DraftList
ComponentRegistry.unregister DraftSelectionBar
ComponentRegistry.unregister ThreadList
ComponentRegistry.unregister ThreadSelectionBar
ComponentRegistry.unregister ThreadBulkArchiveButton
ComponentRegistry.unregister DownButton
ComponentRegistry.unregister UpButton