diff options
author | Andrew Dolgov <[email protected]> | 2021-03-04 19:50:19 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-03-04 19:50:19 +0300 |
commit | 476965b1611c45dac1e250365cbbfd03df78926f (patch) | |
tree | ed4ba1f28da5e00cd8ed69f25133a8e903d80c2e /js | |
parent | f398fea414cc3a2598a0486aa7997f6655d02c0a (diff) |
show installed plugins in the installer list
Diffstat (limited to 'js')
-rw-r--r-- | js/PrefHelpers.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js index 6012d2d02..5ee84f258 100644 --- a/js/PrefHelpers.js +++ b/js/PrefHelpers.js @@ -374,6 +374,7 @@ const Helpers = { need_refresh: false, entries: false, search_query: "", + installed_plugins: [], onHide: function() { if (this.need_refresh) { Helpers.Prefs.refresh(); @@ -449,6 +450,9 @@ const Helpers = { .filter((stoken) => (stoken.length > 0 ? stoken : null)); dialog.entries.forEach((plugin) => { + const is_installed = (dialog.installed_plugins + .filter((p) => plugin.topics.map((t) => t.replace(/-/, "_")).includes(p))).length > 0; + if (search_tokens.length == 0 || Object.values(plugin).filter((pval) => search_tokens.filter((stoken) => @@ -458,8 +462,9 @@ const Helpers = { ++results_rendered; container.innerHTML += ` - <li data-row-value="${App.escapeHtml(plugin.name)}"> - ${App.FormFields.button_tag(__('Install'), "", {class: 'alt-primary pull-right', + <li data-row-value="${App.escapeHtml(plugin.name)}" class="${is_installed ? "plugin-installed" : ""}"> + ${App.FormFields.button_tag(is_installed ? __("Already installed") : __('Install'), "", {class: 'alt-primary pull-right', + disabled: is_installed, onclick: `App.dialogOf(this).performInstall("${App.escapeHtml(plugin.name)}")`})} <h3 style="margin-top: 0">${plugin.name} @@ -487,9 +492,7 @@ const Helpers = { const container = dialog.domNode.querySelector(".contents"); container.innerHTML = `<li class='text-center'>${__("Looking for plugins...")}</li>`; - const installed = [...document.querySelectorAll('*[data-plugin-name]')].map((p) => p.getAttribute('data-plugin-name')); - - xhr.json("backend.php", {op: "pref-prefs", method: "getAvailablePlugins", 'installed[]': installed}, (reply) => { + xhr.json("backend.php", {op: "pref-prefs", method: "getAvailablePlugins"}, (reply) => { dialog.entries = reply; dialog.render_contents(); }); @@ -502,7 +505,7 @@ const Helpers = { <div style='height : 16px'> </div> <!-- disgusting --> </div> - <ul style='clear : both' class="panel panel-scrollable-400px contents"> </ul> + <ul style='clear : both' class="panel panel-scrollable-400px contents plugin-installer-list"> </ul> <footer> ${App.FormFields.button_tag(__("Refresh"), "", {class: 'alt-primary', onclick: 'App.dialogOf(this).reload()'})} @@ -513,6 +516,9 @@ const Helpers = { const tmph = dojo.connect(dialog, 'onShow', function () { dojo.disconnect(tmph); + + dialog.installed_plugins = [...document.querySelectorAll('*[data-plugin-name]')].map((p) => p.getAttribute('data-plugin-name')); + dialog.reload(); }); |