diff --git a/src/browser/application.es6 b/src/browser/application.es6 index 5973a5ec0..4f4cef838 100644 --- a/src/browser/application.es6 +++ b/src/browser/application.es6 @@ -707,6 +707,8 @@ export default class Application extends EventEmitter { } else if (parts.protocol === 'nylas:') { if (parts.host === 'calendar') { this.openCalendarURL(parts.path); + } else if (parts.host === 'plugins') { + main.sendMessage('changePluginStateFromUrl', urlToOpen); } else { main.sendMessage('openExternalThread', urlToOpen); } diff --git a/src/package-manager.coffee b/src/package-manager.coffee index 03ded0d77..103710eb3 100644 --- a/src/package-manager.coffee +++ b/src/package-manager.coffee @@ -1,7 +1,8 @@ path = require 'path' +url = require 'url' _ = require 'underscore' -{remote} = require 'electron' +{ipcRenderer, remote} = require 'electron' EmitterMixin = require('emissary').Emitter {Emitter} = require 'event-kit' fs = require 'fs-plus' @@ -58,6 +59,8 @@ class PackageManager @packageActivators = [] @registerPackageActivator(this, ['nylas']) + ipcRenderer.on("changePluginStateFromUrl", @_onChangePluginState) + pluginIdFor: (packageName) => env = NylasEnv.config.get("env") @@ -67,6 +70,12 @@ class PackageManager @cachedPackagePluginIds[cacheKey] = @_resolvePluginIdFor(packageName, env) return @cachedPackagePluginIds[cacheKey] + _onChangePluginState: (event, urlToOpen = "") => + {query} = url.parse(urlToOpen, true) + for name, state of query + if state is "off" then @deactivatePackage(name) + else if state is "on" then @activatePackage(name) + _resolvePluginIdFor: (packageName, env) => metadata = @loadedPackages[packageName]?.metadata