mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 04:25:31 +08:00
5acbdb0955
Summary: - New control will likely be shortlived - SDW mocking up replacement for when settings UI lands - New action for toggling location hidden - New rule for mail labels: can't remove "Sent" Test Plan: Run tests - none new atm Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D1782
49 lines
1.2 KiB
CoffeeScript
49 lines
1.2 KiB
CoffeeScript
{ComponentRegistry,
|
|
WorkspaceStore,
|
|
Actions} = require "nylas-exports"
|
|
{RetinaImg} = require 'nylas-component-kit'
|
|
React = require "react"
|
|
_ = require "underscore"
|
|
|
|
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="btn btn-toolbar mode-toggle mode-#{@state.mode}"
|
|
style={order:500}
|
|
onClick={@_onToggleMode}>
|
|
<RetinaImg
|
|
name="toolbar-icon-toggle-pane.png"
|
|
mode={RetinaImg.Mode.ContentIsMask}
|
|
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
|