mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-05 05:25:49 +01:00
Exposed package data for incompatible plugins to admin/plugins controller, #3480
ping @psychobunny
This commit is contained in:
@@ -269,17 +269,39 @@ adminController.postCache.get = function(req, res, next) {
|
||||
};
|
||||
|
||||
adminController.plugins.get = function(req, res, next) {
|
||||
plugins.getAll(function(err, plugins) {
|
||||
async.parallel({
|
||||
compatible: function(next) {
|
||||
plugins.list(function(err, plugins) {
|
||||
if (err || !Array.isArray(plugins)) {
|
||||
plugins = [];
|
||||
}
|
||||
|
||||
next(null, plugins);
|
||||
});
|
||||
},
|
||||
all: function(next) {
|
||||
plugins.list(false, function(err, plugins) {
|
||||
if (err || !Array.isArray(plugins)) {
|
||||
plugins = [];
|
||||
}
|
||||
|
||||
next(null, plugins);
|
||||
});
|
||||
}
|
||||
}, function(err, payload) {
|
||||
var compatiblePkgNames = payload.compatible.map(function(pkgData) {
|
||||
return pkgData.name;
|
||||
});
|
||||
|
||||
res.render('admin/extend/plugins' , {
|
||||
installed: plugins.filter(function(plugin) {
|
||||
installed: payload.compatible.filter(function(plugin) {
|
||||
return plugin.installed;
|
||||
}),
|
||||
download: plugins.filter(function(plugin) {
|
||||
download: payload.compatible.filter(function(plugin) {
|
||||
return !plugin.installed;
|
||||
}),
|
||||
incompatible: payload.all.filter(function(plugin) {
|
||||
return compatiblePkgNames.indexOf(plugin.name) === -1;
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
@@ -195,8 +195,13 @@ var fs = require('fs'),
|
||||
});
|
||||
};
|
||||
|
||||
Plugins.getAll = function(callback) {
|
||||
var url = (nconf.get('registry') || 'https://packages.nodebb.org') + '/api/v1/plugins?version=' + require('../package.json').version;
|
||||
Plugins.list = function(matching, callback) {
|
||||
if (arguments.length === 1 && typeof matching === 'function') {
|
||||
callback = matching;
|
||||
matching = true;
|
||||
}
|
||||
|
||||
var url = (nconf.get('registry') || 'https://packages.nodebb.org') + '/api/v1/plugins' + (matching !== false ? '?version=' + require('../package.json').version : '');
|
||||
|
||||
require('request')(url, {
|
||||
json: true
|
||||
|
||||
Reference in New Issue
Block a user