Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall')
-rw-r--r--archinstall/lib/menu/list_manager.py13
-rw-r--r--archinstall/lib/menu/selection_menu.py9
2 files changed, 21 insertions, 1 deletions
diff --git a/archinstall/lib/menu/list_manager.py b/archinstall/lib/menu/list_manager.py
index e7a9c2ac..ae3a6eb5 100644
--- a/archinstall/lib/menu/list_manager.py
+++ b/archinstall/lib/menu/list_manager.py
@@ -44,6 +44,12 @@ class ListManager:
self._base_actions = base_actions
self._sub_menu_actions = sub_menu_actions
+ self._last_choice = None
+
+ @property
+ def last_choice(self):
+ return self._last_choice
+
def run(self):
while True:
# this will return a dictionary with the key as the menu entry to be displayed
@@ -73,6 +79,7 @@ class ListManager:
selected_entry = data_formatted[choice.value]
self._run_actions_on_entry(selected_entry)
+ self._last_choice = choice
if choice.value == self._cancel_action:
return self._original_data # return the original list
else:
@@ -97,7 +104,7 @@ class ListManager:
return options, header
def _run_actions_on_entry(self, entry: Any):
- options = self._sub_menu_actions + [self._cancel_action]
+ options = self.filter_options(entry,self._sub_menu_actions) + [self._cancel_action]
display_value = self.selected_action_display(entry)
prompt = _("Select an action for '{}'").format(display_value)
@@ -129,3 +136,7 @@ class ListManager:
# this function is called when a base action or
# a specific action for an entry is triggered
raise NotImplementedError('Please implement me in the child class')
+
+ def filter_options(self, selection :Any, options :List[str]) -> List[str]:
+ # filter which actions to show for an specific selection
+ return options
diff --git a/archinstall/lib/menu/selection_menu.py b/archinstall/lib/menu/selection_menu.py
index 8dd6fcce..c6ac5852 100644
--- a/archinstall/lib/menu/selection_menu.py
+++ b/archinstall/lib/menu/selection_menu.py
@@ -188,6 +188,11 @@ class GeneralMenu:
self._menu_options: Dict[str, Selector] = {}
self._setup_selection_menu_options()
self.preview_size = preview_size
+ self._last_choice = None
+
+ @property
+ def last_choice(self):
+ return self._last_choice
def __enter__(self, *args :Any, **kwargs :Any) -> GeneralMenu:
self.is_context_mgr = True
@@ -325,6 +330,10 @@ class GeneralMenu:
if not self._process_selection(value):
break
+ # we get the last action key
+ actions = {str(v.description):k for k,v in self._menu_options.items()}
+ self._last_choice = actions[selection.value.strip()]
+
if not self.is_context_mgr:
self.__exit__()