From f9a53090956e7e6094d81cce17d2f232bfd06f80 Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Wed, 29 Oct 2025 21:37:54 +0100 Subject: [PATCH] luci-mod-network: predicate the display of dnsmasq and odhcpd tabs First check the features are installed. Further, verify that some sections exist which some GUI functions depend on. Signed-off-by: Paul Donald --- .../htdocs/luci-static/resources/view/network/dhcp.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js index ccb7624a73..b886c38e2a 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js @@ -207,9 +207,11 @@ return view.extend({ m = new form.Map('dhcp', _('DHCP')); m.tabbed = true; - this.add_dnsmasq_cfg(m, networks); + if (L.hasSystemFeature('dnsmasq')) + this.add_dnsmasq_cfg(m, networks); - this.add_odhcpd_cfg(m); + if (L.hasSystemFeature('odhcpd')) + this.add_odhcpd_cfg(m); this.add_leases_cfg(m, hosts, duids, pools, macdata); @@ -309,11 +311,11 @@ return view.extend({ const sections = this.cfgsections(); return Promise.resolve(renderTask).then(function(nodes) { - if (sections.length < 2) { + if (sections.length == 1) { nodes.querySelector('#cbi-dhcp-dnsmasq > h3').remove(); nodes.querySelector('#cbi-dhcp-dnsmasq > .cbi-section-remove').remove(); } - else { + else if (sections.length > 1) { nodes.querySelectorAll('#cbi-dhcp-dnsmasq > .cbi-section-remove').forEach(function(div, i) { const section = uci.get('dhcp', sections[i]); const hline = div.nextElementSibling; -- 2.30.2