luci-mod-system: improve handling of absent plugins
authorPaul Donald <redacted>
Wed, 27 May 2026 10:38:01 +0000 (13:38 +0300)
committerPaul Donald <redacted>
Wed, 27 May 2026 10:41:14 +0000 (13:41 +0300)
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 <redacted>
modules/luci-mod-system/htdocs/luci-static/resources/view/system/plugins.js

index 424b3d79c425947ff4e406dbb8897fc7912d03ab..786b82630c01299af26c2dd33f7db65fe69bc3ff 100644 (file)
@@ -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();
git clone https://git.99rst.org/PROJECT