mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-22 00:10:25 +01:00
fixes #5853
This commit is contained in:
@@ -90,6 +90,7 @@
|
||||
"socket.io-client": "2.0.1",
|
||||
"socket.io-redis": "5.0.1",
|
||||
"socketio-wildcard": "2.0.0",
|
||||
"spdx-license-list": "^3.0.1",
|
||||
"string": "^3.0.0",
|
||||
"templates.js": "0.3.11",
|
||||
"toobusy-js": "^0.5.1",
|
||||
|
||||
@@ -43,5 +43,9 @@
|
||||
"alert.suggest-error": "<p>NodeBB could not reach the package manager, proceed with installation of latest version?</p><div class=\"alert alert-danger\"><strong>Server returned (%1)</strong>: %2</div>",
|
||||
"alert.package-manager-unreachable": "<p>NodeBB could not reach the package manager, an upgrade is not suggested at this time.</p>",
|
||||
"alert.incompatible": "<p>Your version of NodeBB (v%1) is only cleared to upgrade to v%2 of this plugin. Please update your NodeBB if you wish to install a newer version of this plugin.</p>",
|
||||
"alert.possibly-incompatible": "<div class=\"alert alert-warning\"><p><strong>No Compatibility Information Found</strong></p><p>This plugin did not specify a specific version for installation given your NodeBB version. Full compatibility cannot be guaranteed, and may cause your NodeBB to no longer start properly.</p></div><p>In the event that NodeBB cannot boot properly:</p><pre><code>$ ./nodebb reset plugin=\"%1\"</code></pre><p>Continue installation of latest version of this plugin?</p>"
|
||||
"alert.possibly-incompatible": "<div class=\"alert alert-warning\"><p><strong>No Compatibility Information Found</strong></p><p>This plugin did not specify a specific version for installation given your NodeBB version. Full compatibility cannot be guaranteed, and may cause your NodeBB to no longer start properly.</p></div><p>In the event that NodeBB cannot boot properly:</p><pre><code>$ ./nodebb reset plugin=\"%1\"</code></pre><p>Continue installation of latest version of this plugin?</p>",
|
||||
|
||||
"license.title": "Plugin License Information",
|
||||
"license.intro": "The plugin <strong>%1</strong> is licensed under the %2. Please read and understand the license terms prior to activating this plugin.",
|
||||
"license.cta": "Do you wish to continue with activating this plugin?"
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ 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"]');
|
||||
var pluginData = ajaxify.data.installed[pluginEl.attr('data-plugin-index')];
|
||||
|
||||
function toggleActivate () {
|
||||
socket.emit('admin.plugins.toggleActive', pluginID, function (err, status) {
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
@@ -34,6 +37,9 @@ define('admin/extend/plugins', ['jqueryui', 'translator'], function (jqueryui, t
|
||||
$('#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') + ']]',
|
||||
@@ -48,6 +54,30 @@ define('admin/extend/plugins', ['jqueryui', 'translator'], function (jqueryui, t
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
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 () {
|
||||
|
||||
@@ -44,9 +44,20 @@ function loadPluginInfo(pluginPath, callback) {
|
||||
}
|
||||
var pluginData;
|
||||
var packageData;
|
||||
var licenseData;
|
||||
try {
|
||||
pluginData = JSON.parse(results.plugin);
|
||||
packageData = JSON.parse(results.package);
|
||||
try {
|
||||
licenseData = require('spdx-license-list/licenses/' + packageData.license);
|
||||
pluginData.license = {
|
||||
name: licenseData.name,
|
||||
text: licenseData.licenseText,
|
||||
};
|
||||
} catch (e) {
|
||||
// No license matched
|
||||
pluginData.license = null;
|
||||
}
|
||||
|
||||
pluginData.id = packageData.name;
|
||||
pluginData.name = packageData.name;
|
||||
@@ -55,7 +66,6 @@ function loadPluginInfo(pluginPath, callback) {
|
||||
pluginData.repository = packageData.repository;
|
||||
pluginData.nbbpm = packageData.nbbpm;
|
||||
pluginData.path = pluginPath;
|
||||
pluginData.license = packageData.license;
|
||||
} catch (err) {
|
||||
var pluginDir = path.basename(pluginPath);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!-- IF !installed.error -->
|
||||
<li id="{installed.id}" data-plugin-id="{installed.id}" data-version="{installed.version}" class="clearfix <!-- IF installed.active -->active<!-- ENDIF installed.active -->">
|
||||
<li id="{installed.id}" data-plugin-index="@index" data-plugin-id="{installed.id}" data-version="{installed.version}" class="clearfix <!-- IF installed.active -->active<!-- ENDIF installed.active -->">
|
||||
<div class="pull-right controls">
|
||||
<!-- IF installed.isTheme -->
|
||||
<a href="{config.relative_path}/admin/appearance/themes" class="btn btn-info">[[admin/extend/plugins:plugin-item.themes]]</a>
|
||||
|
||||
5
src/views/admin/partials/plugins/license.tpl
Normal file
5
src/views/admin/partials/plugins/license.tpl
Normal file
@@ -0,0 +1,5 @@
|
||||
[[admin/extend/plugins:license.intro, {name}, {license.name}]]
|
||||
|
||||
<blockquote>{license.text}</blockquote>
|
||||
|
||||
[[admin/extend/plugins:license.cta]]
|
||||
Reference in New Issue
Block a user