mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-08 01:04:39 +08:00
e3dfbe59be
Summary: Fix react upgrade errors Test Plan: edgehill --test Reviewers: bengotow Reviewed By: bengotow Differential Revision: https://review.inboxapp.com/D1456
49 lines
1.2 KiB
CoffeeScript
49 lines
1.2 KiB
CoffeeScript
{ComponentRegistry,
|
|
WorkspaceStore,
|
|
Actions} = require "inbox-exports"
|
|
{RetinaImg} = require 'ui-components'
|
|
React = require "react"
|
|
_ = require "underscore-plus"
|
|
|
|
class ModeToggle extends React.Component
|
|
@displayName: 'ModeToggle'
|
|
|
|
constructor: (@props) ->
|
|
@state = @_getStateFromStores()
|
|
|
|
componentDidMount: =>
|
|
@unsubscribe = WorkspaceStore.listen(@_onStateChanged, @)
|
|
|
|
componentWillUnmount: =>
|
|
@unsubscribe?()
|
|
|
|
render: =>
|
|
return <div></div> unless @state.visible
|
|
|
|
<div className="mode-toggle"
|
|
style={order:51, marginTop:10, marginRight:14}
|
|
onClick={@_onToggleMode}>
|
|
<RetinaImg
|
|
name="toolbar-icon-toggle-pane.png"
|
|
colorfill={@state.mode is 'split'}
|
|
onClick={@_onToggleMode} />
|
|
</div>
|
|
|
|
_onStateChanged: =>
|
|
@setState(@_getStateFromStores())
|
|
|
|
_getStateFromStores: =>
|
|
rootModes = WorkspaceStore.rootSheet().supportedModes
|
|
rootVisible = WorkspaceStore.rootSheet() is WorkspaceStore.topSheet()
|
|
|
|
mode: WorkspaceStore.layoutMode()
|
|
visible: rootVisible and rootModes and rootModes.length > 1
|
|
|
|
_onToggleMode: =>
|
|
if @state.mode is 'list'
|
|
Actions.selectLayoutMode('split')
|
|
else
|
|
Actions.selectLayoutMode('list')
|
|
|
|
|
|
module.exports = ModeToggle
|