Removed the progress view.
On non systemd systems (ie WSL) the progress view is always empty. Thus this view is removed and the summary (formerly overview) view becomes the last page of the setup with the reboot button. This button is displayed dynamically when setup is complete. Co-authored-by: Didier Roche <didrocks@ubuntu.com>
This commit is contained in:
parent
15664d9016
commit
ab161250e1
|
@ -10,7 +10,5 @@ WSLConfigurationBase:
|
|||
custom_mount_opt: 'opt1 opt2 opt3'
|
||||
gen_host: false
|
||||
gen_resolvconf: false
|
||||
Overview:
|
||||
noproperty: "there is no property for this view, just a done button but subiquity requires something to proceed"
|
||||
InstallProgress:
|
||||
Summary:
|
||||
reboot: yes
|
|
@ -34,8 +34,7 @@ class SystemSetupClient(SubiquityClient):
|
|||
"Welcome",
|
||||
"WSLIdentity",
|
||||
"WSLConfigurationBase",
|
||||
"Overview",
|
||||
"Progress",
|
||||
"Summary",
|
||||
]
|
||||
|
||||
def __init__(self, opts):
|
||||
|
@ -49,9 +48,9 @@ class SystemSetupClient(SubiquityClient):
|
|||
# self.variant = "wsl_configuration"
|
||||
if opts.reconfigure:
|
||||
self.controllers = [
|
||||
"Welcome",
|
||||
"WSLConfigurationBase",
|
||||
"WSLConfigurationAdvanced",
|
||||
"Progress",
|
||||
"Summary",
|
||||
]
|
||||
super().__init__(opts)
|
||||
|
||||
|
|
|
@ -16,18 +16,16 @@
|
|||
|
||||
from .identity import WSLIdentityController
|
||||
from .wslconfbase import WSLConfigurationBaseController
|
||||
from .overview import OverviewController
|
||||
from .summary import SummaryController
|
||||
from .wslconfadvanced import WSLConfigurationAdvancedController
|
||||
|
||||
from subiquity.client.controllers import (ProgressController,
|
||||
WelcomeController)
|
||||
from subiquity.client.controllers import (WelcomeController)
|
||||
|
||||
|
||||
__all__ = [
|
||||
'WelcomeController',
|
||||
'WSLIdentityController',
|
||||
'ProgressController',
|
||||
'WSLConfigurationBaseController',
|
||||
'WSLConfigurationAdvancedController',
|
||||
'OverviewController',
|
||||
'SummaryController',
|
||||
]
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
import logging
|
||||
from subiquity.client.controller import SubiquityTuiController
|
||||
|
||||
from system_setup.ui.views.overview import OverviewView
|
||||
|
||||
log = logging.getLogger('ubuntu_wsl_oobe.controllers.overview')
|
||||
|
||||
|
||||
class OverviewController(SubiquityTuiController):
|
||||
|
||||
async def make_ui(self):
|
||||
real_name = ""
|
||||
identity = getattr(self.app.client, "identity")
|
||||
if identity is not None:
|
||||
data = await identity.GET()
|
||||
real_name = data.realname
|
||||
return OverviewView(self, real_name)
|
||||
|
||||
def cancel(self):
|
||||
self.app.cancel()
|
||||
|
||||
def run_answers(self):
|
||||
self.done(None)
|
||||
|
||||
def done(self, result):
|
||||
log.debug(
|
||||
"OverviewController.done next_screen")
|
||||
self.app.next_screen()
|
|
@ -0,0 +1,98 @@
|
|||
import aiohttp
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
from subiquitycore.context import with_context
|
||||
|
||||
from subiquity.client.controller import SubiquityTuiController
|
||||
from subiquity.common.types import (
|
||||
ApplicationState,
|
||||
ShutdownMode
|
||||
)
|
||||
from subiquity.ui.views.installprogress import (
|
||||
InstallRunning,
|
||||
)
|
||||
|
||||
from system_setup.ui.views.summary import SummaryView
|
||||
|
||||
|
||||
log = logging.getLogger('ubuntu_wsl_oobe.controllers.summary')
|
||||
|
||||
|
||||
class SummaryController(SubiquityTuiController):
|
||||
|
||||
def __init__(self, app):
|
||||
super().__init__(app)
|
||||
self.app_state = None
|
||||
self.crash_report_ref = None
|
||||
self.summary_view = None
|
||||
|
||||
def start(self):
|
||||
self.app.aio_loop.create_task(self._wait_status())
|
||||
|
||||
def cancel(self):
|
||||
self.app.cancel()
|
||||
|
||||
def run_answers(self):
|
||||
pass
|
||||
|
||||
def click_reboot(self):
|
||||
self.app.aio_loop.create_task(self.send_reboot_and_wait())
|
||||
|
||||
async def send_reboot_and_wait(self):
|
||||
try:
|
||||
await self.app.client.shutdown.POST(mode=ShutdownMode.REBOOT)
|
||||
except aiohttp.ClientError:
|
||||
pass
|
||||
self.app.exit()
|
||||
|
||||
@with_context()
|
||||
async def _wait_status(self, context):
|
||||
install_running = None
|
||||
while True:
|
||||
try:
|
||||
app_status = await self.app.client.meta.status.GET(
|
||||
cur=self.app_state)
|
||||
except aiohttp.ClientError:
|
||||
await asyncio.sleep(1)
|
||||
continue
|
||||
self.app_state = app_status.state
|
||||
|
||||
if self.summary_view:
|
||||
self.summary_view.update_for_state(self.app_state)
|
||||
if app_status.error is not None:
|
||||
if self.crash_report_ref is None:
|
||||
self.crash_report_ref = app_status.error
|
||||
if self.summary_view:
|
||||
self.ui.set_body(self.summary_view)
|
||||
self.app.show_error_report(self.crash_report_ref)
|
||||
|
||||
if self.app_state == ApplicationState.NEEDS_CONFIRMATION:
|
||||
if self.showing:
|
||||
self.app.show_confirm_install()
|
||||
|
||||
if self.app_state == ApplicationState.RUNNING:
|
||||
if app_status.confirming_tty != self.app.our_tty:
|
||||
install_running = InstallRunning(
|
||||
self.app, app_status.confirming_tty)
|
||||
self.app.add_global_overlay(install_running)
|
||||
else:
|
||||
if install_running is not None:
|
||||
self.app.remove_global_overlay(install_running)
|
||||
install_running = None
|
||||
|
||||
if self.app_state == ApplicationState.DONE:
|
||||
if self.answers.get('reboot', False):
|
||||
self.click_reboot()
|
||||
|
||||
async def make_ui(self):
|
||||
real_name = ""
|
||||
identity = getattr(self.app.client, "identity")
|
||||
if identity is not None:
|
||||
data = await identity.GET()
|
||||
real_name = data.realname
|
||||
self.summary_view = SummaryView(self, real_name)
|
||||
# We may reach the DONE or ERROR state even before we had a chance
|
||||
# to show the UI.
|
||||
self.summary_view.update_for_state(self.app_state)
|
||||
return self.summary_view
|
|
@ -16,11 +16,11 @@
|
|||
from .identity import WSLIdentityView
|
||||
from .wslconfbase import WSLConfigurationBaseView
|
||||
from .wslconfadvanced import WSLConfigurationAdvancedView
|
||||
from .overview import OverviewView
|
||||
from .summary import SummaryView
|
||||
|
||||
__all__ = [
|
||||
'WSLIdentityView',
|
||||
'WSLConfigurationBaseView',
|
||||
'WSLConfigurationAdvancedView',
|
||||
'OverviewView',
|
||||
'SummaryView',
|
||||
]
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
""" Overview
|
||||
|
||||
Overview provides user with the overview of all the current settings.
|
||||
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from subiquitycore.ui.buttons import done_btn
|
||||
from subiquitycore.ui.utils import button_pile, screen
|
||||
from subiquitycore.view import BaseView
|
||||
|
||||
log = logging.getLogger("ubuntu_wsl_oobe.ui.views.overview")
|
||||
|
||||
|
||||
class OverviewView(BaseView):
|
||||
title = _("Setup Complete")
|
||||
|
||||
def __init__(self, controller, real_name):
|
||||
self.controller = controller
|
||||
complete_text = _("Hi {real_name},\n\n"
|
||||
"You have complete the setup!\n\n"
|
||||
"It is suggested to run the following commands"
|
||||
" to update your Ubuntu to the latest version:"
|
||||
"\n\n\n"
|
||||
" $ sudo apt update\n $ sudo apt upgrade\n\n\n"
|
||||
"All settings will take effect after next "
|
||||
"restart of Ubuntu.").format(real_name=real_name)
|
||||
|
||||
super().__init__(
|
||||
screen(
|
||||
rows=[],
|
||||
buttons=button_pile(
|
||||
[done_btn(_("Done"), on_press=self.confirm), ]),
|
||||
focus_buttons=True,
|
||||
excerpt=complete_text,
|
||||
)
|
||||
)
|
||||
|
||||
def confirm(self, result):
|
||||
self.controller.done(result)
|
|
@ -0,0 +1,90 @@
|
|||
""" Summary
|
||||
|
||||
Summary provides user with the summary of all the current settings.
|
||||
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from subiquitycore.ui.utils import button_pile, screen
|
||||
from subiquitycore.view import BaseView
|
||||
from subiquitycore.ui.form import Toggleable
|
||||
from subiquitycore.ui.buttons import (
|
||||
cancel_btn,
|
||||
ok_btn,
|
||||
)
|
||||
from subiquitycore.ui.width import widget_width
|
||||
from subiquity.common.types import ApplicationState
|
||||
|
||||
|
||||
log = logging.getLogger("ubuntu_wsl_oobe.ui.views.summary")
|
||||
|
||||
|
||||
class SummaryView(BaseView):
|
||||
title = _("Setup Complete")
|
||||
|
||||
def __init__(self, controller, real_name):
|
||||
self.controller = controller
|
||||
complete_text = _("Hi {real_name},\n\n"
|
||||
"You have completed the setup!\n\n"
|
||||
"It is suggested to run the following commands"
|
||||
" to update your Ubuntu to the latest version:"
|
||||
"\n\n\n"
|
||||
" $ sudo apt update\n $ sudo apt upgrade\n\n\n"
|
||||
"All settings will take effect after next "
|
||||
"restart of Ubuntu.").format(real_name=real_name)
|
||||
|
||||
self.reboot_btn = Toggleable(ok_btn(
|
||||
_("Reboot Now"), on_press=self.reboot))
|
||||
self.view_error_btn = cancel_btn(
|
||||
_("View error report"), on_press=self.view_error)
|
||||
|
||||
self.event_buttons = button_pile([])
|
||||
super().__init__(
|
||||
screen(
|
||||
rows=[],
|
||||
buttons=self.event_buttons,
|
||||
focus_buttons=True,
|
||||
excerpt=complete_text,
|
||||
)
|
||||
)
|
||||
|
||||
def update_for_state(self, state):
|
||||
btns = []
|
||||
if state == ApplicationState.DONE:
|
||||
btns = [self.reboot_btn]
|
||||
elif state == ApplicationState.ERROR:
|
||||
self.title = _('An error occurred during installation')
|
||||
self.reboot_btn.base_widget.set_label(_("Reboot Now"))
|
||||
self.reboot_btn.enabled = True
|
||||
btns = [
|
||||
self.view_error_btn,
|
||||
self.reboot_btn,
|
||||
]
|
||||
else:
|
||||
raise Exception(state)
|
||||
if self.controller.showing:
|
||||
self.controller.app.ui.set_header(self.title)
|
||||
self._set_buttons(btns)
|
||||
|
||||
def reboot(self, btn):
|
||||
log.debug('reboot clicked')
|
||||
self.reboot_btn.base_widget.set_label(_("Rebooting..."))
|
||||
self.reboot_btn.enabled = False
|
||||
self.event_buttons.original_widget._select_first_selectable()
|
||||
self.controller.click_reboot()
|
||||
self._set_button_width()
|
||||
|
||||
def view_error(self, btn):
|
||||
self.controller.app.show_error_report(self.controller.crash_report_ref)
|
||||
|
||||
def _set_button_width(self):
|
||||
w = 14
|
||||
for b, o in self.event_buttons.original_widget.contents:
|
||||
w = max(widget_width(b), w)
|
||||
self.event_buttons.width = self.event_buttons.min_width = w
|
||||
|
||||
def _set_buttons(self, buttons):
|
||||
p = self.event_buttons.original_widget
|
||||
p.contents[:] = [(b, p.options('pack')) for b in buttons]
|
||||
self._set_button_width()
|
Loading…
Reference in New Issue