ubuntu-pro: display warning message on pre-releases
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
parent
d19171c052
commit
20b131ce07
|
@ -42,7 +42,9 @@ class TestUbuntuProController(unittest.IsolatedAsyncioTestCase):
|
|||
with patch.object(ctrler.endpoint, "GET", return_value=rv):
|
||||
await ctrler.make_ui()
|
||||
|
||||
view.assert_called_once_with(ctrler, token="", has_network=False)
|
||||
view.assert_called_once_with(
|
||||
ctrler, token="", has_network=False, pre_release=False
|
||||
)
|
||||
|
||||
@patch("subiquity.client.controllers.ubuntu_pro.UbuntuProView")
|
||||
@patch(
|
||||
|
@ -72,3 +74,7 @@ class TestUbuntuProController(unittest.IsolatedAsyncioTestCase):
|
|||
await ctrler.make_ui()
|
||||
|
||||
view.assert_called_once()
|
||||
|
||||
view.assert_called_once_with(
|
||||
ctrler, token="", has_network=False, pre_release=True
|
||||
)
|
||||
|
|
|
@ -61,16 +61,24 @@ class UbuntuProController(SubiquityTuiController):
|
|||
"""Generate the UI, based on the data provided by the model."""
|
||||
|
||||
dry_run: bool = self.app.opts.dry_run
|
||||
pre_release = False
|
||||
|
||||
lsb = lsb_release(dry_run=dry_run)
|
||||
# TODO remove special handling of 24.04 when it is marked LTS
|
||||
if "LTS" not in lsb["description"] and lsb["release"] != "24.04":
|
||||
await self.endpoint.skip.POST()
|
||||
raise Skip("Not running LTS version")
|
||||
|
||||
if "LTS" not in lsb["description"]:
|
||||
# TODO remove special handling of 24.04 when it is marked LTS
|
||||
if lsb["release"] == "24.04":
|
||||
pre_release = True
|
||||
else:
|
||||
await self.endpoint.skip.POST()
|
||||
raise Skip("Not running LTS version")
|
||||
|
||||
ubuntu_pro_info: UbuntuProResponse = await self.endpoint.GET()
|
||||
return UbuntuProView(
|
||||
self, token=ubuntu_pro_info.token, has_network=ubuntu_pro_info.has_network
|
||||
self,
|
||||
token=ubuntu_pro_info.token,
|
||||
has_network=ubuntu_pro_info.has_network,
|
||||
pre_release=pre_release,
|
||||
)
|
||||
|
||||
async def run_answers(self) -> None:
|
||||
|
|
|
@ -37,7 +37,7 @@ from subiquitycore.ui.form import (
|
|||
from subiquitycore.ui.interactive import StringEditor
|
||||
from subiquitycore.ui.spinner import Spinner
|
||||
from subiquitycore.ui.stretchy import Stretchy
|
||||
from subiquitycore.ui.utils import SomethingFailed, button_pile, screen
|
||||
from subiquitycore.ui.utils import Color, SomethingFailed, button_pile, screen
|
||||
from subiquitycore.view import BaseView
|
||||
|
||||
log = logging.getLogger("subiquity.ui.views.ubuntu_pro")
|
||||
|
@ -270,11 +270,12 @@ class UbuntuProView(BaseView):
|
|||
title = _("Upgrade to Ubuntu Pro")
|
||||
subscription_done_label = _("Continue")
|
||||
|
||||
def __init__(self, controller, token: str, has_network: bool):
|
||||
def __init__(self, controller, token: str, has_network: bool, *, pre_release=False):
|
||||
"""Initialize the view with the default value for the token."""
|
||||
self.controller = controller
|
||||
|
||||
self.has_network = has_network
|
||||
self.pre_release = pre_release
|
||||
|
||||
if self.has_network:
|
||||
self.upgrade_yes_no_form = UpgradeYesNoForm(
|
||||
|
@ -399,7 +400,22 @@ class UbuntuProView(BaseView):
|
|||
rows = [
|
||||
bp,
|
||||
Text(""),
|
||||
] + self.upgrade_yes_no_form.as_rows()
|
||||
]
|
||||
if self.pre_release:
|
||||
rows.extend(
|
||||
[
|
||||
Color.info_error(
|
||||
Text(
|
||||
_(
|
||||
"Please note that this is not an official LTS build."
|
||||
" This screen is only provided for testing."
|
||||
)
|
||||
)
|
||||
),
|
||||
Text(""),
|
||||
]
|
||||
)
|
||||
rows.extend(self.upgrade_yes_no_form.as_rows())
|
||||
return screen(
|
||||
ListBox(rows),
|
||||
self.upgrade_yes_no_form.buttons,
|
||||
|
|
Loading…
Reference in New Issue