plugin updater: show changes before updating
This commit is contained in:
parent
7f2fe465b0
commit
e2cbb54b2c
|
@ -1174,7 +1174,7 @@ class Pref_Prefs extends Handler_Protected {
|
||||||
$root_dir = dirname(dirname(__DIR__)); # we're in classes/pref/
|
$root_dir = dirname(dirname(__DIR__)); # we're in classes/pref/
|
||||||
|
|
||||||
if (!empty($plugin_name)) {
|
if (!empty($plugin_name)) {
|
||||||
$rv = ["plugin" => $plugin_name, "rv" => self::_plugin_needs_update($root_dir, $plugin_name)];
|
$rv = [["plugin" => $plugin_name, "rv" => self::_plugin_needs_update($root_dir, $plugin_name)]];
|
||||||
} else {
|
} else {
|
||||||
$rv = self::_get_updated_plugins();
|
$rv = self::_get_updated_plugins();
|
||||||
}
|
}
|
||||||
|
|
|
@ -323,23 +323,52 @@ const Helpers = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
update: function(name = null) {
|
update: function(name = null) {
|
||||||
const msg = name ? __("Update %p using git?").replace("%p", name) :
|
|
||||||
__("Update all local plugins using git?");
|
|
||||||
|
|
||||||
if (confirm(msg)) {
|
|
||||||
|
|
||||||
const dialog = new fox.SingleUseDialog({
|
const dialog = new fox.SingleUseDialog({
|
||||||
title: __("Plugin Updater"),
|
title: __("Plugin Updater"),
|
||||||
execute: function() {
|
need_refresh: false,
|
||||||
|
onHide: function() {
|
||||||
|
if (this.need_refresh) {
|
||||||
Helpers.Prefs.refresh();
|
Helpers.Prefs.refresh();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
performUpdate: function() {
|
||||||
|
const container = dialog.domNode.querySelector(".update-results");
|
||||||
|
|
||||||
|
container.innerHTML = `<li>${__("Loading, please wait...")}</li>`;
|
||||||
|
|
||||||
|
xhr.json("backend.php", {op: "pref-prefs", method: "updateLocalPlugins", name: name}, (reply) => {
|
||||||
|
|
||||||
|
if (!reply) {
|
||||||
|
container.innerHTML = `<li>${__("Operation failed: check event log.")}</li>`;
|
||||||
|
} else {
|
||||||
|
container.innerHTML = "";
|
||||||
|
|
||||||
|
reply.forEach((p) => {
|
||||||
|
if (p.rv.s == 0) dialog.need_refresh = true;
|
||||||
|
|
||||||
|
container.innerHTML +=
|
||||||
|
`
|
||||||
|
<li><h3 style="margin-top: 0">${p.plugin}</h3>
|
||||||
|
${p.rv.e ? `<pre class="small text-error">${p.rv.e}</pre>` : ''}
|
||||||
|
${p.rv.o ? `<pre class="small text-success">${p.rv.o}</pre>` : ''}
|
||||||
|
<p class="small">
|
||||||
|
${p.rv.s ? __("Exited with RC: %d").replace("%d", p.rv.s) : __("OK")}
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
content: `
|
content: `
|
||||||
<ul class="panel panel-scrollable update-results">
|
<ul class="panel panel-scrollable update-results">
|
||||||
<li>${__("Loading, please wait...")}</li>
|
<li>${__("Loading, please wait...")}</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<footer class="text-center">
|
<footer>
|
||||||
${App.FormFields.submit_tag(__("Reload preferences"))}
|
${App.FormFields.button_tag(__("Update"), "", {class: "alt-primary", onclick: "App.dialogOf(this).performUpdate()"})}
|
||||||
|
${App.FormFields.cancel_dialog_tag(__("Close"))}
|
||||||
</footer>
|
</footer>
|
||||||
`,
|
`,
|
||||||
});
|
});
|
||||||
|
@ -347,11 +376,11 @@ const Helpers = {
|
||||||
const tmph = dojo.connect(dialog, 'onShow', function () {
|
const tmph = dojo.connect(dialog, 'onShow', function () {
|
||||||
dojo.disconnect(tmph);
|
dojo.disconnect(tmph);
|
||||||
|
|
||||||
xhr.json("backend.php", {op: "pref-prefs", method: "updateLocalPlugins", name: name}, (reply) => {
|
xhr.json("backend.php", {op: "pref-prefs", method: "checkForPluginUpdates", name: name}, (reply) => {
|
||||||
const container = dialog.domNode.querySelector(".update-results");
|
const container = dialog.domNode.querySelector(".update-results");
|
||||||
|
|
||||||
if (!reply) {
|
if (!reply) {
|
||||||
container.innerHTML = __("Operation failed: check event log.");
|
container.innerHTML = `<li>${__("Operation failed: check event log.")}</li>`;
|
||||||
} else {
|
} else {
|
||||||
container.innerHTML = "";
|
container.innerHTML = "";
|
||||||
|
|
||||||
|
@ -373,7 +402,6 @@ const Helpers = {
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
OPML: {
|
OPML: {
|
||||||
|
|
Loading…
Reference in New Issue