From d6f121329f9d55cab86b5e3e891cdf5151522659 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Tue, 31 May 2022 17:29:44 +0200 Subject: [PATCH] ubuntu-pro: add stretchy widget to show info about Ubuntu Pro Signed-off-by: Olivier Gayot --- subiquity/ui/views/ubuntu_pro.py | 72 ++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/subiquity/ui/views/ubuntu_pro.py b/subiquity/ui/views/ubuntu_pro.py index fbdcbde2..b5d9d3c6 100644 --- a/subiquity/ui/views/ubuntu_pro.py +++ b/subiquity/ui/views/ubuntu_pro.py @@ -19,6 +19,7 @@ import re from typing import List from urwid import ( + Columns, connect_signal, LineBox, Text, @@ -212,6 +213,77 @@ class UbuntuProView(BaseView): self.show_stretchy_overlay(ShowServicesWidget(self, services)) +class AboutProWidget(Stretchy): + """ Widget showing some information about what Ubuntu Pro offers. + +------------------- About Ubuntu Pro --------------------+ + | | + | Ubuntu Pro subscription gives you access to multiple | + | security & compliance services, including: | + | | + | • Security patching for over 30.000 packages, with a | + | focus on High and Critical CVEs (extended from 2.500) | + | • ... | + | • ... | + | | + | Ubuntu Pro is free for personal use on up to 3 machines.| + | More information on ubuntu.com/pro | + | | + | [ Continue ] | + +---------------------------------------------------------+ + """ + def __init__(self, parent: UbuntuProView) -> None: + """ Initializes the widget.""" + self.parent = parent + + ok = ok_btn(label=_("Continue"), on_press=lambda unused: self.close()) + + title = _("About Ubuntu Pro") + header = _("Ubuntu Pro subscription gives you access to multiple" + " security & compliance services, including:") + + services = [ + _("Security patching for over 30.000 packages, with a focus on" + " High and Critical CVEs (extended from 2.500)"), + _("10 years of security Maintenance (extended from 5 years)"), + _("Kernel Livepatch service for increased uptime and security"), + _("Ubuntu Security Guide for hardening profiles, including CIS" + " and DISA-STIG"), + _("FIPS 140-2 NIST-certified crypto-modules for FedRAMP" + " compliance"), + ] + + def itemize(item: str, marker: str = "•") -> Columns: + """ Return the text specified in a Text widget prepended with a + bullet point / marker. If the text is too long to fit in a single + line, the continuation lines are indented as shown below: + +---------------------------+ + | * This is an example of | + | what such element would | + | look like. | + +---------------------------+ + """ + return Columns( + [(len(marker), Text(marker)), Text(item)], dividechars=1) + + widgets: List[Widget] = [ + Text(header), + Text(""), + Pile([itemize(svc) for svc in services]), + Text(""), + Text(_("Ubuntu Pro is free for personal use on up to 3" + " machines.")), + Text(_("More information on ubuntu.com/pro")), + Text(""), + button_pile([ok]), + ] + + super().__init__(title, widgets, stretchy_index=2, focus_index=7) + + def close(self) -> None: + """ Close the overlay. """ + self.parent.remove_overlay() + + class ShowServicesWidget(Stretchy): """ Widget to show the activable services for UA subscription. +------------------ Activable Services -------------------+