luci-mod-network: make state of interface more clear
authorFlorian Eckert <[email protected]>
Mon, 6 Oct 2025 11:05:10 +0000 (13:05 +0200)
committerFlorian Eckert <[email protected]>
Fri, 10 Oct 2025 12:08:14 +0000 (14:08 +0200)
In the current source, it is difficult to see when the disable button should
be shown or not. This commit adjusts this and moves the handling to an
if else statement, so that it can be easily seen.

Signed-off-by: Florian Eckert <[email protected]>
modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js

index 696d324da6f427e7de7435a85bd934ceec707859..f7e092e49abe8a5793805ee2d195ba8e07c8662d 100644 (file)
@@ -489,13 +489,11 @@ return view.extend({
                                        'class': 'cbi-button cbi-button-neutral reconnect',
                                        'click': iface_updown.bind(this, true, section_id),
                                        'title': _('Reconnect this interface'),
-                                       'disabled': dynamic ? 'disabled' : null
                                }, _('Restart')),
                                E('button', {
                                        'class': 'cbi-button cbi-button-neutral down',
                                        'click': iface_updown.bind(this, false, section_id),
                                        'title': _('Shutdown this interface'),
-                                       'disabled': (dynamic || disabled) ? 'disabled' : null
                                }, _('Stop')),
                                tdEl.lastChild.firstChild,
                                tdEl.lastChild.lastChild
@@ -503,13 +501,27 @@ return view.extend({
 
                        if (!dynamic && net && !uci.get('network', net.getName())) {
                                tdEl.lastChild.childNodes[0].disabled = true;
+                               tdEl.lastChild.childNodes[1].disabled = true;
                                tdEl.lastChild.childNodes[2].disabled = true;
                                tdEl.lastChild.childNodes[3].disabled = true;
                        }
-
-                       if (dynamic) {
-                               //disable the 'Edit' button on dynamic interfaces
+                       else if(dynamic === true) {
+                               tdEl.lastChild.childNodes[0].disabled = true;
+                               tdEl.lastChild.childNodes[1].disabled = true;
                                tdEl.lastChild.childNodes[2].disabled = true;
+                               tdEl.lastChild.childNodes[3].disabled = true;
+                       }
+                       else if (disabled === true){
+                               tdEl.lastChild.childNodes[0].disabled = false;
+                               tdEl.lastChild.childNodes[1].disabled = true;
+                               tdEl.lastChild.childNodes[2].disabled = false;
+                               tdEl.lastChild.childNodes[3].disabled = false;
+                       }
+                       else {
+                               tdEl.lastChild.childNodes[0].disabled = false;
+                               tdEl.lastChild.childNodes[1].disabled = false;
+                               tdEl.lastChild.childNodes[2].disabled = false;
+                               tdEl.lastChild.childNodes[3].disabled = false;
                        }
 
                        return tdEl;