diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 8746aa1e0..7f986858f 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -1174,7 +1174,7 @@ class Pref_Prefs extends Handler_Protected { $root_dir = dirname(dirname(__DIR__)); # we're in classes/pref/ 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 { $rv = self::_get_updated_plugins(); } diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js index efb6a2a89..4fb3cdddf 100644 --- a/js/PrefHelpers.js +++ b/js/PrefHelpers.js @@ -323,39 +323,30 @@ const Helpers = { }); }, 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({ - title: __("Plugin Updater"), - execute: function() { + const dialog = new fox.SingleUseDialog({ + title: __("Plugin Updater"), + need_refresh: false, + onHide: function() { + if (this.need_refresh) { Helpers.Prefs.refresh(); - }, - content: ` - + } + }, + performUpdate: function() { + const container = dialog.domNode.querySelector(".update-results"); - - `, - }); - - const tmph = dojo.connect(dialog, 'onShow', function () { - dojo.disconnect(tmph); + container.innerHTML = `
  • ${__("Loading, please wait...")}
  • `; xhr.json("backend.php", {op: "pref-prefs", method: "updateLocalPlugins", name: name}, (reply) => { - const container = dialog.domNode.querySelector(".update-results"); if (!reply) { - container.innerHTML = __("Operation failed: check event log."); + container.innerHTML = `
  • ${__("Operation failed: check event log.")}
  • `; } else { container.innerHTML = ""; reply.forEach((p) => { + if (p.rv.s == 0) dialog.need_refresh = true; + container.innerHTML += `
  • ${p.plugin}

    @@ -369,11 +360,48 @@ const Helpers = { }); } }); + }, + content: ` + + + `, + }); + + const tmph = dojo.connect(dialog, 'onShow', function () { + dojo.disconnect(tmph); + + xhr.json("backend.php", {op: "pref-prefs", method: "checkForPluginUpdates", name: name}, (reply) => { + const container = dialog.domNode.querySelector(".update-results"); + + if (!reply) { + container.innerHTML = `
  • ${__("Operation failed: check event log.")}
  • `; + } else { + container.innerHTML = ""; + + reply.forEach((p) => { + container.innerHTML += + ` +
  • ${p.plugin}

    + ${p.rv.e ? `
    ${p.rv.e}
    ` : ''} + ${p.rv.o ? `
    ${p.rv.o}
    ` : ''} +

    + ${p.rv.s ? __("Exited with RC: %d").replace("%d", p.rv.s) : __("OK")} +

    +
  • + ` + }); + } }); - dialog.show(); - } + }); + + dialog.show(); }, }, OPML: {