Fix a myriad of problems with the ACP/Plugins page

- Fixed #3350
- Fixed issue where the normalised API return would have the wrong id for all plugins
- Fixed issue where uninstalling a locally installed plugin via ACP would cause NodeBB to crash
- Simplified ACP/Plugins client-side code to simply refresh the page after installing or uninstalling a plugin.
v1.18.x
Julian Lam 10 years ago
parent f53fb19468
commit e60194292f

@ -186,22 +186,7 @@ define('admin/extend/plugins', function() {
return app.alertError(err.message);
}
var targetList = (pluginData.installed ? 'installed' : 'download'),
otherList = (pluginData.installed ? 'download' : 'installed'),
payload = {};
payload[targetList] = pluginData;
templates.parse('admin/partials/' + targetList + '_plugin_item', payload, function(html) {
var pluginList = $('ul.' + targetList);
pluginList.append(html);
$('ul.' + otherList).find('li[data-plugin-id="' + pluginID + '"]').slideUp('slow', function() {
$(this).remove();
$('html,body').animate({
scrollTop: pluginList.find('li').last().offset().top - 48
}, 1000);
});
});
ajaxify.refresh();
app.alert({
alert_id: 'plugin_toggled',

@ -170,9 +170,13 @@ var fs = require('fs'),
require('request')(url, {
json: true
}, function(err, res, body) {
if (res.statusCode === 404 || !body.payload) {
return callback(err, {});
}
Plugins.normalise([body.payload], function(err, normalised) {
normalised = normalised.filter(function(plugin) {
return plugin.id = id;
return plugin.id === id;
});
return callback(err, !err ? normalised[0] : undefined);
});

Loading…
Cancel
Save