mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-11 02:30:21 +08:00
d9ee12cf81
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
120 lines
4.2 KiB
CoffeeScript
120 lines
4.2 KiB
CoffeeScript
React = require 'react'
|
|
_ = require 'underscore-plus'
|
|
{Actions,ComponentRegistry, WorkspaceStore} = require "inbox-exports"
|
|
RetinaImg = require './components/retina-img'
|
|
Flexbox = require './components/flexbox'
|
|
ResizableRegion = require './components/resizable-region'
|
|
|
|
FLEX = 10000
|
|
|
|
module.exports =
|
|
Sheet = React.createClass
|
|
displayName: 'Sheet'
|
|
|
|
propTypes:
|
|
data: React.PropTypes.object.isRequired
|
|
depth: React.PropTypes.number.isRequired
|
|
onColumnSizeChanged: React.PropTypes.func
|
|
|
|
getInitialState: ->
|
|
@_getStateFromStores()
|
|
|
|
componentDidMount: ->
|
|
@unlisteners ?= []
|
|
@unlisteners.push ComponentRegistry.listen (event) =>
|
|
@setState(@_getStateFromStores())
|
|
@unlisteners.push WorkspaceStore.listen (event) =>
|
|
@setState(@_getStateFromStores())
|
|
|
|
componentDidUpdate: ->
|
|
@props.onColumnSizeChanged(@) if @props.onColumnSizeChanged
|
|
|
|
shouldComponentUpdate: (nextProps, nextState) ->
|
|
not _.isEqual(nextProps, @props) or not _.isEqual(nextState, @state)
|
|
|
|
componentWillUnmount: ->
|
|
unlisten() for unlisten in @unlisteners
|
|
|
|
render: ->
|
|
style =
|
|
position:'absolute'
|
|
width:'100%'
|
|
height:'100%'
|
|
zIndex: 1
|
|
|
|
# Note - setting the z-index of the sheet is important, even though it's
|
|
# always 1. Assigning a z-index creates a "stacking context" in the browser,
|
|
# so z-indexes inside the sheet are relative to each other, but something in
|
|
# one sheet cannot be on top of something in another sheet.
|
|
# http://philipwalton.com/articles/what-no-one-told-you-about-z-index/
|
|
|
|
<div name={"Sheet"}
|
|
style={style}
|
|
className={"sheet mode-#{@state.mode}"}
|
|
data-id={@props.data.id}>
|
|
<Flexbox direction="row">
|
|
{@_columnFlexboxElements()}
|
|
</Flexbox>
|
|
</div>
|
|
|
|
_columnFlexboxElements: ->
|
|
@state.columns.map ({entries, maxWidth, minWidth, handle, id}, idx) =>
|
|
elements = entries.map ({name, view}) -> <view key={name} />
|
|
if minWidth != maxWidth and maxWidth < FLEX
|
|
<ResizableRegion key={"#{@props.data.id}:#{idx}"}
|
|
name={"#{@props.data.id}:#{idx}"}
|
|
className={"column-#{id}"}
|
|
data-column={idx}
|
|
onResize={ => @props.onColumnSizeChanged(@) }
|
|
minWidth={minWidth}
|
|
maxWidth={maxWidth}
|
|
handle={handle}>
|
|
<Flexbox direction="column">
|
|
{elements}
|
|
</Flexbox>
|
|
</ResizableRegion>
|
|
else
|
|
<Flexbox direction="column"
|
|
key={"#{@props.data.id}:#{idx}"}
|
|
name={"#{@props.data.id}:#{idx}"}
|
|
className={"column-#{id}"}
|
|
data-column={idx}
|
|
style={flex: 1}>
|
|
{elements}
|
|
</Flexbox>
|
|
|
|
_getStateFromStores: ->
|
|
state =
|
|
mode: WorkspaceStore.layoutMode()
|
|
columns: []
|
|
|
|
widest = -1
|
|
widestWidth = -1
|
|
|
|
if @props.data?.columns[state.mode]?
|
|
for location, idx in @props.data.columns[state.mode]
|
|
entries = ComponentRegistry.findAllByLocationAndMode(location, state.mode)
|
|
maxWidth = _.reduce entries, ((m,{view}) -> Math.min(view.maxWidth ? 10000, m)), 10000
|
|
minWidth = _.reduce entries, ((m,{view}) -> Math.max(view.minWidth ? 0, m)), 0
|
|
col = {entries, maxWidth, minWidth, id: location.id}
|
|
state.columns.push(col)
|
|
|
|
if maxWidth > widestWidth
|
|
widestWidth = maxWidth
|
|
widest = idx
|
|
|
|
if state.columns.length > 0
|
|
# Once we've accumulated all the React components for the columns,
|
|
# ensure that at least one column has a huge max-width so that the columns
|
|
# expand to fill the window. This may make items in the column unhappy, but
|
|
# we pick the column with the highest max-width so the effect is minimal.
|
|
state.columns[widest].maxWidth = FLEX
|
|
|
|
# Assign flexible edges based on whether items are to the left or right
|
|
# of the flexible column (which has no edges)
|
|
state.columns[i].handle = ResizableRegion.Handle.Right for i in [0..widest-1] by 1
|
|
state.columns[i].handle = ResizableRegion.Handle.Left for i in [widest..state.columns.length-1] by 1
|
|
state
|
|
|
|
_pop: ->
|
|
Actions.popSheet()
|