Mailspring/internal_packages/draft-list/lib/draft-list.cjsx
Ben Gotow a48ddd51f8 refactor(menus): Major prune of keymaps/commands, real conditional menus
Summary:
Keymaps & menus CSON => JSON, remove AtomKeymaps, CommandRegistry use of CSS selectors, use Mousetrap instead

Important Notes:

- The `application:` prefix is reserved for commands which are handled in the application process. Don't use it for other things. You will not receive the events in the window.

- Maintaining dynamic menus seems to come with quite an overhead, because Electron updates the entire menu every time. In the future, we'll need https://github.com/electron/electron/issues/528 to really make things nice. I will be tracking this upstream.

- The format for keyboard shortcuts has changed. `cmd-X` is now `command+shift+x`

Test Plan: Run tests

Reviewers: juan, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2917
2016-04-24 12:16:25 -05:00

49 lines
1.4 KiB
CoffeeScript

_ = require 'underscore'
React = require 'react'
{Actions} = require 'nylas-exports'
{FluxContainer,
FocusContainer,
EmptyListState,
MultiselectList} = require 'nylas-component-kit'
DraftListStore = require './draft-list-store'
DraftListColumns = require './draft-list-columns'
class DraftList extends React.Component
@displayName: 'DraftList'
@containerRequired: false
render: =>
<FluxContainer
stores=[DraftListStore]
getStateFromStores={ -> dataSource: DraftListStore.dataSource() }>
<FocusContainer collection="draft">
<MultiselectList
columns={DraftListColumns.Wide}
onDoubleClick={@_onDoubleClick}
emptyComponent={EmptyListState}
keymapHandlers={@_keymapHandlers()}
itemPropsProvider={@_itemPropsProvider}
itemHeight={39}
className="draft-list" />
</FocusContainer>
</FluxContainer>
_itemPropsProvider: (draft) ->
props = {}
props.className = 'sending' if draft.uploadTaskId
props
_keymapHandlers: =>
'core:remove-from-view': @_onRemoveFromView
_onDoubleClick: (draft) =>
unless draft.uploadTaskId
Actions.composePopoutDraft(draft.clientId)
# Additional Commands
_onRemoveFromView: =>
drafts = DraftListStore.dataSource().selection.items()
Actions.destroyDraft(draft.clientId) for draft in drafts
module.exports = DraftList