mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 04:25:31 +08:00
599d8f834f
Summary: This diff moves the preferences interface to a sheet in the main window, with the following benefits: - We can put any sort of React control in it (no ReactRemote) - It's not strange for the interface to scroll - Since it can scroll, it's safe to auto-generate preferences for plugins based on their package config schema. The general tab is now mostly based on the config schema, with the exception of the "Workspace" and "Layout" bits. The other tabs are still manual, and should be polished more. Test Plan: No new tests Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D2278
43 lines
1.3 KiB
CoffeeScript
43 lines
1.3 KiB
CoffeeScript
React = require 'react'
|
|
_ = require 'underscore'
|
|
{RetinaImg, Flexbox, ConfigPropContainer, ScrollRegion} = require 'nylas-component-kit'
|
|
{PreferencesSectionStore} = require 'nylas-exports'
|
|
|
|
PreferencesSidebar = require './preferences-sidebar'
|
|
|
|
class PreferencesRoot extends React.Component
|
|
@displayName: 'PreferencesRoot'
|
|
@containerRequired: false
|
|
|
|
constructor: (@props) ->
|
|
@state = @getStateFromStores()
|
|
|
|
componentDidMount: =>
|
|
@unlisteners = []
|
|
@unlisteners.push PreferencesSectionStore.listen =>
|
|
@setState(@getStateFromStores())
|
|
|
|
componentWillUnmount: =>
|
|
unlisten() for unlisten in @unlisteners
|
|
|
|
getStateFromStores: =>
|
|
sections: PreferencesSectionStore.sections()
|
|
activeSectionId: PreferencesSectionStore.activeSectionId()
|
|
|
|
render: =>
|
|
section = _.find @state.sections, ({sectionId}) => sectionId is @state.activeSectionId
|
|
|
|
if section
|
|
bodyElement = <section.component />
|
|
else
|
|
bodyElement = <div>No Section Active</div>
|
|
|
|
<Flexbox direction="row" className="preferences-wrap">
|
|
<PreferencesSidebar sections={@state.sections}
|
|
activeSectionId={@state.activeSectionId} />
|
|
<ScrollRegion className="preferences-content">
|
|
<ConfigPropContainer>{bodyElement}</ConfigPropContainer>
|
|
</ScrollRegion>
|
|
</Flexbox>
|
|
|
|
module.exports = PreferencesRoot
|