mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-01 13:14:16 +08:00
fix(plugin): better errors if plugins are malformed
Fixed read assets
This commit is contained in:
parent
57d7057161
commit
cc15d35848
5 changed files with 29 additions and 11 deletions
BIN
internal_packages/open-tracking/assets/InMessage-Read@1x.png
Normal file
BIN
internal_packages/open-tracking/assets/InMessage-Read@1x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
internal_packages/open-tracking/assets/InMessage-Read@2x.png
Normal file
BIN
internal_packages/open-tracking/assets/InMessage-Read@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
|
@ -37,7 +37,8 @@ export default class OpenTrackingMessageStatus extends React.Component {
|
||||||
return (
|
return (
|
||||||
<RetinaImg
|
<RetinaImg
|
||||||
className={this.state.opened ? "opened" : "unopened"}
|
className={this.state.opened ? "opened" : "unopened"}
|
||||||
url="nylas://open-tracking/assets/icon-composer-eye@2x.png"
|
style={{position: 'relative', top: -1}}
|
||||||
|
url="nylas://open-tracking/assets/InMessage-Read@2x.png"
|
||||||
mode={RetinaImg.Mode.ContentIsMask} />
|
mode={RetinaImg.Mode.ContentIsMask} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,15 +173,13 @@ PackagesStore = Reflux.createStore
|
||||||
properties: ['openDirectory']
|
properties: ['openDirectory']
|
||||||
, (filenames) =>
|
, (filenames) =>
|
||||||
return if not filenames or filenames.length is 0
|
return if not filenames or filenames.length is 0
|
||||||
NylasEnv.packages.installPackageFromPath filenames[0], (err, packageTargetDir) =>
|
NylasEnv.packages.installPackageFromPath filenames[0], (err) =>
|
||||||
return if err
|
return if err
|
||||||
packageName = path.basename(filenames[0])
|
packageName = path.basename(filenames[0])
|
||||||
msg = "#{packageName} has been installed and enabled. No need to \
|
msg = "#{packageName} has been installed and enabled. No need to \
|
||||||
restart! If you don't see the package loaded, check the \
|
restart! If you don't see the package loaded, check the \
|
||||||
console for errors."
|
console for errors."
|
||||||
@_displayMessage("Package installed", msg)
|
@_displayMessage("Plugin installed 🎉", msg)
|
||||||
if packageTargetDir
|
|
||||||
shell.showItemInFolder(packageTargetDir)
|
|
||||||
|
|
||||||
_onCreatePackage: ->
|
_onCreatePackage: ->
|
||||||
if not NylasEnv.inDevMode()
|
if not NylasEnv.inDevMode()
|
||||||
|
@ -210,19 +208,19 @@ PackagesStore = Reflux.createStore
|
||||||
packageName = path.basename(packageDir)
|
packageName = path.basename(packageDir)
|
||||||
|
|
||||||
if not packageDir.startsWith(packagesDir)
|
if not packageDir.startsWith(packagesDir)
|
||||||
return @_displayMessage('Invalid package location', 'Sorry, you must
|
return @_displayMessage('Invalid plugin location', 'Sorry, you must
|
||||||
create packages in the packages folder.')
|
create plugins in the packages folder.')
|
||||||
|
|
||||||
if NylasEnv.packages.resolvePackagePath(packageName)
|
if NylasEnv.packages.resolvePackagePath(packageName)
|
||||||
return @_displayMessage('Invalid package name', 'Sorry, you must
|
return @_displayMessage('Invalid plugin name', 'Sorry, you must
|
||||||
give your package a unqiue name.')
|
give your plugin a unqiue name.')
|
||||||
|
|
||||||
if packageName.indexOf(' ') isnt -1
|
if packageName.indexOf(' ') isnt -1
|
||||||
return @_displayMessage('Invalid package name', 'Sorry, package names
|
return @_displayMessage('Invalid plugin name', 'Sorry, plugin names
|
||||||
cannot contain spaces.')
|
cannot contain spaces.')
|
||||||
|
|
||||||
fs.mkdir packageDir, (err) =>
|
fs.mkdir packageDir, (err) =>
|
||||||
return @_displayMessage('Could not create package', err.toString()) if err
|
return @_displayMessage('Could not create plugin', err.toString()) if err
|
||||||
|
|
||||||
{resourcePath} = NylasEnv.getLoadSettings()
|
{resourcePath} = NylasEnv.getLoadSettings()
|
||||||
packageTemplatePath = path.join(resourcePath, 'static', 'package-template')
|
packageTemplatePath = path.join(resourcePath, 'static', 'package-template')
|
||||||
|
|
|
@ -6,6 +6,7 @@ EmitterMixin = require('emissary').Emitter
|
||||||
fs = require 'fs-plus'
|
fs = require 'fs-plus'
|
||||||
Q = require 'q'
|
Q = require 'q'
|
||||||
Grim = require 'grim'
|
Grim = require 'grim'
|
||||||
|
CSON = require 'season'
|
||||||
|
|
||||||
ServiceHub = require 'service-hub'
|
ServiceHub = require 'service-hub'
|
||||||
Package = require './package'
|
Package = require './package'
|
||||||
|
@ -338,6 +339,8 @@ class PackageManager
|
||||||
dialog = require('remote').require('dialog')
|
dialog = require('remote').require('dialog')
|
||||||
shell = require('shell')
|
shell = require('shell')
|
||||||
|
|
||||||
|
return unless @verifyValidPackage(packageSourceDir, callback)
|
||||||
|
|
||||||
packagesDir = path.join(NylasEnv.getConfigDirPath(), 'packages')
|
packagesDir = path.join(NylasEnv.getConfigDirPath(), 'packages')
|
||||||
packageName = path.basename(packageSourceDir)
|
packageName = path.basename(packageSourceDir)
|
||||||
packageTargetDir = path.join(packagesDir, packageName)
|
packageTargetDir = path.join(packagesDir, packageName)
|
||||||
|
@ -376,6 +379,22 @@ class PackageManager
|
||||||
@activatePackage(packageName)
|
@activatePackage(packageName)
|
||||||
callback(null, packageTargetDir)
|
callback(null, packageTargetDir)
|
||||||
|
|
||||||
|
verifyValidPackage: (packageSourceDir, callback) ->
|
||||||
|
if CSON.resolve(path.join(packageSourceDir, 'package'))
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
errMsg = "The folder you selected doesn't look like a valid N1 plugin. All N1 plugins must have a package.json file in the top level of the folder. Check the contents of #{packageSourceDir} and try again"
|
||||||
|
|
||||||
|
dialog = require('remote').require('dialog')
|
||||||
|
dialog.showMessageBox({
|
||||||
|
type: 'warning'
|
||||||
|
buttons: ['OK']
|
||||||
|
title: 'Not a valid plugin folder'
|
||||||
|
message: errMsg
|
||||||
|
})
|
||||||
|
|
||||||
|
callback(errMsg)
|
||||||
|
return false
|
||||||
###
|
###
|
||||||
Section: Private
|
Section: Private
|
||||||
###
|
###
|
||||||
|
|
Loading…
Reference in a new issue