/admin/plugins/info: Move logic to `.js` file

pull/4675/head^2
Richard Hansen 2021-02-03 23:05:58 -05:00 committed by John McLear
parent c5f0274116
commit cd1d322af4
2 changed files with 15 additions and 13 deletions

View File

@ -3,14 +3,15 @@
const eejs = require('../../eejs');
const settings = require('../../utils/Settings');
const installer = require('../../../static/js/pluginfw/installer');
const plugins = require('../../../static/js/pluginfw/plugin_defs');
const pluginDefs = require('../../../static/js/pluginfw/plugin_defs');
const plugins = require('../../../static/js/pluginfw/plugins');
const semver = require('semver');
const UpdateCheck = require('../../utils/UpdateCheck');
exports.expressCreateServer = (hookName, args, cb) => {
args.app.get('/admin/plugins', (req, res) => {
res.send(eejs.require('ep_etherpad-lite/templates/admin/plugins.html', {
plugins: plugins.plugins,
plugins: pluginDefs.plugins,
req,
errors: [],
}));
@ -23,6 +24,10 @@ exports.expressCreateServer = (hookName, args, cb) => {
res.send(eejs.require('ep_etherpad-lite/templates/admin/plugins-info.html', {
gitCommit,
epVersion,
installedPlugins: `<pre>${plugins.formatPlugins().replace(/, /g, '\n')}</pre>`,
installedParts: `<pre>${plugins.formatParts()}</pre>`,
installedServerHooks: `<div>${plugins.formatHooks()}</div>`,
installedClientHooks: `<div>${plugins.formatHooks('client_hooks')}</div>`,
latestVersion: UpdateCheck.getLatestVersion(),
req,
}));
@ -40,7 +45,7 @@ exports.socketio = (hookName, args, cb) => {
socket.on('getInstalled', (query) => {
// send currently installed plugins
const installed =
Object.keys(plugins.plugins).map((plugin) => plugins.plugins[plugin].package);
Object.keys(pluginDefs.plugins).map((plugin) => pluginDefs.plugins[plugin].package);
socket.emit('results:installed', {installed});
});
@ -50,11 +55,11 @@ exports.socketio = (hookName, args, cb) => {
try {
const results = await installer.getAvailablePlugins(/* maxCacheAge:*/ 60 * 10);
const updatable = Object.keys(plugins.plugins).filter((plugin) => {
const updatable = Object.keys(pluginDefs.plugins).filter((plugin) => {
if (!results[plugin]) return false;
const latestVersion = results[plugin].version;
const currentVersion = plugins.plugins[plugin].package.version;
const currentVersion = pluginDefs.plugins[plugin].package.version;
return semver.gt(latestVersion, currentVersion);
});
@ -82,7 +87,7 @@ exports.socketio = (hookName, args, cb) => {
const results = await installer.search(query.searchTerm, /* maxCacheAge:*/ 60 * 10);
let res = Object.keys(results)
.map((pluginName) => results[pluginName])
.filter((plugin) => !plugins.plugins[plugin.name]);
.filter((plugin) => !pluginDefs.plugins[plugin.name]);
res = sortPluginList(res, query.sortBy, query.sortDir)
.slice(query.offset, query.offset + query.limit);
socket.emit('results:search', {results: res, query});

View File

@ -1,6 +1,3 @@
<%
var plugins = require("ep_etherpad-lite/static/js/pluginfw/plugins");
%>
<!doctype html>
<html>
<head>
@ -31,17 +28,17 @@
<p>Git sha: <a href='https://github.com/ether/etherpad-lite/commit/<%= gitCommit %>'><%= gitCommit %></a></p>
<h2 data-l10n-id="admin_plugins_info.plugins">Installed plugins</h2>
<pre><%- plugins.formatPlugins().replace(/, /g,"\n") %></pre>
<%- installedPlugins %>
<h2 data-l10n-id="admin_plugins_info.parts">Installed parts</h2>
<pre><%= plugins.formatParts() %></pre>
<%- installedParts %>
<h2 data-l10n-id="admin_plugins_info.hooks">Installed hooks</h2>
<h3 data-l10n-id="admin_plugins_info.hooks_server">Server-side hooks</h3>
<div><%- plugins.formatHooks() %></div>
<%- installedServerHooks %>
<h3 data-l10n-id="admin_plugins_info.hooks_client">Client-side hooks</h3>
<div><%- plugins.formatHooks("client_hooks") %></div>
<%- installedClientHooks %>
</div>
</div>