drivers: show different words when online vs offline

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2022-03-31 12:28:37 +02:00
parent d6048a6914
commit 6a2e8b6a49
4 changed files with 39 additions and 12 deletions

View File

@ -38,7 +38,8 @@ class DriversController(SubiquityTuiController):
raise Skip raise Skip
response: DriversResponse = await self.endpoint.GET() response: DriversResponse = await self.endpoint.GET()
return DriversView(self, response.drivers, response.install) return DriversView(self, response.drivers,
response.install, response.local_only)
async def _wait_drivers(self) -> List[str]: async def _wait_drivers(self) -> List[str]:
response: DriversResponse = await self.endpoint.GET(wait=True) response: DriversResponse = await self.endpoint.GET(wait=True)

View File

@ -398,9 +398,11 @@ class DriversResponse:
:drivers: tells what third-party drivers will be installed should we decide :drivers: tells what third-party drivers will be installed should we decide
to do it. It will bet set to None until we figure out what drivers are to do it. It will bet set to None until we figure out what drivers are
available. available.
:local_only: tells if we are looking for drivers only from the ISO.
""" """
install: bool install: bool
drivers: Optional[List[str]] drivers: Optional[List[str]]
local_only: bool
@attr.s(auto_attribs=True) @attr.s(auto_attribs=True)

View File

@ -98,10 +98,13 @@ class DriversController(SubiquityController):
await self.configured() await self.configured()
async def GET(self, wait: bool = False) -> DriversResponse: async def GET(self, wait: bool = False) -> DriversResponse:
local_only = not self.app.base_model.network.has_network
if wait: if wait:
await asyncio.shield(self._drivers_task) await asyncio.shield(self._drivers_task)
return DriversResponse(install=self.model.do_install, return DriversResponse(install=self.model.do_install,
drivers=self.drivers) drivers=self.drivers,
local_only=local_only)
async def POST(self, data: DriversPayload) -> None: async def POST(self, data: DriversPayload) -> None:
self.model.do_install = data.install self.model.do_install = data.install

View File

@ -69,12 +69,14 @@ class DriversView(BaseView):
form = None form = None
def __init__(self, controller, drivers: Optional[List[str]], def __init__(self, controller, drivers: Optional[List[str]],
install: bool) -> None: install: bool, local_only: bool) -> None:
self.controller = controller self.controller = controller
self.local_only = local_only
self.search_later = [ self.search_later = [
Text(_("Note: You can search again later for third-party " + Text(_("Note: Once the installation has finished and you are " +
"drivers using the command:")), "connected to a network, you can search again for " +
"third-party drivers using the following command:")),
Text(""), Text(""),
Text(" $ ubuntu-drivers list --recommended --gpgpu"), Text(" $ ubuntu-drivers list --recommended --gpgpu"),
] ]
@ -91,8 +93,17 @@ class DriversView(BaseView):
asynchronously. """ asynchronously. """
self.spinner = Spinner(self.controller.app.aio_loop, style='dots') self.spinner = Spinner(self.controller.app.aio_loop, style='dots')
self.spinner.start() self.spinner.start()
if self.local_only:
looking_for_drivers = _("Not connected to a network. " +
"Looking for applicable third-party " +
"drivers available locally...")
else:
looking_for_drivers = _("Looking for applicable third-party " +
"drivers available locally or online...")
rows = [ rows = [
Text(_("Looking for applicable third-party drivers...")), Text(looking_for_drivers),
Text(""), Text(""),
self.spinner, self.spinner,
] ]
@ -117,10 +128,18 @@ class DriversView(BaseView):
""" Change the view into an information page that shows that no """ Change the view into an information page that shows that no
third-party drivers are available for installation. """ third-party drivers are available for installation. """
rows = [ if self.local_only:
Text(_("No applicable third-party drivers were found.")), no_drivers_found = _("No applicable third-party drivers are " +
Text(""), "available locally.")
] + self.search_later else:
no_drivers_found = _("No applicable third-party drivers are " +
"available locally or online.")
rows = [Text(no_drivers_found)]
if self.local_only:
rows.append(Text(""))
rows.extend(self.search_later)
self.cont_btn = ok_btn( self.cont_btn = ok_btn(
_("Continue"), _("Continue"),
on_press=lambda sender: self.done(False)) on_press=lambda sender: self.done(False))
@ -149,6 +168,8 @@ class DriversView(BaseView):
rows = [Text(f"* {driver}") for driver in drivers] rows = [Text(f"* {driver}") for driver in drivers]
rows.append(Text("")) rows.append(Text(""))
rows.extend(self.form.as_rows()) rows.extend(self.form.as_rows())
if self.local_only:
rows.append(Text("")) rows.append(Text(""))
rows.extend(self.search_later) rows.extend(self.search_later)