From de63e3799a28a51aa132c7c9e1dea44b2dfde800 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 27 Feb 2021 17:29:41 +0300 Subject: only show plugin update buttons when needed --- js/PrefHelpers.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'js/PrefHelpers.js') diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js index 125cc20d0..ff7766d8a 100644 --- a/js/PrefHelpers.js +++ b/js/PrefHelpers.js @@ -295,7 +295,34 @@ const Helpers = { }); } }, - updateLocal: function(name = null) { + checkForUpdate: function(name = null) { + Notify.progress("Checking for plugin updates..."); + + xhr.json("backend.php", {op: "pref-prefs", method: "checkForPluginUpdates", name: name}, (reply) => { + Notify.close(); + + if (reply) { + let plugins_with_updates = 0; + + reply.forEach((p) => { + if (p.rv.o) { + const button = dijit.getEnclosingWidget(App.find(`*[data-update-btn-for-plugin="${p.plugin}"]`)); + + if (button) { + button.domNode.show(); + ++plugins_with_updates; + } + } + }); + + if (plugins_with_updates > 0) + App.find(".update-all-plugins-btn").show(); + } else { + Notify.error("Unable to check for plugin updates."); + } + }); + }, + update: function(name = null) { const msg = name ? __("Update %p using git?").replace("%p", name) : __("Update all local plugins using git?"); -- cgit v1.2.3