ubuntu-pro: add intermediate screen that shows token was added

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2022-06-13 15:17:46 +02:00
parent c8ed8abe55
commit af091b689c
1 changed files with 40 additions and 2 deletions

View File

@ -16,7 +16,7 @@
import logging import logging
import re import re
from typing import List from typing import Callable, List
from urwid import ( from urwid import (
Columns, Columns,
@ -312,9 +312,16 @@ class UbuntuProView(BaseView):
""" Open the loading dialog and asynchronously check if the token is """ Open the loading dialog and asynchronously check if the token is
valid. """ valid. """
def on_success(services: List[UbuntuProService]) -> None: def on_success(services: List[UbuntuProService]) -> None:
def show_services() -> None:
self.remove_overlay() self.remove_overlay()
self.show_activable_services(services) self.show_activable_services(services)
self.remove_overlay()
widget = TokenAddedWidget(
parent=self,
on_continue=show_services)
self.show_stretchy_overlay(widget)
def on_failure(status: UbuntuProCheckTokenStatus) -> None: def on_failure(status: UbuntuProCheckTokenStatus) -> None:
self.remove_overlay() self.remove_overlay()
if status == UbuntuProCheckTokenStatus.INVALID_TOKEN: if status == UbuntuProCheckTokenStatus.INVALID_TOKEN:
@ -387,9 +394,40 @@ class UbuntuProView(BaseView):
""" Display an overlay with the list of services that can be enabled """ Display an overlay with the list of services that can be enabled
via Ubuntu Pro subscription. After the user confirms, we will via Ubuntu Pro subscription. After the user confirms, we will
quit the current view and move on. """ quit the current view and move on. """
# TODO: replace this by a full screen.
# Changing the text in the title bar is what makes it difficult.
self.show_stretchy_overlay(ShowServicesWidget(self, services)) self.show_stretchy_overlay(ShowServicesWidget(self, services))
class TokenAddedWidget(Stretchy):
""" Widget that shows that the supplied token is valid and was "added".
+---------------- Token added successfully ---------------+
| |
| Your token has been added successfully and your |
| subscription configuration will be applied at the first |
| boot. |
| |
| [ Continue ] |
+---------------------------------------------------------+
"""
def __init__(self, parent: UbuntuProView,
on_continue: Callable[[], None]) -> None:
""" Initializes the widget. """
self.parent = parent
cont = done_btn(
label=_("Continue"),
on_press=lambda unused: on_continue())
widgets = [
Text(_("Your token has been added successfully and your"
" subscription configuration will be applied at the first"
" boot.")),
Text(""),
button_pile([cont]),
]
super().__init__("Token added successfully", widgets,
stretchy_index=0, focus_index=2)
class AboutProWidget(Stretchy): class AboutProWidget(Stretchy):
""" Widget showing some information about what Ubuntu Pro offers. """ Widget showing some information about what Ubuntu Pro offers.
+------------------- About Ubuntu Pro --------------------+ +------------------- About Ubuntu Pro --------------------+