Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
svartkanin committed Feb 9, 2025
1 parent eaf3738 commit ad942a6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
9 changes: 6 additions & 3 deletions archinstall/lib/global_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,18 @@ def _get_menu_options(self) -> list[MenuItem]:
),
MenuItem(
text=str(_('Save configuration')),
action=lambda x: self._safe_config()
action=lambda x: self._safe_config(),
key='__config__'
),
MenuItem(
text=str(_('Install')),
preview_action=self._prev_install_invalid_config
preview_action=self._prev_install_invalid_config,
key='__config__'
),
MenuItem(
text=str(_('Abort')),
action=lambda x: exit(1)
action=lambda x: exit(1),
key='__config__'
)
]

Expand Down
19 changes: 13 additions & 6 deletions archinstall/lib/menu/abstract_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
_: Callable[[str], DeferredTranslation]


CONFIG_KEY = '__config__'


class AbstractMenu:
def __init__(
self,
Expand Down Expand Up @@ -48,7 +51,7 @@ def __exit__(self, *args: Any, **kwargs: Any) -> None:

def _sync_from_config(self) -> None:
for item in self._menu_item_group.menu_items:
if item.key is not None:
if item.key is not None and item.key != CONFIG_KEY:
config_value = getattr(self._config, item.key)
if config_value is not None:
item.value = config_value
Expand All @@ -59,7 +62,7 @@ def sync_all_to_config(self) -> None:
setattr(self._config, item.key, item.value)

def _sync(self, item: MenuItem) -> None:
if not item.key:
if not item.key or item.key == CONFIG_KEY:
return

config_value = getattr(self._config, item.key)
Expand All @@ -70,11 +73,15 @@ def _sync(self, item: MenuItem) -> None:
setattr(self._config, item.key, item.value)

def set_enabled(self, key: str, enabled: bool) -> None:
if (item := self._menu_item_group.find_by_key(key)) is not None:
item.enabled = enabled
return None
# the __config__ is associated with multiple items
found = False
for item in self._menu_item_group.items:
if item.key == key:
item.enabled = enabled
found = True

raise ValueError(f'No selector found: {key}')
if not found:
raise ValueError(f'No selector found: {key}')

def disable_all(self) -> None:
for item in self._menu_item_group.items:
Expand Down
8 changes: 3 additions & 5 deletions archinstall/scripts/only_hd.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ def ask_user_questions() -> None:
global_menu = GlobalMenu(arch_config_handler.config)
global_menu.disable_all()

global_menu.set_enabled('archinstall-language', True)
global_menu.set_enabled('archinstall_language', True)
global_menu.set_enabled('disk_config', True)
global_menu.set_enabled('_disk_encryption', True)
global_menu.set_enabled('disk_encryption', True)
global_menu.set_enabled('swap', True)
global_menu.set_enabled('save_config', True)
global_menu.set_enabled('install', True)
global_menu.set_enabled('abort', True)
global_menu.set_enabled('__config__', True)

global_menu.run()

Expand Down

0 comments on commit ad942a6

Please sign in to comment.