diff --git a/src/node/hooks/express/adminplugins.js b/src/node/hooks/express/adminplugins.js
index 543f04c0f..4dad3730d 100644
--- a/src/node/hooks/express/adminplugins.js
+++ b/src/node/hooks/express/adminplugins.js
@@ -62,7 +62,7 @@ exports.socketio = (hookName, args, cb) => {
const currentVersion = pluginDefs.plugins[plugin].package.version;
return semver.gt(latestVersion, currentVersion);
- });
+ }).map((plugin) => ({name: plugin, version: results[plugin].version}));
socket.emit('results:updatable', {updatable});
} catch (err) {
@@ -98,8 +98,8 @@ exports.socketio = (hookName, args, cb) => {
}
});
- socket.on('install', (pluginName) => {
- installer.install(pluginName, (err) => {
+ socket.on('install', (pluginName, version) => {
+ installer.install(pluginName, version, (err) => {
if (err) console.warn(err.stack || err.toString());
socket.emit('finished:install', {
diff --git a/src/static/js/admin/plugins.js b/src/static/js/admin/plugins.js
index e51e1102d..ce9db7be1 100644
--- a/src/static/js/admin/plugins.js
+++ b/src/static/js/admin/plugins.js
@@ -123,13 +123,17 @@ $(document).ready(() => {
$('.do-install, .do-update').off('click').on('click', function (e) {
const $row = $(e.target).closest('tr');
const plugin = $row.data('plugin');
+ const update = $row.find('input.do-update');
+ // TODO dont store it here in DOM
+ // version after update or after installing a new package
+ const version = update.length !== 0 ? update.attr('version') : $row.find('.version').text();
if ($(this).hasClass('do-install')) {
$row.remove().appendTo('#installed-plugins');
installed.progress.show(plugin, 'Installing');
} else {
installed.progress.show(plugin, 'Updating');
}
- socket.emit('install', plugin);
+ socket.emit('install', plugin, version);
installed.messages.hide('nothing-installed');
});
@@ -217,11 +221,13 @@ $(document).ready(() => {
});
socket.on('results:updatable', (data) => {
- data.updatable.forEach((pluginName) => {
- const actions = $(`#installed-plugins > tr.${pluginName} .actions`);
+ data.updatable.forEach((plugin) => {
+ const {name, version} = plugin;
+ const actions = $(`#installed-plugins > tr.${name} .actions`);
actions.find('.do-update').remove();
+ // TODO dont store version here in DOM
actions.append(
- $('').addClass('do-update').attr('type', 'button').attr('value', 'Update'));
+ $('').addClass('do-update').attr('type', 'button').attr('version', version).attr('value', 'Update'));
});
updateHandlers();
});
diff --git a/src/static/js/pluginfw/installer.js b/src/static/js/pluginfw/installer.js
index 7410c9037..57739758a 100644
--- a/src/static/js/pluginfw/installer.js
+++ b/src/static/js/pluginfw/installer.js
@@ -43,17 +43,17 @@ exports.uninstall = async (pluginName, cb = null) => {
cb(null);
};
-exports.install = async (pluginName, cb = null) => {
+exports.install = async (pluginName, version, cb = null) => {
cb = wrapTaskCb(cb);
- logger.info(`Installing plugin ${pluginName}...`);
+ logger.info(`Installing plugin ${pluginName}@${version}...`);
try {
- await runCmd(['npm', 'install', pluginName]);
+ await runCmd(['npm', 'install', `${pluginName}@${version}`]);
} catch (err) {
- logger.error(`Failed to install plugin ${pluginName}`);
+ logger.error(`Failed to install plugin ${pluginName}@${version}`);
cb(err || new Error(err));
throw err;
}
- logger.info(`Successfully installed plugin ${pluginName}`);
+ logger.info(`Successfully installed plugin ${pluginName}@${version}`);
await hooks.aCallAll('pluginInstall', {pluginName});
await plugins.update();
cb(null);