From f199b4f912cb455f2b01c8e22a9afc944fb87dc6 Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Wed, 27 May 2026 13:38:01 +0300 Subject: [PATCH] luci-mod-system: improve handling of absent plugins add cleanup functionality; remove orphaned config for absent plugins render placeholder title when plugin is absent follow-up to 617f364333c10ebe1780556db4a88b3019cffb97 Signed-off-by: Paul Donald --- .../resources/view/system/plugins.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/plugins.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/plugins.js index 424b3d79c4..786b82630c 100644 --- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/plugins.js +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/plugins.js @@ -3,6 +3,7 @@ 'require form'; 'require fs'; 'require uci'; +'require ui'; 'require view'; // const plugins_path = '/usr/share/ucode/luci/plugins'; @@ -72,8 +73,9 @@ return view.extend({ s.sectiontitle = function(section_id) { const plugin = plugins[section_id]; + const section = uci.get(luci_plugins, section_id); - return plugin.title; + return plugin ? plugin.title : _('Missing plugin:') + ' ' + section?.name; }; p_enabled = s.option(form.Flag, 'enabled', _('Enabled')); @@ -136,11 +138,24 @@ return view.extend({ const trEl = this.super('renderRowActions', [ section_id, _('Configure…') ]); - if (!plugin || !plugin.addFormOptions) + if (!plugin || !plugin.addFormOptions) { dom.content(trEl, null); + return E('td', { 'class': 'td middle cbi-section-actions' }, E('div', [ + E('button', { + 'class': 'cbi-button cbi-button-negative remove', + 'title': _('Delete this config'), + 'click': ui.createHandlerFn(this, 'handleRemove', section_id) + }, _('Remove')) + ])); + } return trEl; }; + + s.handleRemove = function(section_id, ev) { + return form.GridSection.prototype.handleRemove.apply(this, [section_id, ev]); + }; + } return m.render();