console_conf/ui/views: simplify sorting actions, tweaks

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
This commit is contained in:
Maciej Borzecki 2020-04-08 12:56:18 +02:00
parent 8ebc8e0580
commit 9293d85638
2 changed files with 6 additions and 8 deletions

View File

@ -51,19 +51,17 @@ class ChooserBaseView(BaseView):
title = "Ubuntu Core"
def __init__(self, current, scr):
super().__init__(scr)
if current is not None:
self.title = current.model.display_name
super().__init__(scr)
def by_preferred_action_type(action):
"""Order action entries by having the 'run' mode first, then 'recover', then
'install', the rest is ordered alphabetically."""
return (action.mode != "run",
action.mode != "recover",
action.mode != "install",
action.title.lower())
priority = {"run": 0, "recover": 1, "install": 2}
return (priority.get(action.mode, 100), action.title.lower())
class ChooserCurrentSystemView(ChooserBaseView):

View File

@ -56,8 +56,8 @@ class ChooserWelcomeView(WelcomeView):
)
def __init__(self, controller):
super().__init__(controller)
current = controller.model.current
if current is not None:
self.title = current.model.display_name
super().__init__(controller)