Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
eef9fb5d
Commit
eef9fb5d
authored
Nov 20, 2017
by
Piotr Gawron
Browse files
plugins loaded few times have few entries in plugin dialog
parent
996f1e2d
Pipeline
#2613
passed with stage
in 1 minute
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
frontend-js/src/main/js/gui/PluginDialog.js
View file @
eef9fb5d
"
use strict
"
;
var
Promise
=
require
(
'
bluebird
'
);
var
AbstractGuiElement
=
require
(
'
./AbstractGuiElement
'
);
var
GuiConnector
=
require
(
'
../GuiConnector
'
);
var
GuiUtils
=
require
(
'
./leftPanel/GuiUtils
'
);
...
...
@@ -56,12 +53,10 @@ PluginDialog.prototype._createPluginGui = function () {
var
pluginManager
=
self
.
getPluginManager
();
var
loadedPlugins
=
[];
var
processedPlugins
=
[];
var
plugins
=
pluginManager
.
getPlugins
();
var
i
;
for
(
i
=
0
;
i
<
plugins
.
length
;
i
++
)
{
loadedPlugins
[
plugins
[
i
].
getOptions
().
url
]
=
true
;
processedPlugins
[
plugins
[
i
].
getOptions
().
url
]
=
false
;
}
for
(
i
=
0
;
i
<
self
.
_knownPlugins
.
length
;
i
++
)
{
...
...
@@ -75,23 +70,7 @@ PluginDialog.prototype._createPluginGui = function () {
});
pluginUrl
.
readOnly
=
true
;
var
button
;
if
(
loadedPlugins
[
url
])
{
button
=
Functions
.
createElement
({
type
:
"
button
"
,
content
:
"
UNLOAD
"
,
onclick
:
function
()
{
var
promises
=
[];
for
(
var
i
=
0
;
i
<
plugins
.
length
;
i
++
)
{
if
(
plugins
[
i
].
getOptions
().
url
===
$
(
this
).
data
(
"
url
"
))
{
promises
.
push
(
pluginManager
.
removePlugin
(
plugins
[
i
]));
}
}
return
Promise
.
all
(
promises
).
then
(
function
()
{
self
.
close
();
}).
then
(
null
,
GuiConnector
.
alert
);
}
});
}
else
{
if
(
!
loadedPlugins
[
url
])
{
button
=
Functions
.
createElement
({
type
:
"
button
"
,
content
:
"
LOAD
"
,
...
...
@@ -103,39 +82,33 @@ PluginDialog.prototype._createPluginGui = function () {
});
}
$
(
button
).
data
(
"
url
"
,
url
);
processedPlugins
[
url
]
=
true
;
pluginFormTab
.
appendChild
(
guiUtils
.
createTableRow
([
Functions
.
createElement
({
type
:
"
span
"
}),
pluginUrl
,
button
]));
}
for
(
url
in
loadedPlugins
)
{
if
(
loadedPlugins
.
hasOwnProperty
(
url
)
&&
!
processedPlugins
[
url
])
{
pluginUrl
=
Functions
.
createElement
({
type
:
"
input
"
,
value
:
url
,
style
:
"
color:#999999
"
});
pluginUrl
.
readOnly
=
true
;
button
=
Functions
.
createElement
({
type
:
"
button
"
,
content
:
"
UNLOAD
"
,
onclick
:
function
()
{
var
promises
=
[];
for
(
var
i
=
0
;
i
<
plugins
.
length
;
i
++
)
{
if
(
plugins
[
i
].
getOptions
().
url
===
$
(
this
).
data
(
"
url
"
))
{
promises
.
push
(
pluginManager
.
removePlugin
(
plugins
[
i
]));
}
}
return
Promise
.
all
(
promises
).
then
(
function
()
{
self
.
close
();
}).
then
(
null
,
GuiConnector
.
alert
);
}
});
$
(
button
).
data
(
"
url
"
,
url
);
for
(
i
=
0
;
i
<
plugins
.
length
;
i
++
)
{
var
plugin
=
plugins
[
i
];
var
removePlugin
=
(
function
()
{
var
pluginToRemove
=
plugin
;
return
function
()
{
return
pluginManager
.
removePlugin
(
pluginToRemove
).
then
(
function
()
{
self
.
close
();
}).
then
(
null
,
GuiConnector
.
alert
);
}
})();
pluginUrl
=
Functions
.
createElement
({
type
:
"
input
"
,
value
:
plugins
[
i
].
getOptions
().
url
,
style
:
"
color:#999999
"
});
pluginUrl
.
readOnly
=
true
;
button
=
Functions
.
createElement
({
type
:
"
button
"
,
content
:
"
UNLOAD
"
,
onclick
:
removePlugin
});
pluginFormTab
.
appendChild
(
guiUtils
.
createTableRow
([
Functions
.
createElement
({
type
:
"
span
"
}),
pluginUrl
,
button
]));
pluginFormTab
.
appendChild
(
guiUtils
.
createTableRow
([
Functions
.
createElement
({
type
:
"
span
"
}),
pluginUrl
,
button
]));
}
}
};
...
...
@@ -173,8 +146,8 @@ PluginDialog.prototype.close = function () {
PluginDialog
.
prototype
.
destroy
=
function
()
{
var
self
=
this
;
var
div
=
self
.
getElement
();
if
(
$
(
self
.
getElement
()
).
hasClass
(
"
ui-dialog-content
"
))
{
$
(
self
.
getElement
()
).
dialog
(
"
destroy
"
);
if
(
$
(
div
).
hasClass
(
"
ui-dialog-content
"
))
{
$
(
div
).
dialog
(
"
destroy
"
);
}
};
...
...
frontend-js/src/test/js/gui/OptionsMenu-test.js
View file @
eef9fb5d
...
...
@@ -47,5 +47,4 @@ describe('OptionsMenu', function () {
return
pluginManager
.
destroy
();
});
});
})
;
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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