drivers: show the drivers screen only if search drivers was checked

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2022-03-16 16:19:31 +01:00
parent c76a8f23e3
commit 1ffff94eff
3 changed files with 16 additions and 2 deletions

View File

@ -31,9 +31,13 @@ class DriversController(SubiquityTuiController):
endpoint_name = 'drivers' endpoint_name = 'drivers'
async def make_ui(self) -> DriversView: async def make_ui(self) -> DriversView:
response: DriversResponse = await self.endpoint.GET() source_endpoint = self.app.client.source
if not response.drivers and response.drivers is not None: source_response = await source_endpoint.GET()
if not source_response.search_drivers:
raise Skip raise Skip
response: DriversResponse = await self.endpoint.GET()
return DriversView(self, response.drivers, response.install) return DriversView(self, response.drivers, response.install)
async def _wait_drivers(self) -> List[str]: async def _wait_drivers(self) -> List[str]:

View File

@ -74,6 +74,14 @@ class DriversController(SubiquityController):
async def _list_drivers(self, context): async def _list_drivers(self, context):
with context.child("wait_apt"): with context.child("wait_apt"):
await self._wait_apt.wait() await self._wait_apt.wait()
# The APT_CONFIGURED event (which unblocks _wait_apt.wait) is sent
# after the user confirms the destruction changes. At this point, the
# source is already mounted so the user can't go back all the way to
# the source screen to enable/disable the "search drivers" checkbox.
if not self.app.controllers.Source.model.search_drivers:
self.drivers = []
await self.configured()
return
apt = self.app.controllers.Mirror.apt_configurer apt = self.app.controllers.Mirror.apt_configurer
async with apt.overlay() as d: async with apt.overlay() as d:
try: try:

View File

@ -66,6 +66,8 @@ class DriversView(BaseView):
if drivers is None: if drivers is None:
self.make_waiting(install) self.make_waiting(install)
elif not drivers:
self.make_no_drivers()
else: else:
self.make_main(install, drivers) self.make_main(install, drivers)