Skip to content

Commit

Permalink
Hide dynamic buttons in tui when in static mode
Browse files Browse the repository at this point in the history
Add `isDynamic` helper to `NetInterface`

Signed-off-by: BenjiReis <benjamin.reis@vates.fr>
  • Loading branch information
benjamreis committed Jun 5, 2023
1 parent 759b98b commit 8f187a3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions netinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ def isStatic6(self):
""" Returns true if an IPv6 static interface configuration is represented. """
return self.modev6 == self.Static

def isDynamic(self):
""" Returns true if a dynamic interface configuration is represented. """
return self.mode == self.DHCP or self.modev6 == self.DHCP or self.modev6 == self.Autoconf

def isVlan(self):
return self.vlan is not None

Expand Down
2 changes: 1 addition & 1 deletion netutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def writeResolverFile(configuration, filename):

for iface in configuration:
settings = configuration[iface]
if settings.isStatic4() and settings.dns:
if (not settings.isDynamic()) and settings.dns:
if settings.dns:
for server in settings.dns:
outfile.write("nameserver %s\n" % server)
Expand Down
6 changes: 3 additions & 3 deletions tui/installer/screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ def ns_callback((enabled, )):
for entry in [ns1_entry, ns2_entry, ns3_entry]:
entry.setFlags(FLAG_DISABLED, enabled)

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

# HOSTNAME:
hn_title = Textbox(len("Hostname Configuration"), 1, "Hostname Configuration")
Expand Down Expand Up @@ -1025,7 +1025,7 @@ def nsvalue(answers, id):
answers['manual-nameservers'][1].append(ns2_entry.value())
if ns3_entry.value() != '':
answers['manual-nameservers'][1].append(ns3_entry.value())
if 'net-admin-configuration' in answers and answers['net-admin-configuration'].isStatic4():
if 'net-admin-configuration' in answers and not answers['net-admin-configuration'].isDynamic():
answers['net-admin-configuration'].dns = answers['manual-nameservers'][1]
else:
answers['manual-nameservers'] = (False, None)
Expand Down Expand Up @@ -1126,7 +1126,7 @@ def dhcp_change():
for x in [ ntp1_field, ntp2_field, ntp3_field ]:
x.setFlags(FLAG_DISABLED, not dhcp_cb.value())

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

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

0 comments on commit 8f187a3

Please sign in to comment.