2015-10-22 02:03:27 +08:00
|
|
|
_ = require 'underscore'
|
2016-03-29 16:41:24 +08:00
|
|
|
React = require "react"
|
2015-04-25 02:33:10 +08:00
|
|
|
classNames = require 'classnames'
|
2015-04-09 10:25:00 +08:00
|
|
|
ThreadListStore = require './thread-list-store'
|
2015-05-15 08:08:30 +08:00
|
|
|
{RetinaImg} = require 'nylas-component-kit'
|
2015-10-01 10:51:48 +08:00
|
|
|
{Actions,
|
2015-10-22 01:38:00 +08:00
|
|
|
TaskFactory,
|
2016-03-08 10:13:53 +08:00
|
|
|
AccountStore,
|
2015-10-22 01:38:00 +08:00
|
|
|
CategoryStore,
|
2015-10-01 10:51:48 +08:00
|
|
|
FocusedContentStore,
|
2016-01-09 06:58:31 +08:00
|
|
|
FocusedPerspectiveStore} = require "nylas-exports"
|
refactor(*): Thread list fixes, flexible workspace store, multiple root sheets
Summary:
Remember to remove all the event listeners added to email frame
New files tab, queryable filename, not attribute
Rename ThreadSelectionBar to RootSelectionBar to go with RootCenterComponent, make it appear for draft selection and file selection as well
Initial file list and file list store, File Location
Remove unnecessary shouldComponentUpdate
Always track whether new requests have happened since ours to prevent out of order triggers
Always scroll to the current [focused/keyboard-cursor] in lists
So goodbye to the trash tag
Only scroll to current item if focus or keyboard has moved
Show message snippet in notification if no subject line
Make the RootSelectionBar pull items from Component Registry
New Archive button (prettier than the other one)
Refactor event additions to iframe so iframe can be used for file display also
Thread List is no longer the uber root package - drafts and files moved to separate packages
WorkspaceStore now allows packages to register sheets, "view" concept replaced with "root sheet" concept, "mode" may not be observed by all sheets, and is now called "preferred mode"
Don't animate transitions between two root sheets
Mode switch is only visible on root sheets that support multiple modes
Account sidebar now shows "Views" that have registered themselves: drafts and files for now
Model Selection Bar is now a component, just like ModelList. Meant to be in the toolbar above a Model List
Misc supporting changes
New files package which registers it's views and components
Rename files package to `file-list`
Move checkmark column down into model list
Don't throw exception if shift-down arrow and nothing selected
Takes a long time on login to fetch first page of threads, make pages smaller
Displaynames, spec fixes
Test Plan: Run tests
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1412
2015-04-11 05:33:05 +08:00
|
|
|
|
2016-03-18 00:50:30 +08:00
|
|
|
class ArchiveButton extends React.Component
|
|
|
|
@displayName: 'ArchiveButton'
|
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-05-01 07:10:15 +08:00
|
|
|
@containerRequired: false
|
refactor(*): Thread list fixes, flexible workspace store, multiple root sheets
Summary:
Remember to remove all the event listeners added to email frame
New files tab, queryable filename, not attribute
Rename ThreadSelectionBar to RootSelectionBar to go with RootCenterComponent, make it appear for draft selection and file selection as well
Initial file list and file list store, File Location
Remove unnecessary shouldComponentUpdate
Always track whether new requests have happened since ours to prevent out of order triggers
Always scroll to the current [focused/keyboard-cursor] in lists
So goodbye to the trash tag
Only scroll to current item if focus or keyboard has moved
Show message snippet in notification if no subject line
Make the RootSelectionBar pull items from Component Registry
New Archive button (prettier than the other one)
Refactor event additions to iframe so iframe can be used for file display also
Thread List is no longer the uber root package - drafts and files moved to separate packages
WorkspaceStore now allows packages to register sheets, "view" concept replaced with "root sheet" concept, "mode" may not be observed by all sheets, and is now called "preferred mode"
Don't animate transitions between two root sheets
Mode switch is only visible on root sheets that support multiple modes
Account sidebar now shows "Views" that have registered themselves: drafts and files for now
Model Selection Bar is now a component, just like ModelList. Meant to be in the toolbar above a Model List
Misc supporting changes
New files package which registers it's views and components
Rename files package to `file-list`
Move checkmark column down into model list
Don't throw exception if shift-down arrow and nothing selected
Takes a long time on login to fetch first page of threads, make pages smaller
Displaynames, spec fixes
Test Plan: Run tests
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1412
2015-04-11 05:33:05 +08:00
|
|
|
|
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-05-01 07:10:15 +08:00
|
|
|
@propTypes:
|
2016-03-18 00:50:30 +08:00
|
|
|
items: React.PropTypes.array.isRequired
|
refactor(*): Thread list fixes, flexible workspace store, multiple root sheets
Summary:
Remember to remove all the event listeners added to email frame
New files tab, queryable filename, not attribute
Rename ThreadSelectionBar to RootSelectionBar to go with RootCenterComponent, make it appear for draft selection and file selection as well
Initial file list and file list store, File Location
Remove unnecessary shouldComponentUpdate
Always track whether new requests have happened since ours to prevent out of order triggers
Always scroll to the current [focused/keyboard-cursor] in lists
So goodbye to the trash tag
Only scroll to current item if focus or keyboard has moved
Show message snippet in notification if no subject line
Make the RootSelectionBar pull items from Component Registry
New Archive button (prettier than the other one)
Refactor event additions to iframe so iframe can be used for file display also
Thread List is no longer the uber root package - drafts and files moved to separate packages
WorkspaceStore now allows packages to register sheets, "view" concept replaced with "root sheet" concept, "mode" may not be observed by all sheets, and is now called "preferred mode"
Don't animate transitions between two root sheets
Mode switch is only visible on root sheets that support multiple modes
Account sidebar now shows "Views" that have registered themselves: drafts and files for now
Model Selection Bar is now a component, just like ModelList. Meant to be in the toolbar above a Model List
Misc supporting changes
New files package which registers it's views and components
Rename files package to `file-list`
Move checkmark column down into model list
Don't throw exception if shift-down arrow and nothing selected
Takes a long time on login to fetch first page of threads, make pages smaller
Displaynames, spec fixes
Test Plan: Run tests
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1412
2015-04-11 05:33:05 +08:00
|
|
|
|
|
|
|
render: ->
|
2016-03-18 00:50:30 +08:00
|
|
|
canArchiveThreads = FocusedPerspectiveStore.current().canArchiveThreads(@props.items)
|
2016-03-08 10:13:53 +08:00
|
|
|
return <span /> unless canArchiveThreads
|
2015-10-01 10:51:48 +08:00
|
|
|
|
fix(focus): Remove focusedField in favor of imperative focus, break apart ComposerView
Summary:
- Removes controlled focus in the composer!
- No React components ever perfom focus in lifecycle methods. Never again.
- A new `Utils.schedule({action, after, timeout})` helper makes it easy to say "setState or load draft, etc. and then focus"
- The DraftStore issues a focusDraft action after creating a draft, which causes the MessageList to focus and scroll to the desired composer, which itself decides which field to focus.
- The MessageList never focuses anything automatically.
- Refactors ComposerView apart — ComposerHeader handles all top fields, DraftSessionContainer handles draft session initialization and exposes props to ComposerView
- ComposerHeader now uses a KeyCommandRegion (with focusIn and focusOut) to do the expanding and collapsing of the participants fields. May rename that container very soon.
- Removes all CommandRegistry handling of tab and shift-tab. Unless you preventDefault, the browser does it's thing.
- Removes all tabIndexes greater than 1. This is an anti-pattern—assigning everything a tabIndex of 0 tells the browser to move between them based on their order in the DOM, and is almost always what you want.
- Adds "TabGroupRegion" which allows you to create a tab/shift-tabbing group, (so tabbing does not leave the active composer). Can't believe this isn't a browser feature.
Todos:
- Occasionally, clicking out of the composer contenteditable requires two clicks. This is because atomicEdit is restoring selection within the contenteditable and breaking blur.
- Because the ComposerView does not render until it has a draft, we're back to it being white in popout composers for a brief moment. We will fix this another way - all the "return unless draft" statements were untenable.
- Clicking a row in the thread list no longer shifts focus to the message list and focuses the last draft. This will be restored soon.
Test Plan: Broken
Reviewers: juan, evan
Reviewed By: juan, evan
Differential Revision: https://phab.nylas.com/D2814
2016-04-05 06:22:01 +08:00
|
|
|
<button
|
|
|
|
tabIndex={-1}
|
|
|
|
style={order:-107}
|
|
|
|
className="btn btn-toolbar"
|
|
|
|
title="Archive"
|
|
|
|
onClick={@_onArchive}>
|
2015-10-22 01:38:00 +08:00
|
|
|
<RetinaImg name="toolbar-archive.png" mode={RetinaImg.Mode.ContentIsMask} />
|
|
|
|
</button>
|
|
|
|
|
2016-03-18 00:50:30 +08:00
|
|
|
_onArchive: (event) =>
|
2016-01-22 05:46:04 +08:00
|
|
|
tasks = TaskFactory.tasksForArchiving
|
2016-03-18 00:50:30 +08:00
|
|
|
threads: @props.items
|
2016-01-22 05:46:04 +08:00
|
|
|
Actions.queueTasks(tasks)
|
2016-03-18 00:50:30 +08:00
|
|
|
Actions.popSheet()
|
|
|
|
event.stopPropagation()
|
2016-01-26 09:08:38 +08:00
|
|
|
return
|
2015-10-22 01:38:00 +08:00
|
|
|
|
2016-03-18 00:50:30 +08:00
|
|
|
class TrashButton extends React.Component
|
|
|
|
@displayName: 'TrashButton'
|
2015-10-22 01:38:00 +08:00
|
|
|
@containerRequired: false
|
|
|
|
|
|
|
|
@propTypes:
|
2016-03-18 00:50:30 +08:00
|
|
|
items: React.PropTypes.array.isRequired
|
2015-10-22 01:38:00 +08:00
|
|
|
|
|
|
|
render: ->
|
2016-03-18 00:50:30 +08:00
|
|
|
canTrashThreads = FocusedPerspectiveStore.current().canTrashThreads(@props.items)
|
2016-03-08 10:13:53 +08:00
|
|
|
return <span /> unless canTrashThreads
|
2015-10-01 10:51:48 +08:00
|
|
|
|
fix(focus): Remove focusedField in favor of imperative focus, break apart ComposerView
Summary:
- Removes controlled focus in the composer!
- No React components ever perfom focus in lifecycle methods. Never again.
- A new `Utils.schedule({action, after, timeout})` helper makes it easy to say "setState or load draft, etc. and then focus"
- The DraftStore issues a focusDraft action after creating a draft, which causes the MessageList to focus and scroll to the desired composer, which itself decides which field to focus.
- The MessageList never focuses anything automatically.
- Refactors ComposerView apart — ComposerHeader handles all top fields, DraftSessionContainer handles draft session initialization and exposes props to ComposerView
- ComposerHeader now uses a KeyCommandRegion (with focusIn and focusOut) to do the expanding and collapsing of the participants fields. May rename that container very soon.
- Removes all CommandRegistry handling of tab and shift-tab. Unless you preventDefault, the browser does it's thing.
- Removes all tabIndexes greater than 1. This is an anti-pattern—assigning everything a tabIndex of 0 tells the browser to move between them based on their order in the DOM, and is almost always what you want.
- Adds "TabGroupRegion" which allows you to create a tab/shift-tabbing group, (so tabbing does not leave the active composer). Can't believe this isn't a browser feature.
Todos:
- Occasionally, clicking out of the composer contenteditable requires two clicks. This is because atomicEdit is restoring selection within the contenteditable and breaking blur.
- Because the ComposerView does not render until it has a draft, we're back to it being white in popout composers for a brief moment. We will fix this another way - all the "return unless draft" statements were untenable.
- Clicking a row in the thread list no longer shifts focus to the message list and focuses the last draft. This will be restored soon.
Test Plan: Broken
Reviewers: juan, evan
Reviewed By: juan, evan
Differential Revision: https://phab.nylas.com/D2814
2016-04-05 06:22:01 +08:00
|
|
|
<button tabIndex={-1}
|
|
|
|
style={order:-106}
|
refactor(*): Thread list fixes, flexible workspace store, multiple root sheets
Summary:
Remember to remove all the event listeners added to email frame
New files tab, queryable filename, not attribute
Rename ThreadSelectionBar to RootSelectionBar to go with RootCenterComponent, make it appear for draft selection and file selection as well
Initial file list and file list store, File Location
Remove unnecessary shouldComponentUpdate
Always track whether new requests have happened since ours to prevent out of order triggers
Always scroll to the current [focused/keyboard-cursor] in lists
So goodbye to the trash tag
Only scroll to current item if focus or keyboard has moved
Show message snippet in notification if no subject line
Make the RootSelectionBar pull items from Component Registry
New Archive button (prettier than the other one)
Refactor event additions to iframe so iframe can be used for file display also
Thread List is no longer the uber root package - drafts and files moved to separate packages
WorkspaceStore now allows packages to register sheets, "view" concept replaced with "root sheet" concept, "mode" may not be observed by all sheets, and is now called "preferred mode"
Don't animate transitions between two root sheets
Mode switch is only visible on root sheets that support multiple modes
Account sidebar now shows "Views" that have registered themselves: drafts and files for now
Model Selection Bar is now a component, just like ModelList. Meant to be in the toolbar above a Model List
Misc supporting changes
New files package which registers it's views and components
Rename files package to `file-list`
Move checkmark column down into model list
Don't throw exception if shift-down arrow and nothing selected
Takes a long time on login to fetch first page of threads, make pages smaller
Displaynames, spec fixes
Test Plan: Run tests
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1412
2015-04-11 05:33:05 +08:00
|
|
|
className="btn btn-toolbar"
|
2015-10-22 02:03:27 +08:00
|
|
|
title="Move to Trash"
|
2015-10-01 10:51:48 +08:00
|
|
|
onClick={@_onRemove}>
|
2015-10-22 01:38:00 +08:00
|
|
|
<RetinaImg name="toolbar-trash.png" mode={RetinaImg.Mode.ContentIsMask} />
|
refactor(*): Thread list fixes, flexible workspace store, multiple root sheets
Summary:
Remember to remove all the event listeners added to email frame
New files tab, queryable filename, not attribute
Rename ThreadSelectionBar to RootSelectionBar to go with RootCenterComponent, make it appear for draft selection and file selection as well
Initial file list and file list store, File Location
Remove unnecessary shouldComponentUpdate
Always track whether new requests have happened since ours to prevent out of order triggers
Always scroll to the current [focused/keyboard-cursor] in lists
So goodbye to the trash tag
Only scroll to current item if focus or keyboard has moved
Show message snippet in notification if no subject line
Make the RootSelectionBar pull items from Component Registry
New Archive button (prettier than the other one)
Refactor event additions to iframe so iframe can be used for file display also
Thread List is no longer the uber root package - drafts and files moved to separate packages
WorkspaceStore now allows packages to register sheets, "view" concept replaced with "root sheet" concept, "mode" may not be observed by all sheets, and is now called "preferred mode"
Don't animate transitions between two root sheets
Mode switch is only visible on root sheets that support multiple modes
Account sidebar now shows "Views" that have registered themselves: drafts and files for now
Model Selection Bar is now a component, just like ModelList. Meant to be in the toolbar above a Model List
Misc supporting changes
New files package which registers it's views and components
Rename files package to `file-list`
Move checkmark column down into model list
Don't throw exception if shift-down arrow and nothing selected
Takes a long time on login to fetch first page of threads, make pages smaller
Displaynames, spec fixes
Test Plan: Run tests
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1412
2015-04-11 05:33:05 +08:00
|
|
|
</button>
|
|
|
|
|
2016-03-18 00:50:30 +08:00
|
|
|
_onRemove: (event) =>
|
2016-01-22 05:46:04 +08:00
|
|
|
tasks = TaskFactory.tasksForMovingToTrash
|
2016-03-18 00:50:30 +08:00
|
|
|
threads: @props.items
|
2016-01-22 05:46:04 +08:00
|
|
|
Actions.queueTasks(tasks)
|
2016-03-18 00:50:30 +08:00
|
|
|
Actions.popSheet()
|
|
|
|
event.stopPropagation()
|
2016-01-26 09:08:38 +08:00
|
|
|
return
|
refactor(*): Thread list fixes, flexible workspace store, multiple root sheets
Summary:
Remember to remove all the event listeners added to email frame
New files tab, queryable filename, not attribute
Rename ThreadSelectionBar to RootSelectionBar to go with RootCenterComponent, make it appear for draft selection and file selection as well
Initial file list and file list store, File Location
Remove unnecessary shouldComponentUpdate
Always track whether new requests have happened since ours to prevent out of order triggers
Always scroll to the current [focused/keyboard-cursor] in lists
So goodbye to the trash tag
Only scroll to current item if focus or keyboard has moved
Show message snippet in notification if no subject line
Make the RootSelectionBar pull items from Component Registry
New Archive button (prettier than the other one)
Refactor event additions to iframe so iframe can be used for file display also
Thread List is no longer the uber root package - drafts and files moved to separate packages
WorkspaceStore now allows packages to register sheets, "view" concept replaced with "root sheet" concept, "mode" may not be observed by all sheets, and is now called "preferred mode"
Don't animate transitions between two root sheets
Mode switch is only visible on root sheets that support multiple modes
Account sidebar now shows "Views" that have registered themselves: drafts and files for now
Model Selection Bar is now a component, just like ModelList. Meant to be in the toolbar above a Model List
Misc supporting changes
New files package which registers it's views and components
Rename files package to `file-list`
Move checkmark column down into model list
Don't throw exception if shift-down arrow and nothing selected
Takes a long time on login to fetch first page of threads, make pages smaller
Displaynames, spec fixes
Test Plan: Run tests
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1412
2015-04-11 05:33:05 +08:00
|
|
|
|
2015-03-24 22:41:00 +08:00
|
|
|
|
2016-03-18 00:50:30 +08:00
|
|
|
class ToggleStarredButton extends React.Component
|
|
|
|
@displayName: 'ToggleStarredButton'
|
2015-06-09 08:02:50 +08:00
|
|
|
@containerRequired: false
|
|
|
|
|
|
|
|
@propTypes:
|
2016-03-18 00:50:30 +08:00
|
|
|
items: React.PropTypes.array.isRequired
|
2015-06-09 08:02:50 +08:00
|
|
|
|
|
|
|
render: ->
|
2016-03-18 00:50:30 +08:00
|
|
|
postClickStarredState = _.every @props.items, (t) -> t.starred is false
|
2016-04-15 04:34:46 +08:00
|
|
|
title = "Unstar"
|
2016-02-25 11:51:17 +08:00
|
|
|
imageName = "toolbar-star-selected.png"
|
|
|
|
|
|
|
|
if postClickStarredState
|
2016-04-15 04:34:46 +08:00
|
|
|
title = "Star"
|
2016-02-25 11:51:17 +08:00
|
|
|
imageName = "toolbar-star.png"
|
2015-10-22 02:03:27 +08:00
|
|
|
|
fix(focus): Remove focusedField in favor of imperative focus, break apart ComposerView
Summary:
- Removes controlled focus in the composer!
- No React components ever perfom focus in lifecycle methods. Never again.
- A new `Utils.schedule({action, after, timeout})` helper makes it easy to say "setState or load draft, etc. and then focus"
- The DraftStore issues a focusDraft action after creating a draft, which causes the MessageList to focus and scroll to the desired composer, which itself decides which field to focus.
- The MessageList never focuses anything automatically.
- Refactors ComposerView apart — ComposerHeader handles all top fields, DraftSessionContainer handles draft session initialization and exposes props to ComposerView
- ComposerHeader now uses a KeyCommandRegion (with focusIn and focusOut) to do the expanding and collapsing of the participants fields. May rename that container very soon.
- Removes all CommandRegistry handling of tab and shift-tab. Unless you preventDefault, the browser does it's thing.
- Removes all tabIndexes greater than 1. This is an anti-pattern—assigning everything a tabIndex of 0 tells the browser to move between them based on their order in the DOM, and is almost always what you want.
- Adds "TabGroupRegion" which allows you to create a tab/shift-tabbing group, (so tabbing does not leave the active composer). Can't believe this isn't a browser feature.
Todos:
- Occasionally, clicking out of the composer contenteditable requires two clicks. This is because atomicEdit is restoring selection within the contenteditable and breaking blur.
- Because the ComposerView does not render until it has a draft, we're back to it being white in popout composers for a brief moment. We will fix this another way - all the "return unless draft" statements were untenable.
- Clicking a row in the thread list no longer shifts focus to the message list and focuses the last draft. This will be restored soon.
Test Plan: Broken
Reviewers: juan, evan
Reviewed By: juan, evan
Differential Revision: https://phab.nylas.com/D2814
2016-04-05 06:22:01 +08:00
|
|
|
<button tabIndex={-1}
|
|
|
|
style={order:-104}
|
2015-06-09 08:02:50 +08:00
|
|
|
className="btn btn-toolbar"
|
2015-10-22 02:03:27 +08:00
|
|
|
title={title}
|
2015-06-09 08:02:50 +08:00
|
|
|
onClick={@_onStar}>
|
2016-02-25 11:51:17 +08:00
|
|
|
<RetinaImg name={imageName} mode={RetinaImg.Mode.ContentIsMask} />
|
2015-06-09 08:02:50 +08:00
|
|
|
</button>
|
|
|
|
|
2016-03-18 00:50:30 +08:00
|
|
|
_onStar: (event) =>
|
|
|
|
task = TaskFactory.taskForInvertingStarred(threads: @props.items)
|
2015-10-22 01:38:00 +08:00
|
|
|
Actions.queueTask(task)
|
2016-03-18 00:50:30 +08:00
|
|
|
event.stopPropagation()
|
2016-01-26 09:08:38 +08:00
|
|
|
return
|
2015-06-09 08:02:50 +08:00
|
|
|
|
|
|
|
|
2016-03-18 00:50:30 +08:00
|
|
|
class ToggleUnreadButton extends React.Component
|
|
|
|
@displayName: 'ToggleUnreadButton'
|
2015-09-16 07:49:16 +08:00
|
|
|
@containerRequired: false
|
|
|
|
|
|
|
|
@propTypes:
|
2016-03-18 00:50:30 +08:00
|
|
|
items: React.PropTypes.array.isRequired
|
2015-09-16 07:49:16 +08:00
|
|
|
|
|
|
|
render: =>
|
2016-03-18 00:50:30 +08:00
|
|
|
postClickUnreadState = _.every @props.items, (t) -> _.isMatch(t, {unread: false})
|
2015-12-05 08:38:26 +08:00
|
|
|
fragment = if postClickUnreadState then "unread" else "read"
|
2015-09-16 07:49:16 +08:00
|
|
|
|
fix(focus): Remove focusedField in favor of imperative focus, break apart ComposerView
Summary:
- Removes controlled focus in the composer!
- No React components ever perfom focus in lifecycle methods. Never again.
- A new `Utils.schedule({action, after, timeout})` helper makes it easy to say "setState or load draft, etc. and then focus"
- The DraftStore issues a focusDraft action after creating a draft, which causes the MessageList to focus and scroll to the desired composer, which itself decides which field to focus.
- The MessageList never focuses anything automatically.
- Refactors ComposerView apart — ComposerHeader handles all top fields, DraftSessionContainer handles draft session initialization and exposes props to ComposerView
- ComposerHeader now uses a KeyCommandRegion (with focusIn and focusOut) to do the expanding and collapsing of the participants fields. May rename that container very soon.
- Removes all CommandRegistry handling of tab and shift-tab. Unless you preventDefault, the browser does it's thing.
- Removes all tabIndexes greater than 1. This is an anti-pattern—assigning everything a tabIndex of 0 tells the browser to move between them based on their order in the DOM, and is almost always what you want.
- Adds "TabGroupRegion" which allows you to create a tab/shift-tabbing group, (so tabbing does not leave the active composer). Can't believe this isn't a browser feature.
Todos:
- Occasionally, clicking out of the composer contenteditable requires two clicks. This is because atomicEdit is restoring selection within the contenteditable and breaking blur.
- Because the ComposerView does not render until it has a draft, we're back to it being white in popout composers for a brief moment. We will fix this another way - all the "return unless draft" statements were untenable.
- Clicking a row in the thread list no longer shifts focus to the message list and focuses the last draft. This will be restored soon.
Test Plan: Broken
Reviewers: juan, evan
Reviewed By: juan, evan
Differential Revision: https://phab.nylas.com/D2814
2016-04-05 06:22:01 +08:00
|
|
|
<button tabIndex={-1}
|
|
|
|
style={order:-105}
|
2015-09-16 07:49:16 +08:00
|
|
|
className="btn btn-toolbar"
|
2015-10-22 02:03:27 +08:00
|
|
|
title="Mark as #{fragment}"
|
2015-09-16 07:49:16 +08:00
|
|
|
onClick={@_onClick}>
|
2015-10-22 02:33:33 +08:00
|
|
|
<RetinaImg name="toolbar-markas#{fragment}.png"
|
2015-09-16 07:49:16 +08:00
|
|
|
mode={RetinaImg.Mode.ContentIsMask} />
|
|
|
|
</button>
|
|
|
|
|
2016-03-18 00:50:30 +08:00
|
|
|
_onClick: (event) =>
|
|
|
|
task = TaskFactory.taskForInvertingUnread(threads: @props.items)
|
2015-10-22 01:38:00 +08:00
|
|
|
Actions.queueTask(task)
|
2016-03-18 00:50:30 +08:00
|
|
|
Actions.popSheet()
|
|
|
|
event.stopPropagation()
|
2016-01-26 09:08:38 +08:00
|
|
|
return
|
2015-09-16 07:49:16 +08:00
|
|
|
|
2015-03-24 22:41:00 +08:00
|
|
|
ThreadNavButtonMixin =
|
|
|
|
getInitialState: ->
|
|
|
|
@_getStateFromStores()
|
|
|
|
|
|
|
|
componentDidMount: ->
|
2015-04-09 10:25:00 +08:00
|
|
|
@_unsubscribe = ThreadListStore.listen @_onStoreChange
|
|
|
|
@_unsubscribe_focus = FocusedContentStore.listen @_onStoreChange
|
2015-04-01 08:19:17 +08:00
|
|
|
|
|
|
|
isFirstThread: ->
|
2015-04-09 10:25:00 +08:00
|
|
|
selectedId = FocusedContentStore.focusedId('thread')
|
2016-01-15 07:04:17 +08:00
|
|
|
ThreadListStore.dataSource().get(0)?.id is selectedId
|
2015-04-01 08:19:17 +08:00
|
|
|
|
|
|
|
isLastThread: ->
|
2015-04-09 10:25:00 +08:00
|
|
|
selectedId = FocusedContentStore.focusedId('thread')
|
2015-04-07 02:46:20 +08:00
|
|
|
|
2016-01-15 07:04:17 +08:00
|
|
|
lastIndex = ThreadListStore.dataSource().count() - 1
|
|
|
|
ThreadListStore.dataSource().get(lastIndex)?.id is selectedId
|
2015-03-24 22:41:00 +08:00
|
|
|
|
|
|
|
componentWillUnmount: ->
|
|
|
|
@_unsubscribe()
|
2015-04-01 08:19:17 +08:00
|
|
|
@_unsubscribe_focus()
|
2015-03-24 22:41:00 +08:00
|
|
|
|
2015-04-01 08:19:17 +08:00
|
|
|
_onStoreChange: ->
|
2015-03-24 22:41:00 +08:00
|
|
|
@setState @_getStateFromStores()
|
|
|
|
|
|
|
|
|
|
|
|
DownButton = React.createClass
|
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-05-01 07:10:15 +08:00
|
|
|
displayName: 'DownButton'
|
2015-03-24 22:41:00 +08:00
|
|
|
mixins: [ThreadNavButtonMixin]
|
|
|
|
|
|
|
|
render: ->
|
2015-10-22 02:03:27 +08:00
|
|
|
<div className={@_classSet()} onClick={@_onClick} title="Next thread">
|
2015-06-06 02:40:44 +08:00
|
|
|
<RetinaImg name="toolbar-down-arrow.png" mode={RetinaImg.Mode.ContentIsMask} />
|
2015-03-24 22:41:00 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
_classSet: ->
|
2015-04-25 02:33:10 +08:00
|
|
|
classNames
|
2015-06-06 02:40:44 +08:00
|
|
|
"btn-icon": true
|
2015-03-24 22:41:00 +08:00
|
|
|
"message-toolbar-arrow": true
|
|
|
|
"down": true
|
|
|
|
"disabled": @state.disabled
|
|
|
|
|
|
|
|
_onClick: ->
|
|
|
|
return if @state.disabled
|
2015-11-12 02:25:11 +08:00
|
|
|
NylasEnv.commands.dispatch(document.body, 'core:next-item')
|
2015-12-05 10:26:26 +08:00
|
|
|
return
|
2015-03-24 22:41:00 +08:00
|
|
|
|
|
|
|
_getStateFromStores: ->
|
2015-04-01 08:19:17 +08:00
|
|
|
disabled: @isLastThread()
|
2015-03-24 22:41:00 +08:00
|
|
|
|
|
|
|
UpButton = React.createClass
|
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-05-01 07:10:15 +08:00
|
|
|
displayName: 'UpButton'
|
2015-03-24 22:41:00 +08:00
|
|
|
mixins: [ThreadNavButtonMixin]
|
|
|
|
|
|
|
|
render: ->
|
2015-10-22 02:03:27 +08:00
|
|
|
<div className={@_classSet()} onClick={@_onClick} title="Previous thread">
|
2015-06-06 02:40:44 +08:00
|
|
|
<RetinaImg name="toolbar-up-arrow.png" mode={RetinaImg.Mode.ContentIsMask} />
|
2015-03-24 22:41:00 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
_classSet: ->
|
2015-04-25 02:33:10 +08:00
|
|
|
classNames
|
2015-06-06 02:40:44 +08:00
|
|
|
"btn-icon": true
|
2015-03-24 22:41:00 +08:00
|
|
|
"message-toolbar-arrow": true
|
|
|
|
"up": true
|
|
|
|
"disabled": @state.disabled
|
|
|
|
|
|
|
|
_onClick: ->
|
|
|
|
return if @state.disabled
|
2015-11-12 02:25:11 +08:00
|
|
|
NylasEnv.commands.dispatch(document.body, 'core:previous-item')
|
2015-12-05 10:26:26 +08:00
|
|
|
return
|
2015-03-24 22:41:00 +08:00
|
|
|
|
|
|
|
_getStateFromStores: ->
|
2015-04-01 08:19:17 +08:00
|
|
|
disabled: @isFirstThread()
|
2015-03-24 22:41:00 +08:00
|
|
|
|
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-05-01 07:10:15 +08:00
|
|
|
UpButton.containerRequired = false
|
|
|
|
DownButton.containerRequired = false
|
|
|
|
|
2015-10-22 01:38:00 +08:00
|
|
|
module.exports = {
|
|
|
|
UpButton,
|
2016-03-18 00:50:30 +08:00
|
|
|
DownButton,
|
|
|
|
TrashButton,
|
|
|
|
ArchiveButton,
|
|
|
|
ToggleStarredButton,
|
|
|
|
ToggleUnreadButton
|
2015-10-22 01:38:00 +08:00
|
|
|
}
|