Mailspring/internal_packages/file-list/lib/file-list.cjsx

52 lines
1.2 KiB
Plaintext
Raw Normal View History

_ = require 'underscore'
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
React = require 'react'
{ListTabular, MultiselectList} = require 'nylas-component-kit'
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
{Actions,
DatabaseStore,
ComponentRegistry} = 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
FileListStore = require './file-list-store'
class FileList extends React.Component
@displayName: 'FileList'
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
@containerRequired: false
componentWillMount: =>
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
prettySize = (size) ->
units = ['GB', 'MB', 'KB', 'bytes']
while size > 1024
size /= 1024
units.pop()
size = "#{(Math.ceil(size * 10) / 10)}"
pretty = units.pop()
"#{size} #{pretty}"
c1 = new ListTabular.Column
name: "Name"
flex: 1
resolver: (file) =>
feat(attachments): Tons of tiny fixes to attachments, drag-and-drop attachments to other apps Summary: consolidate all the "untitled" stuff into a convenience method on the File itself. Previously it'd show "Unnamed Attachment", download as "Untitled" and open as "<file.id>". Now it's consistent everywhere and chooses names based on the contenttype (Event.ics). Rewrite CSS rules for uploads and attachments to be simpler - remove container divs and classnames from things that have no CSS - switch to using Flexbox so it's not necesary to have so many containers - remove zIndex hacks, apply overflow rules to name div only, so long filenames don't make action button unclickable - consolidate CSS classnames for uploads/attachments - Other style fixes - cursor "default" instead of text insertion on image attachments - cursor "default" on action buttons - image uplaods / attachments with long filenames truncate with ellpsis - attachments are not indented by an extra 15px in message bodies Prevent progress bar overflow (was ending above 100%, 100.12315%...) Update FileDownloadStore so it never creates Download objects when file is downloaded already - Previously, the download itself decided if it would be a no-op, but this meant the download was around for a split second and you'd see progress indicators flash for a moment when opening/saving an attachment. Upgrade FileDownloadStore use of promises Restore Image attachment drag and drop - was broken because the name gradient thing was covering the entire drag region. Allow file attachments to be drag and dropped to the finder and other applications 😍😍😍 Test Plan: Tests still pass Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D1745
2015-07-16 04:15:05 +08:00
<div>{file.displayName()}</div>
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
c2 = new ListTabular.Column
name: "Size"
width: '100px'
resolver: (file) =>
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
<div>{prettySize(file.size)}</div>
@columns = [c1, c2]
render: =>
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
<MultiselectList
dataStore={FileListStore}
columns={@columns}
commands={{}}
onDoubleClick={@_onDoubleClick}
itemPropsProvider={ -> {} }
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="file-list"
collection="file" />
_onDoubleClick: (item) =>
module.exports = FileList