Skip to content

Commit b58c15f

Browse files
Moved Function and Changed Symbol
1 parent be1228a commit b58c15f

2 files changed

Lines changed: 26 additions & 26 deletions

File tree

archinstall/lib/global_menu.py

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from archinstall.lib.pacman.pacman_menu import PacmanMenu
3636
from archinstall.lib.translationhandler import Language, tr, translation_handler
3737
from archinstall.lib.utils.format import as_table
38-
from archinstall.tui.components import tui
38+
from archinstall.tui.components import get_status_prefix, tui
3939
from archinstall.tui.menu_item import MenuItem, MenuItemGroup, MsgLevelType, PreviewResult
4040

4141

@@ -64,30 +64,6 @@ def __init__(
6464
super().__init__(self._item_group, config=arch_config, title=title)
6565
self._update_item_labels()
6666

67-
def _get_status_prefix(self, item: MenuItem) -> str:
68-
"""
69-
Returns a rich-formatted status prefix icon depending on item state:
70-
- [✓] (Green) for configured items
71-
- [!] (Red) for missing mandatory or required items
72-
- [•] (Yellow) for unconfigured optional items
73-
"""
74-
if item.read_only or item.key in (SpecialMenuKey.SAVE.value, SpecialMenuKey.INSTALL.value, SpecialMenuKey.ABORT.value):
75-
return ''
76-
77-
if item.key == 'auth_config':
78-
auth_config: AuthenticationConfiguration | None = item.value
79-
is_auth_valid = auth_config is not None and (auth_config.root_enc_password is not None or auth_config.has_superuser())
80-
if is_auth_valid:
81-
return '[bold green][✓][/bold green] '
82-
return '[bold red][!][/bold red] '
83-
84-
if item.has_value():
85-
return '[bold green][✓][/bold green] '
86-
elif item.mandatory:
87-
return '[bold red][!][/bold red] '
88-
else:
89-
return '[bold yellow][•][/bold yellow] '
90-
9167
def _update_item_labels(self) -> None:
9268
"""
9369
Re-applies translated titles and status prefixes to all active menu items.
@@ -98,7 +74,7 @@ def _update_item_labels(self) -> None:
9874
for item in self._item_group.items:
9975
if item.key in new_options:
10076
base_title = new_options[item.key]
101-
prefix = self._get_status_prefix(item)
77+
prefix = get_status_prefix(item)
10278
item.text = f'{prefix}{base_title}'
10379

10480
def _wrap_action(self, item: MenuItem, action: Callable[..., Any]) -> Callable[..., Any]:

archinstall/tui/components.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
from textual.worker import WorkerCancelled
2121

2222
from archinstall.lib.log import debug
23+
from archinstall.lib.menu.abstract_menu import SpecialMenuKey
24+
from archinstall.lib.models.authentication import AuthenticationConfiguration
2325
from archinstall.lib.translationhandler import tr
2426
from archinstall.tui.menu_item import MenuItem, MenuItemGroup, MsgLevelType, PreviewResult
2527
from archinstall.tui.result import Result, ResultType
@@ -55,6 +57,28 @@ def _translate_bindings(source: BindingsMap | None, target: BindingsMap) -> None
5557
target.key_to_bindings[key] = [replace(b, description=tr(b.description)) if b.description else b for b in bindings]
5658

5759

60+
def get_status_prefix(item: MenuItem) -> str:
61+
"""
62+
Returns a rich-formatted status prefix icon depending on item state:
63+
- Space for configured items
64+
- ! (Yellow) for unconfigured items
65+
"""
66+
if item.read_only or item.key in (SpecialMenuKey.SAVE.value, SpecialMenuKey.INSTALL.value, SpecialMenuKey.ABORT.value):
67+
return ''
68+
69+
if item.key == 'auth_config':
70+
auth_config: AuthenticationConfiguration | None = item.value
71+
is_auth_valid = auth_config is not None and (auth_config.root_enc_password is not None or auth_config.has_superuser())
72+
if is_auth_valid:
73+
return ' '
74+
return '[bold yellow][!][/bold yellow] '
75+
76+
if item.has_value():
77+
return ' '
78+
else:
79+
return '[bold yellow]![/bold yellow] '
80+
81+
5882
class BaseScreen(Screen[Result[ValueT]]):
5983
BINDINGS: ClassVar = [
6084
Binding('escape', 'cancel_operation', 'Cancel', show=True),

0 commit comments

Comments
 (0)