mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-03 13:59:12 +08:00
feat(plugins): Restore the plugins sidebar view
This commit is contained in:
parent
c29220365a
commit
d0ac42f07f
17 changed files with 115 additions and 103 deletions
|
@ -59,18 +59,28 @@ class AccountSidebarStore extends NylasStore
|
|||
# Find root views and add them to the bottom of the list (Drafts, etc.)
|
||||
standardItems = standardCategoryItems
|
||||
standardItems.splice(1, 0, starredItem)
|
||||
standardItems.push(WorkspaceStore.sidebarItems()...)
|
||||
|
||||
customSections = {}
|
||||
for item in WorkspaceStore.sidebarItems()
|
||||
if item.section
|
||||
customSections[item.section] ?= []
|
||||
customSections[item.section].push(item)
|
||||
else
|
||||
standardItems.push(item)
|
||||
|
||||
@_sections = []
|
||||
@_sections.push
|
||||
label: 'Mailboxes'
|
||||
items: standardItems
|
||||
type: 'mailboxes'
|
||||
|
||||
for section, items of customSections
|
||||
@_sections.push
|
||||
label: section
|
||||
items: items
|
||||
|
||||
@_sections.push
|
||||
label: CategoryStore.categoryLabel()
|
||||
items: userCategoryItems
|
||||
type: 'category'
|
||||
|
||||
@trigger()
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
React = require "react"
|
||||
ActivitySidebar = require "./activity-sidebar"
|
||||
NotificationStore = require './notifications-store'
|
||||
NotificationsStickyBar = require "./notifications-sticky-bar"
|
||||
{ComponentRegistry, WorkspaceStore} = require("nylas-exports")
|
||||
|
||||
|
|
27
internal_packages/plugins/lib/main.cjsx
Normal file
27
internal_packages/plugins/lib/main.cjsx
Normal file
|
@ -0,0 +1,27 @@
|
|||
PluginsView = require "./plugins-view"
|
||||
PluginsTabsView = require "./plugins-tabs-view"
|
||||
|
||||
{ComponentRegistry,
|
||||
WorkspaceStore} = require 'nylas-exports'
|
||||
|
||||
module.exports =
|
||||
|
||||
activate: (@state={}) ->
|
||||
WorkspaceStore.defineSheet 'Plugins', {root: true, name: 'Plugins', supportedModes: ['list']},
|
||||
list: ['RootSidebar', 'Plugins']
|
||||
|
||||
@sidebarItem = new WorkspaceStore.SidebarItem
|
||||
sheet: WorkspaceStore.Sheet.Plugins
|
||||
id: 'Plugins'
|
||||
name: 'Plugins'
|
||||
section: 'Views'
|
||||
|
||||
WorkspaceStore.addSidebarItem(@sidebarItem)
|
||||
|
||||
ComponentRegistry.register PluginsView,
|
||||
location: WorkspaceStore.Location.Plugins
|
||||
|
||||
deactivate: ->
|
||||
ComponentRegistry.unregister(PluginsView)
|
||||
ComponentRegistry.unregister(PluginsTabsView)
|
||||
WorkspaceStore.undefineSheet('Plugins')
|
|
@ -8,6 +8,7 @@ class PackageSet extends React.Component
|
|||
'emptyText': React.PropTypes.string
|
||||
|
||||
render: ->
|
||||
return false unless @props.packages
|
||||
packages = @props.packages.map (pkg) -> <Package package={pkg} />
|
||||
count = <span>({@props.packages.length})</span>
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
React = require 'react'
|
||||
_ = require 'underscore'
|
||||
|
||||
SettingsActions = require './settings-actions'
|
||||
PluginsActions = require './plugins-actions'
|
||||
|
||||
class Package extends React.Component
|
||||
@displayName: 'Package'
|
||||
|
@ -16,10 +16,11 @@ class Package extends React.Component
|
|||
extras = []
|
||||
|
||||
if @props.package.installed
|
||||
if @props.package.enabled
|
||||
actions.push <div className="btn btn-small" onClick={@_onDisablePackage}>Disable</div>
|
||||
else
|
||||
actions.push <div className="btn btn-small" onClick={@_onEnablePackage}>Enable</div>
|
||||
if @props.package.category in ['user' ,'dev']
|
||||
if @props.package.enabled
|
||||
actions.push <div className="btn btn-small" onClick={@_onDisablePackage}>Disable</div>
|
||||
else
|
||||
actions.push <div className="btn btn-small" onClick={@_onEnablePackage}>Enable</div>
|
||||
if @props.package.category is 'user'
|
||||
actions.push <div className="btn btn-small" onClick={@_onUninstallPackage}>Uninstall</div>
|
||||
if @props.package.category is 'dev'
|
||||
|
@ -50,21 +51,21 @@ class Package extends React.Component
|
|||
</div>
|
||||
|
||||
_onDisablePackage: =>
|
||||
SettingsActions.disablePackage(@props.package)
|
||||
PluginsActions.disablePackage(@props.package)
|
||||
|
||||
_onEnablePackage: =>
|
||||
SettingsActions.enablePackage(@props.package)
|
||||
PluginsActions.enablePackage(@props.package)
|
||||
|
||||
_onUninstallPackage: =>
|
||||
SettingsActions.uninstallPackage(@props.package)
|
||||
PluginsActions.uninstallPackage(@props.package)
|
||||
|
||||
_onUpdatePackage: =>
|
||||
SettingsActions.updatePackage(@props.package)
|
||||
PluginsActions.updatePackage(@props.package)
|
||||
|
||||
_onInstallPackage: =>
|
||||
SettingsActions.installPackage(@props.package)
|
||||
PluginsActions.installPackage(@props.package)
|
||||
|
||||
_onShowPackage: =>
|
||||
SettingsActions.showPackage(@props.package)
|
||||
PluginsActions.showPackage(@props.package)
|
||||
|
||||
module.exports = Package
|
|
@ -4,12 +4,12 @@ Reflux = require 'reflux'
|
|||
path = require 'path'
|
||||
fs = require 'fs-plus'
|
||||
shell = require 'shell'
|
||||
SettingsActions = require './settings-actions'
|
||||
PluginsActions = require './plugins-actions'
|
||||
{APMWrapper} = require 'nylas-exports'
|
||||
dialog = require('remote').require('dialog')
|
||||
|
||||
module.exports =
|
||||
SettingsPackagesStore = Reflux.createStore
|
||||
PackagesStore = Reflux.createStore
|
||||
|
||||
init: ->
|
||||
@_apm = new APMWrapper()
|
||||
|
@ -22,8 +22,8 @@ SettingsPackagesStore = Reflux.createStore
|
|||
@_searchResults = null
|
||||
@_refreshFeatured()
|
||||
|
||||
@listenTo SettingsActions.refreshFeaturedPackages, @_refreshFeatured
|
||||
@listenTo SettingsActions.refreshInstalledPackages, @_refreshInstalled
|
||||
@listenTo PluginsActions.refreshFeaturedPackages, @_refreshFeatured
|
||||
@listenTo PluginsActions.refreshInstalledPackages, @_refreshInstalled
|
||||
|
||||
atom.commands.add 'body',
|
||||
'application:create-package': => @_onCreatePackage()
|
||||
|
@ -31,16 +31,16 @@ SettingsPackagesStore = Reflux.createStore
|
|||
atom.commands.add 'body',
|
||||
'application:install-package': => @_onInstallPackage()
|
||||
|
||||
@listenTo SettingsActions.createPackage, @_onCreatePackage
|
||||
@listenTo SettingsActions.updatePackage, @_onUpdatePackage
|
||||
@listenTo SettingsActions.setGlobalSearchValue, @_onGlobalSearchChange
|
||||
@listenTo SettingsActions.setInstalledSearchValue, @_onInstalledSearchChange
|
||||
@listenTo PluginsActions.createPackage, @_onCreatePackage
|
||||
@listenTo PluginsActions.updatePackage, @_onUpdatePackage
|
||||
@listenTo PluginsActions.setGlobalSearchValue, @_onGlobalSearchChange
|
||||
@listenTo PluginsActions.setInstalledSearchValue, @_onInstalledSearchChange
|
||||
|
||||
@listenTo SettingsActions.showPackage, (pkg) =>
|
||||
@listenTo PluginsActions.showPackage, (pkg) =>
|
||||
dir = atom.packages.resolvePackagePath(pkg.name)
|
||||
shell.showItemInFolder(dir) if dir
|
||||
|
||||
@listenTo SettingsActions.installPackage, (pkg) =>
|
||||
@listenTo PluginsActions.installPackage, (pkg) =>
|
||||
@_installing[pkg.name] = true
|
||||
@trigger(@)
|
||||
@_apm.install pkg, (err) =>
|
||||
|
@ -52,7 +52,7 @@ SettingsPackagesStore = Reflux.createStore
|
|||
atom.packages.enablePackage(pkg.name)
|
||||
@_onPackagesChanged()
|
||||
|
||||
@listenTo SettingsActions.uninstallPackage, (pkg) =>
|
||||
@listenTo PluginsActions.uninstallPackage, (pkg) =>
|
||||
if atom.packages.isPackageLoaded(pkg.name)
|
||||
atom.packages.disablePackage(pkg.name)
|
||||
atom.packages.unloadPackage(pkg.name)
|
||||
|
@ -60,11 +60,11 @@ SettingsPackagesStore = Reflux.createStore
|
|||
@_displayMessage("Sorry, an error occurred", err.toString()) if err
|
||||
@_onPackagesChanged()
|
||||
|
||||
@listenTo SettingsActions.enablePackage, (pkg) ->
|
||||
@listenTo PluginsActions.enablePackage, (pkg) ->
|
||||
if atom.packages.isPackageDisabled(pkg.name)
|
||||
atom.packages.enablePackage(pkg.name)
|
||||
|
||||
@listenTo SettingsActions.disablePackage, (pkg) ->
|
||||
@listenTo PluginsActions.disablePackage, (pkg) ->
|
||||
unless atom.packages.isPackageDisabled(pkg.name)
|
||||
atom.packages.disablePackage(pkg.name)
|
||||
|
|
@ -4,11 +4,11 @@ _ = require "underscore"
|
|||
classNames = require 'classnames'
|
||||
|
||||
Tabs = require './tabs'
|
||||
SettingsActions = require './settings-actions'
|
||||
SettingsStore = require './settings-store'
|
||||
TabsStore = require './tabs-store'
|
||||
PluginsActions = require './plugins-actions'
|
||||
|
||||
class SettingsTabs extends React.Component
|
||||
@displayName: 'SettingsTabs'
|
||||
class PluginsTabs extends React.Component
|
||||
@displayName: 'PluginsTabs'
|
||||
|
||||
@propTypes:
|
||||
'onChange': React.PropTypes.Func
|
||||
|
@ -22,7 +22,7 @@ class SettingsTabs extends React.Component
|
|||
@state = @_getStateFromStores()
|
||||
|
||||
render: ->
|
||||
<ul className="settings-view-tabs">
|
||||
<ul className="plugins-view-tabs">
|
||||
{@_renderItems()}
|
||||
</ul>
|
||||
|
||||
|
@ -31,20 +31,20 @@ class SettingsTabs extends React.Component
|
|||
classes = classNames
|
||||
'tab': true
|
||||
'active': idx is @state.tabIndex
|
||||
<li key={key} className={classes} onClick={ => SettingsActions.selectTabIndex(idx)}>{name}</li>
|
||||
<li key={key} className={classes} onClick={ => PluginsActions.selectTabIndex(idx)}>{name}</li>
|
||||
|
||||
componentDidMount: =>
|
||||
@_unsubscribers = []
|
||||
@_unsubscribers.push SettingsStore.listen(@_onChange)
|
||||
@_unsubscribers.push TabsStore.listen(@_onChange)
|
||||
|
||||
componentWillUnmount: =>
|
||||
unsubscribe() for unsubscribe in @_unsubscribers
|
||||
|
||||
_getStateFromStores: =>
|
||||
tabIndex: SettingsStore.tabIndex()
|
||||
tabIndex: TabsStore.tabIndex()
|
||||
|
||||
_onChange: =>
|
||||
@setState(@_getStateFromStores())
|
||||
|
||||
|
||||
module.exports = SettingsTabs
|
||||
module.exports = PluginsTabs
|
|
@ -3,33 +3,32 @@ _ = require "underscore"
|
|||
{Flexbox} = require 'nylas-component-kit'
|
||||
classNames = require 'classnames'
|
||||
|
||||
SettingsStore = require './settings-store'
|
||||
TabsStore = require './tabs-store'
|
||||
Tabs = require './tabs'
|
||||
|
||||
class SettingsView extends React.Component
|
||||
@displayName: 'SettingsView'
|
||||
class PluginsView extends React.Component
|
||||
@displayName: 'PluginsView'
|
||||
|
||||
constructor: (@props) ->
|
||||
@state = @_getStateFromStores()
|
||||
|
||||
render: =>
|
||||
SettingsTabComponent = Tabs[@state.tabIndex].component
|
||||
<div className="settings-view">
|
||||
<SettingsTabComponent />
|
||||
PluginsTabComponent = Tabs[@state.tabIndex].component
|
||||
<div className="plugins-view">
|
||||
<PluginsTabComponent />
|
||||
</div>
|
||||
|
||||
componentDidMount: =>
|
||||
@_unsubscribers = []
|
||||
@_unsubscribers.push SettingsStore.listen(@_onChange)
|
||||
@_unsubscribers.push TabsStore.listen(@_onChange)
|
||||
|
||||
componentWillUnmount: =>
|
||||
unsubscribe() for unsubscribe in @_unsubscribers
|
||||
|
||||
_getStateFromStores: =>
|
||||
tabIndex: SettingsStore.tabIndex()
|
||||
tabIndex: TabsStore.tabIndex()
|
||||
|
||||
_onChange: =>
|
||||
@setState(@_getStateFromStores())
|
||||
|
||||
|
||||
module.exports = SettingsView
|
||||
module.exports = PluginsView
|
|
@ -1,8 +1,8 @@
|
|||
React = require 'react'
|
||||
_ = require "underscore"
|
||||
PackageSet = require './package-set'
|
||||
SettingsPackagesStore = require './settings-packages-store'
|
||||
SettingsActions = require './settings-actions'
|
||||
PackagesStore = require './packages-store'
|
||||
PluginsActions = require './plugins-actions'
|
||||
{Spinner, EventedIFrame, Flexbox} = require 'nylas-component-kit'
|
||||
classNames = require 'classnames'
|
||||
|
||||
|
@ -46,24 +46,24 @@ class TabExplore extends React.Component
|
|||
|
||||
componentDidMount: =>
|
||||
@_unsubscribers = []
|
||||
@_unsubscribers.push SettingsPackagesStore.listen(@_onChange)
|
||||
@_unsubscribers.push PackagesStore.listen(@_onChange)
|
||||
|
||||
# Trigger a refresh of the featured packages
|
||||
SettingsActions.refreshFeaturedPackages()
|
||||
PluginsActions.refreshFeaturedPackages()
|
||||
|
||||
componentWillUnmount: =>
|
||||
unsubscribe() for unsubscribe in @_unsubscribers
|
||||
|
||||
_getStateFromStores: =>
|
||||
featured: SettingsPackagesStore.featured()
|
||||
search: SettingsPackagesStore.globalSearchValue()
|
||||
searchResults: SettingsPackagesStore.searchResults()
|
||||
featured: PackagesStore.featured()
|
||||
search: PackagesStore.globalSearchValue()
|
||||
searchResults: PackagesStore.searchResults()
|
||||
|
||||
_onChange: =>
|
||||
@setState(@_getStateFromStores())
|
||||
|
||||
_onSearchChange: (event) =>
|
||||
SettingsActions.setGlobalSearchValue(event.target.value)
|
||||
PluginsActions.setGlobalSearchValue(event.target.value)
|
||||
|
||||
|
||||
module.exports = TabExplore
|
|
@ -1,8 +1,8 @@
|
|||
React = require 'react'
|
||||
_ = require "underscore"
|
||||
PackageSet = require './package-set'
|
||||
SettingsPackagesStore = require './settings-packages-store'
|
||||
SettingsActions = require './settings-actions'
|
||||
PackagesStore = require './packages-store'
|
||||
PluginsActions = require './plugins-actions'
|
||||
{Spinner, EventedIFrame, Flexbox} = require 'nylas-component-kit'
|
||||
classNames = require 'classnames'
|
||||
|
||||
|
@ -26,41 +26,41 @@ class TabInstalled extends React.Component
|
|||
placeholder="Search Installed Packages"/>
|
||||
<PackageSet
|
||||
packages={@state.packages.user}
|
||||
title="Community"
|
||||
emptyText={searchEmpty ? "You don't have any community packages installed"} />
|
||||
<PackageSet
|
||||
title="Core"
|
||||
packages={@state.packages.core} />
|
||||
title="Installed"
|
||||
emptyText={searchEmpty ? "You don't have any packages installed in ~/.nylas/packages."} />
|
||||
<PackageSet
|
||||
title="Development"
|
||||
packages={@state.packages.dev}
|
||||
emptyText={searchEmpty ? "You don't have any packages in ~/.nylas/dev/packages"} />
|
||||
emptyText={searchEmpty ? <span>You don't have any packages installed in ~/.nylas/dev/packages. These packages are only loaded when you run the app with debug flags enabled (via the Developer menu).<br/><br/>Learn more about building packages at <a href='https://nylas.github.io/N1/docs'>https://nylas.github.io/N1/docs</a></span>} />
|
||||
<div className="new-package">
|
||||
<div className="btn btn-large" onClick={@_onCreatePackage}>Create New Package...</div>
|
||||
</div>
|
||||
<PackageSet
|
||||
title="Core"
|
||||
packages={@state.packages.core} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
componentDidMount: =>
|
||||
@_unsubscribers = []
|
||||
@_unsubscribers.push SettingsPackagesStore.listen(@_onChange)
|
||||
@_unsubscribers.push PackagesStore.listen(@_onChange)
|
||||
|
||||
SettingsActions.refreshInstalledPackages()
|
||||
PluginsActions.refreshInstalledPackages()
|
||||
|
||||
componentWillUnmount: =>
|
||||
unsubscribe() for unsubscribe in @_unsubscribers
|
||||
|
||||
_getStateFromStores: =>
|
||||
packages: SettingsPackagesStore.installed()
|
||||
search: SettingsPackagesStore.installedSearchValue()
|
||||
packages: PackagesStore.installed()
|
||||
search: PackagesStore.installedSearchValue()
|
||||
|
||||
_onChange: =>
|
||||
@setState(@_getStateFromStores())
|
||||
|
||||
_onCreatePackage: =>
|
||||
SettingsActions.createPackage()
|
||||
PluginsActions.createPackage()
|
||||
|
||||
_onSearchChange: (event) =>
|
||||
SettingsActions.setInstalledSearchValue(event.target.value)
|
||||
PluginsActions.setInstalledSearchValue(event.target.value)
|
||||
|
||||
module.exports = TabInstalled
|
|
@ -2,14 +2,14 @@ _ = require 'underscore'
|
|||
ipc = require 'ipc'
|
||||
Reflux = require 'reflux'
|
||||
|
||||
SettingsActions = require './settings-actions'
|
||||
PluginsActions = require './plugins-actions'
|
||||
|
||||
module.exports =
|
||||
SettingsStore = Reflux.createStore
|
||||
TabsStore = Reflux.createStore
|
||||
|
||||
init: ->
|
||||
@_tabIndex = 0
|
||||
@listenTo(SettingsActions.selectTabIndex, @_onTabIndexChanged)
|
||||
@listenTo(PluginsActions.selectTabIndex, @_onTabIndexChanged)
|
||||
|
||||
# Getters
|
||||
|
|
@ -1,9 +1,4 @@
|
|||
module.exports = [{
|
||||
key: 'explore'
|
||||
name: 'Explore'
|
||||
icon: 'tbd'
|
||||
component: require './tab-explore'
|
||||
},{
|
||||
key: 'installed'
|
||||
name: 'Installed'
|
||||
icon: 'tbd'
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"name": "settings",
|
||||
"name": "plugins",
|
||||
"version": "0.1.0",
|
||||
"main": "./lib/main",
|
||||
"description": "Settings",
|
||||
"description": "Plugins",
|
||||
"license": "Proprietary",
|
||||
"private": true,
|
||||
"engines": {
|
|
@ -1,7 +1,7 @@
|
|||
@import "ui-variables";
|
||||
@import "ui-mixins";
|
||||
|
||||
.settings-view-tabs {
|
||||
.plugins-view-tabs {
|
||||
color: @text-color-subtle;
|
||||
list-style-type: none;
|
||||
padding-left:0;
|
||||
|
@ -21,7 +21,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
.settings-view {
|
||||
.plugins-view {
|
||||
background: @background-off-primary;
|
||||
position: absolute;
|
||||
width:100%;
|
|
@ -1,22 +0,0 @@
|
|||
SettingsView = require "./settings-view"
|
||||
SettingsTabsView = require "./settings-tabs-view"
|
||||
|
||||
{ComponentRegistry,
|
||||
WorkspaceStore} = require 'nylas-exports'
|
||||
|
||||
module.exports =
|
||||
|
||||
activate: (@state={}) ->
|
||||
WorkspaceStore.defineSheet 'Settings', {root: true, supportedModes: ['list']},
|
||||
list: ['RootSidebar', 'SettingsSidebar', 'Settings']
|
||||
|
||||
ComponentRegistry.register SettingsTabsView,
|
||||
location: WorkspaceStore.Location.SettingsSidebar
|
||||
|
||||
ComponentRegistry.register SettingsView,
|
||||
location: WorkspaceStore.Location.Settings
|
||||
|
||||
deactivate: ->
|
||||
ComponentRegistry.unregister(SettingsView)
|
||||
ComponentRegistry.unregister(SettingsTabsView)
|
||||
WorkspaceStore.undefineSheet('Settings')
|
|
@ -8,7 +8,7 @@ Location = {}
|
|||
SidebarItems = {}
|
||||
|
||||
class WorkspaceSidebarItem
|
||||
constructor: ({@id, @component, @name, @sheet, @mailViewFilter}) ->
|
||||
constructor: ({@id, @component, @name, @sheet, @mailViewFilter, @section}) ->
|
||||
if not @sheet and not @mailViewFilter and not @component
|
||||
throw new Error("WorkspaceSidebarItem: You must provide either a sheet \
|
||||
component, or a mailViewFilter for the sidebar item named #{@name}")
|
||||
|
|
Loading…
Reference in a new issue