Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Devrim Gunyel
core
Commits
6556859d
Commit
6556859d
authored
Aug 13, 2019
by
Piotr Gawron
Browse files
when plugin crash on upload it's removed from the system properly
parent
b9e9d3c9
Changes
4
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
6556859d
...
...
@@ -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
...
...
frontend-js/src/main/js/plugin/Plugin.js
View file @
6556859d
...
...
@@ -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
;
};
...
...
frontend-js/src/main/js/plugin/PluginManager.js
View file @
6556859d
...
...
@@ -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
);
});
});
...
...
frontend-js/src/test/js/plugin/PluginManager-test.js
View file @
6556859d
...
...
@@ -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
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment