Fix plugin information
Change-Id: Ia53095c1f790363b750a8beb7a4b2e85c7c5371c
diff --git a/dev/js/spec/pluginSpec.js b/dev/js/spec/pluginSpec.js
index 5064e1c..43fd303 100644
--- a/dev/js/spec/pluginSpec.js
+++ b/dev/js/spec/pluginSpec.js
@@ -113,7 +113,7 @@
expect(manager.buttonGroup('match').length).toEqual(1);
manager.destroy();
});
-
+
it('should accept valid registrations for query temporary', function () {
var manager = pluginServerClass.create();
@@ -192,7 +192,6 @@
KorAP.Panel["result"] = undefined;
});
-
it('should accept valid registrations for setWidget', function () {
let p = KorAP.Panel["result"] = panelClass.create();
@@ -244,6 +243,83 @@
KorAP.Panel["result"] = undefined;
});
+ it('should alert on plugin info (1)', function () {
+
+ let alertMsg;
+ spyOn(window, 'alert').and.callFake(function(msg) {
+ alertMsg = msg;
+ });
+
+ let p = KorAP.Panel["result"] = panelClass.create();
+
+ let manager = pluginServerClass.create();
+
+ manager.register({
+ name : 'Check',
+ embed : [{
+ panel : 'result',
+ title : 'Add',
+ onClick : {
+ template : 'about:blank',
+ action : 'setWidget'
+ }
+ }]
+ });
+
+ expect(alertMsg).toBeUndefined();
+
+ let b = p.actions.element().firstChild;
+ b.click();
+
+ // This may only be temporary and should open the plugin window instead
+ p.element().querySelector("span.plugin").click();
+
+ expect(alertMsg).toEqual('Check');
+
+ manager.destroy();
+ KorAP.Panel["result"] = undefined;
+ });
+
+
+ it('should alert on plugin info (2)', function () {
+
+ let alertMsg;
+ spyOn(window, 'alert').and.callFake(function(msg) {
+ alertMsg = msg;
+ });
+
+ let p = KorAP.Panel["result"] = panelClass.create();
+
+ let manager = pluginServerClass.create();
+
+ manager.register({
+ name : 'Check',
+ desc : 'Simple Check plugin',
+ embed : [{
+ panel : 'result',
+ title : 'Add',
+ onClick : {
+ template : 'about:blank',
+ action : 'setWidget'
+ }
+ }]
+ });
+
+ expect(alertMsg).toBeUndefined();
+
+ let b = p.actions.element().firstChild;
+ b.click();
+
+ // This may only be temporary and should open the plugin window instead
+ p.element().querySelector("span.plugin").click();
+
+ expect(alertMsg).toEqual("Check\n\nSimple Check plugin");
+
+ manager.destroy();
+ KorAP.Panel["result"] = undefined;
+ });
+
+
it('should accept widget permissions', function () {
let p = KorAP.Panel["result"] = panelClass.create();
diff --git a/dev/js/src/plugin/server.js b/dev/js/src/plugin/server.js
index 4504e56..76ac11d 100644
--- a/dev/js/src/plugin/server.js
+++ b/dev/js/src/plugin/server.js
@@ -8,7 +8,7 @@
* @author Nils Diewald
*/
-define(["plugin/widget", 'plugin/service', 'state', "util"], function (widgetClass, serviceClass, stateClass) {
+define(['plugin/widget', 'plugin/service', 'state', 'util'], function (widgetClass, serviceClass, stateClass) {
"use strict";
KorAP.Panel = KorAP.Panel || {};
@@ -109,10 +109,12 @@
if (!name)
throw new Error("Missing name of plugin");
+ var desc = obj["desc"];
+
// Register plugin by name
var plugin = plugins[name] = {
name : name,
- desc : obj["desc"],
+ desc : desc,
about : obj["about"],
widgets : [],
services : []
@@ -181,7 +183,8 @@
let id = that.addWidget(this, {
"name": name,
"src": onClick["template"], // that._interpolateURI(onClick["template"], this.match);
- "permissions": onClick["permissions"]
+ "permissions": onClick["permissions"],
+ "desc":desc
});
plugin["widgets"].push(id);
diff --git a/dev/js/src/plugin/service.js b/dev/js/src/plugin/service.js
index 4c91f6a..3a39c4d 100644
--- a/dev/js/src/plugin/service.js
+++ b/dev/js/src/plugin/service.js
@@ -24,6 +24,7 @@
this.name = data["name"];
this.src = data["src"];
this.id = data["id"];
+ this.desc = data["desc"];
let _perm = new Set();
let perm = data["permissions"];
if (perm && Array.isArray(perm)) {
diff --git a/dev/js/src/plugin/widget.js b/dev/js/src/plugin/widget.js
index e661e6d..546cd1b 100644
--- a/dev/js/src/plugin/widget.js
+++ b/dev/js/src/plugin/widget.js
@@ -50,7 +50,11 @@
this.name, {'cls':['button-icon', 'plugin']}, function (e) {
// Temporary
- window.alert("Basic information about this plugin");
+ let str = this.name;
+ if (this.desc !== undefined) {
+ str += "\n\n" + this.desc;
+ };
+ window.alert(str);
}.bind(this));
return obj;