mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-20 15:30:39 +01:00
fixes #5853
This commit is contained in:
@@ -21,33 +21,63 @@ define('admin/extend/plugins', ['jqueryui', 'translator'], function (jqueryui, t
|
||||
var pluginEl = $(this).parents('li');
|
||||
pluginID = pluginEl.attr('data-plugin-id');
|
||||
var btn = $('#' + pluginID + ' [data-action="toggleActive"]');
|
||||
socket.emit('admin.plugins.toggleActive', pluginID, function (err, status) {
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
}
|
||||
translator.translate('<i class="fa fa-power-off"></i> [[admin/extend/plugins:plugin-item.' + (status.active ? 'deactivate' : 'activate') + ']]', function (buttonText) {
|
||||
btn.html(buttonText);
|
||||
btn.toggleClass('btn-warning', status.active).toggleClass('btn-success', !status.active);
|
||||
var pluginData = ajaxify.data.installed[pluginEl.attr('data-plugin-index')];
|
||||
|
||||
// clone it to active plugins tab
|
||||
if (status.active && !$('#active #' + pluginID).length) {
|
||||
$('#active ul').prepend(pluginEl.clone(true));
|
||||
function toggleActivate () {
|
||||
socket.emit('admin.plugins.toggleActive', pluginID, function (err, status) {
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
}
|
||||
translator.translate('<i class="fa fa-power-off"></i> [[admin/extend/plugins:plugin-item.' + (status.active ? 'deactivate' : 'activate') + ']]', function (buttonText) {
|
||||
btn.html(buttonText);
|
||||
btn.toggleClass('btn-warning', status.active).toggleClass('btn-success', !status.active);
|
||||
|
||||
app.alert({
|
||||
alert_id: 'plugin_toggled',
|
||||
title: '[[admin/extend/plugins:alert.' + (status.active ? 'enabled' : 'disabled') + ']]',
|
||||
message: '[[admin/extend/plugins:alert.' + (status.active ? 'activate-success' : 'deactivate-success') + ']]',
|
||||
type: status.active ? 'warning' : 'success',
|
||||
timeout: 5000,
|
||||
clickfn: function () {
|
||||
require(['admin/modules/instance'], function (instance) {
|
||||
instance.restart();
|
||||
});
|
||||
// clone it to active plugins tab
|
||||
if (status.active && !$('#active #' + pluginID).length) {
|
||||
$('#active ul').prepend(pluginEl.clone(true));
|
||||
}
|
||||
|
||||
// Toggle active state in template data
|
||||
pluginData.active = !pluginData.active;
|
||||
|
||||
app.alert({
|
||||
alert_id: 'plugin_toggled',
|
||||
title: '[[admin/extend/plugins:alert.' + (status.active ? 'enabled' : 'disabled') + ']]',
|
||||
message: '[[admin/extend/plugins:alert.' + (status.active ? 'activate-success' : 'deactivate-success') + ']]',
|
||||
type: status.active ? 'warning' : 'success',
|
||||
timeout: 5000,
|
||||
clickfn: function () {
|
||||
require(['admin/modules/instance'], function (instance) {
|
||||
instance.restart();
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (pluginData.license && pluginData.active !== true) {
|
||||
templates.parse('admin/partials/plugins/license', pluginData, function (html) {
|
||||
var modal = bootbox.dialog({
|
||||
title: '[[admin/extend/plugins:license.title]]',
|
||||
message: html,
|
||||
size: 'large',
|
||||
buttons: {
|
||||
cancel: {
|
||||
label: '[[modules:bootbox.cancel]]',
|
||||
className: 'btn-link',
|
||||
},
|
||||
save: {
|
||||
label: '[[modules:bootbox.confirm]]',
|
||||
className: 'btn-primary',
|
||||
callback: toggleActivate,
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
toggleActivate(pluginID);
|
||||
}
|
||||
});
|
||||
|
||||
pluginsList.on('click', 'button[data-action="toggleInstall"]', function () {
|
||||
|
||||
Reference in New Issue
Block a user