{ComponentRegistry, WorkspaceStore, Actions} = require "inbox-exports" {RetinaImg} = require 'ui-components' React = require "react" _ = require "underscore-plus" module.exports = ModeToggle = React.createClass displayName: 'ModeToggle' getInitialState: -> @_getStateFromStores() componentDidMount: -> @unsubscribe = WorkspaceStore.listen(@_onStateChanged, @) componentWillUnmount: -> @unsubscribe?() render: -> return
unless @state.visible
_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')