Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/menu/list_manager.py
diff options
context:
space:
mode:
authorWerner Llácer <wllacer@gmail.com>2022-08-01 09:44:26 +0200
committerGitHub <noreply@github.com>2022-08-01 09:44:26 +0200
commit3bc39225458b32fcd43b8a5b76dbb6797723a86c (patch)
tree28d33463384af8298374540c447fc0677d1b4ee9 /archinstall/lib/menu/list_manager.py
parentd2f58362c9035be57670784584a666eea8c09e60 (diff)
Enhacements to list_manager: (#1346)
* Enhacements to list_manager: method filter_option. To filter options based on selected entry attrib. last_choice. Which is the last action executed before exiting the loop * last_choice is now a calculated attribute, therefore readonly * Added last_choice to selection_menu * bug at selection_menu handling. Translations can be a problem
Diffstat (limited to 'archinstall/lib/menu/list_manager.py')
-rw-r--r--archinstall/lib/menu/list_manager.py13
1 files changed, 12 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