Skip to content

Commit 9a4183b

Browse files
committed
Hide dynamic buttons in tui when in static mode
Add `isDynamic` helper to `NetInterface` Signed-off-by: BenjiReis <benjamin.reis@vates.fr>
1 parent b9c449d commit 9a4183b

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

netinterface.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ def isStatic6(self):
130130
""" Returns true if an IPv6 static interface configuration is represented. """
131131
return self.modev6 == self.Static
132132

133+
def isDynamic(self):
134+
""" Returns true if a dynamic interface configuration is represented. """
135+
return self.mode == self.DHCP or self.modev6 == self.DHCP or self.modev6 == self.Autoconf
136+
133137
def isVlan(self):
134138
return self.vlan is not None
135139

netutil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def writeResolverFile(configuration, filename):
9292

9393
for iface in configuration:
9494
settings = configuration[iface]
95-
if settings.isStatic4() and settings.dns:
95+
if (not settings.isDynamic()) and settings.dns:
9696
if settings.dns:
9797
for server in settings.dns:
9898
outfile.write("nameserver %s\n" % server)

tui/installer/screens.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ def ns_callback((enabled, )):
805805
for entry in [ns1_entry, ns2_entry, ns3_entry]:
806806
entry.setFlags(FLAG_DISABLED, enabled)
807807

808-
hide_rb = answers['net-admin-configuration'].isStatic4()
808+
hide_rb = not answers['net-admin-configuration'].isDynamic()
809809

810810
# HOSTNAME:
811811
hn_title = Textbox(len("Hostname Configuration"), 1, "Hostname Configuration")
@@ -935,7 +935,7 @@ def nsvalue(answers, id):
935935
answers['manual-nameservers'][1].append(ns2_entry.value())
936936
if ns3_entry.value() != '':
937937
answers['manual-nameservers'][1].append(ns3_entry.value())
938-
if 'net-admin-configuration' in answers and answers['net-admin-configuration'].isStatic4():
938+
if 'net-admin-configuration' in answers and not answers['net-admin-configuration'].isDynamic():
939939
answers['net-admin-configuration'].dns = answers['manual-nameservers'][1]
940940
else:
941941
answers['manual-nameservers'] = (False, None)
@@ -1036,7 +1036,7 @@ def dhcp_change():
10361036
for x in [ ntp1_field, ntp2_field, ntp3_field ]:
10371037
x.setFlags(FLAG_DISABLED, not dhcp_cb.value())
10381038

1039-
hide_cb = answers['net-admin-configuration'].isStatic4()
1039+
hide_cb = not answers['net-admin-configuration'].isDynamic()
10401040

10411041
gf = GridFormHelp(tui.screen, 'NTP Configuration', 'ntpconf', 1, 4)
10421042
text = TextboxReflowed(60, "Please specify details of the NTP servers you wish to use (e.g. pool.ntp.org)?")

0 commit comments

Comments
 (0)