Commit a53251e2 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '885-minervanet-error-report-93' into 'master'

Resolve "MINERVANET - Error Report 93"

Closes #885

See merge request !877
parents 25d75e28 6556859d
Pipeline #12733 passed with stage
in 12 minutes and 3 seconds
......@@ -8,6 +8,8 @@ minerva (14.0.0~alpha.1) unstable; urgency=low
* Bug fix: some project couldn't be accessed due to problem with migration of
reaction with unknown boolean operator (#880)
* Bug fix: problem with unloading plugin is properly handled (#884)
* Bug fix: upload of invalid plugin doesn't add it to plugin tab and list of
loaded plugins (#885)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 12 Aug 2019 10:00:00 +0200
......
......@@ -107,6 +107,10 @@ Plugin.prototype.getMinervaPluginProxy = function () {
* @returns {string}
*/
Plugin.prototype.getPluginId = function () {
if (this.getMinervaPluginProxy() === undefined) {
logger.warn("Plugin is not loaded properly");
return undefined;
}
return this.getMinervaPluginProxy().pluginId;
};
......
......@@ -94,6 +94,7 @@ PluginManager.prototype.addPlugin = function (options) {
map: self.getMap(),
serverConnector: self.getServerConnector()
});
self._plugins.push(plugin);
} else {
plugin = new Plugin({
url: options.url,
......@@ -105,11 +106,11 @@ PluginManager.prototype.addPlugin = function (options) {
plugin.addListener("onUnload", function () {
self.getGuiUtils().removeTab(self, element);
});
self._plugins.push(plugin);
if (!self.isValidUrl(options.url)) {
return Promise.reject(new InvalidArgumentError("url: '" + options.url + "' is invalid"));
}
}
self._plugins.push(plugin);
return plugin.load();
}).then(function () {
$("a[href='#" + element.parentNode.id + "']", $(self.getElement()))[0].innerHTML = plugin.getName();
......@@ -140,7 +141,7 @@ PluginManager.prototype.addPlugin = function (options) {
GuiConnector.setUrlParam("plugins", self._getLoadedPluginsAsHashList());
return plugin;
}).catch(function (e) {
return plugin.unload().then(function () {
return self.removePlugin(plugin).then(function () {
GuiConnector.alert("Problem with loading plugin:<br/>" + e.message);
});
});
......
......@@ -88,10 +88,11 @@ describe('PluginManager', function () {
it('with error', function () {
var manager = createPluginManager();
return manager.addPlugin({url: "./invalid.js"}).then(function (plugin) {
return manager.addPlugin({url: "./invalid.js"}).then(function () {
assert.notOk("Expected error");
}).catch(function (e) {
assert.ok(e.message.indexOf("Problem with loading plugin") >= 0)
assert.ok(e.message.indexOf("Problem with loading plugin") >= 0);
assert.equal(0, manager.getPlugins().length);
});
});
it('with invalid url', function () {
......@@ -99,7 +100,7 @@ describe('PluginManager', function () {
manager.isValidUrl = function () {
return false;
};
return manager.addPlugin({url: "xx"}).then(function (plugin) {
return manager.addPlugin({url: "xx"}).then(function () {
assert.notOk("Expected error");
}).catch(function (e) {
assert.ok(e.message.indexOf("Problem with loading plugin") >= 0)
......@@ -146,7 +147,14 @@ describe('PluginManager', function () {
it('removing non existing plugin', function () {
var manager = createPluginManager();
var plugin = new Plugin({url: "testFiles/plugin/empty.js"});
var plugin = new Plugin({
url: "testFiles/plugin/empty.js",
map: manager.getMap(),
configuration: manager.getConfiguration(),
serverConnector: manager.getServerConnector(),
element: testDiv
});
return manager.removePlugin(plugin).then(function () {
assert.notOk("Error expected");
}, function (error) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment