luci-mod-network: handle default protocol for UCI interfaces
authorErik Karlsson <erik.karlsson@iopsys.eu>
Wed, 8 Jan 2025 12:00:57 +0000 (13:00 +0100)
committerPaul Donald <newtwen+github@gmail.com>
Wed, 22 Jan 2025 14:49:14 +0000 (15:49 +0100)
The protocol defaults to 'none' in netifd if unspecified.

Some previously unused and some now redundant code is also removed.

Signed-off-by: Erik Karlsson <erik.karlsson@iopsys.eu>
modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js

index 8652e44c58a9fb9206dcbd957d12ddba2846c59f..c7493fadb6d16298ac7f529cf51b5d3cbf2cef05 100644 (file)
@@ -515,13 +515,9 @@ return view.extend({
                };
 
                s.addModalOptions = function(s) {
-                       var protoval = uci.get('network', s.section, 'proto'),
-                           protoclass = protoval ? network.getProtocol(protoval) : null,
+                       var protoval = uci.get('network', s.section, 'proto') || 'none',
                            o, proto_select, proto_switch, type, stp, igmp, ss, so;
 
-                       if (!protoval)
-                               return;
-
                        return network.getNetwork(s.section).then(L.bind(function(ifc) {
                                var protocols = network.getProtocols();
 
@@ -544,6 +540,7 @@ return view.extend({
 
                                proto_select = s.taboption('general', form.ListValue, 'proto', _('Protocol'));
                                proto_select.modalonly = true;
+                               proto_select.default = 'none';
 
                                proto_switch = s.taboption('general', form.Button, '_switch_proto');
                                proto_switch.modalonly  = true;
@@ -612,7 +609,7 @@ return view.extend({
                                for (var i = 0; i < protocols.length; i++) {
                                        proto_select.value(protocols[i].getProtocol(), protocols[i].getI18n());
 
-                                       if (protocols[i].getProtocol() != uci.get('network', s.section, 'proto'))
+                                       if (protocols[i].getProtocol() != protoval)
                                                proto_switch.depends('proto', protocols[i].getProtocol());
                                }