console_conf/controllers/chooser: show current system actions first

When we know which system is current, show its actions first. Optionally allow
opening the list of other systems.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
This commit is contained in:
Maciej Borzecki 2020-04-01 16:02:03 +02:00
parent 95b65d1caf
commit b0ea2e1be7
1 changed files with 16 additions and 2 deletions

View File

@ -14,7 +14,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
from console_conf.ui.views import ChooserView, ChooserConfirmView
from console_conf.ui.views import (
ChooserView,
ChooserCurrentSystemView,
ChooserConfirmView,
)
from subiquitycore.controller import BaseController
@ -33,13 +37,23 @@ class RecoveryChooserBaseController(BaseController):
class RecoveryChooserController(RecoveryChooserBaseController):
def start_ui(self):
view = ChooserView(self, self.model.systems)
if self.model.current and self.model.current.actions:
# only when we have a current system and it has actions available
more = len(self.model.systems) > 1
view = ChooserCurrentSystemView(self, self.model.current,
has_more=more)
else:
view = ChooserView(self, self.model.systems)
self.ui.set_body(view)
def select(self, system, action):
self.model.select(system, action)
self.app.next_screen()
def more_options(self):
self.ui.set_body(ChooserView(self, self.model.systems))
class RecoveryChooserConfirmController(RecoveryChooserBaseController):
def start_ui(self):