diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js index 4fb3cdddf..5450bd98c 100644 --- a/js/PrefHelpers.js +++ b/js/PrefHelpers.js @@ -335,17 +335,21 @@ const Helpers = { performUpdate: function() { const container = dialog.domNode.querySelector(".update-results"); - container.innerHTML = `
  • ${__("Loading, please wait...")}
  • `; + container.innerHTML = `
  • ${__("Updating, please wait...")}
  • `; + let enable_update_btn = false; xhr.json("backend.php", {op: "pref-prefs", method: "updateLocalPlugins", name: name}, (reply) => { 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; + if (p.rv.s == 0) + dialog.need_refresh = true; + else + enable_update_btn = true; container.innerHTML += ` @@ -353,21 +357,24 @@ const Helpers = { ${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")} -

    + ${p.rv.s ? App.FormFields.icon("error_outline") + " " + __("Exited with RC: %d").replace("%d", p.rv.s) : + App.FormFields.icon("check") + " " + __("Update done.")} +

    ` }); } + + dijit.getEnclosingWidget(dialog.domNode.querySelector(".update-btn")).attr('disabled', !enable_update_btn); }); }, content: ` `, @@ -378,25 +385,33 @@ const Helpers = { xhr.json("backend.php", {op: "pref-prefs", method: "checkForPluginUpdates", name: name}, (reply) => { const container = dialog.domNode.querySelector(".update-results"); + let enable_update_btn = false; 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) + enable_update_btn = true; + 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")} + ${p.rv.s ? App.FormFields.icon("error_outline") + " " + __("Exited with RC: %d").replace("%d", p.rv.s) : + App.FormFields.icon("check") + " " + __("Ready to update")}

  • ` }); } + + dijit.getEnclosingWidget(dialog.domNode.querySelector(".update-btn")).attr('disabled', !enable_update_btn); + }); });