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

non public plugins were disabling addition of public plugins

parent 361bcfb5
Pipeline #8957 passed with stage
in 9 minutes and 38 seconds
minerva (12.2.0~beta.2) unstable; urgency=medium
* Bug fix: plugin can be added after plugin has been removed in admin plugin
panel (#686)
* Bug fix: too many annotations (>=100) caused misaligning in the left panel
(#708)
* Bug fix: text was outside the popup window (#711)
......
......@@ -176,7 +176,7 @@ AddPluginDialog.prototype.onValidateClicked = function () {
}).then(function (plugins) {
for (var i = 0; i < plugins.length; i++) {
var pluginData = plugins[i];
if (pluginData.getUrls().indexOf(url) >= 0) {
if (pluginData.getUrls().indexOf(url) >= 0 && pluginData.isPublic()) {
throw new ValidationError("Plugin is already registered");
}
}
......
"use strict";
var Functions = require('../../Functions');
/**
*
* @param {Object} params
......@@ -36,11 +38,13 @@ PluginData.prototype.getHash = function () {
/**
*
* @param {boolean} isPublic
* @param {string|boolean} isPublic
*/
PluginData.prototype.setPublic = function (isPublic) {
if (isPublic === null || isPublic === undefined) {
this._public = false;
} else if (Functions.isString(isPublic)) {
this._public = (isPublic === "true");
} else {
this._public = isPublic;
}
......
......@@ -5,6 +5,7 @@ require("../../mocha-config");
var AddPluginDialog = require('../../../../main/js/gui/admin/AddPluginDialog');
var ServerConnector = require('../../ServerConnector-mock');
var ValidationError = require('../../../../main/js/ValidationError');
var PluginData = require('../../../../main/js/map/data/PluginData');
var logger = require('../../logger');
......@@ -26,6 +27,12 @@ describe('AddPluginDialog', function () {
serverConnector: ServerConnector
});
};
var getPluginsData = ServerConnector.getPluginsData;
afterEach(function () {
ServerConnector.getPluginsData = getPluginsData;
});
it('init', function () {
helper.loginAsAdmin();
var dialog = createDialog();
......@@ -85,8 +92,35 @@ describe('AddPluginDialog', function () {
return dialog.destroy();
});
});
it('valid file exists', function () {
helper.loginAsAdmin();
var dialog = createDialog();
ServerConnector.getPluginsData = function () {
return Promise.resolve([new PluginData({urls: "./testFiles/plugin/empty.js", isPublic: "true"})]);
};
return dialog.init().then(function () {
$("[name='pluginUrl']").val("./testFiles/plugin/empty.js");
return dialog.onValidateClicked();
}).then(function () {
assert.notOk("error expected");
}).catch(function (e) {
assert.ok(e instanceof ValidationError);
}).finally(function () {
return dialog.destroy();
});
});
it('valid file exists as a private plugin', function () {
helper.loginAsAdmin();
var dialog = createDialog();
ServerConnector.getPluginsData = function () {
return Promise.resolve([new PluginData({urls: "./testFiles/plugin/empty.js", isPublic: "false"})]);
};
return dialog.init().then(function () {
$("[name='pluginUrl']").val("./testFiles/plugin/empty.js");
return dialog.onValidateClicked();
}).finally(function () {
return dialog.destroy();
});
});
});
})
;
});
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