Skip to content

Commit bd6fc86

Browse files
committed
Move install summary into ConfigurationOutput
The summary helper that renders the install preview's two-column configuration overview lived in GlobalMenu. Move it to ConfigurationOutput.as_summary() so it sits alongside the JSON output methods that share the same role. The preview now syncs menu state to ArchConfig and delegates rendering.
1 parent ce5ca8c commit bd6fc86

2 files changed

Lines changed: 69 additions & 66 deletions

File tree

archinstall/lib/configuration.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from archinstall.lib.crypt import encrypt
1111
from archinstall.lib.menu.helpers import Confirmation, Selection
1212
from archinstall.lib.menu.util import get_password, prompt_dir
13+
from archinstall.lib.models.bootloader import Bootloader
14+
from archinstall.lib.models.network import NetworkConfiguration
1315
from archinstall.lib.output import debug, logger, warn
1416
from archinstall.lib.translationhandler import tr
1517
from archinstall.tui.ui.menu_item import MenuItem, MenuItemGroup
@@ -58,6 +60,70 @@ def write_debug(self) -> None:
5860
debug(' -- Chosen configuration --')
5961
debug(self.user_config_to_json())
6062

63+
def as_summary(self) -> str:
64+
"""
65+
Render a concise two-column summary of the current configuration.
66+
67+
The left column holds section labels, the right column holds values.
68+
Column width adapts to the longest translated label so translations
69+
do not break the alignment. Rows whose underlying config is not set
70+
are skipped.
71+
72+
Returns an empty string if nothing meaningful to show.
73+
"""
74+
rows: list[tuple[str, str]] = []
75+
76+
disk_config = self._config.disk_config
77+
if disk_config and disk_config.device_modifications:
78+
disk_parts: list[str] = []
79+
for mod in disk_config.device_modifications:
80+
path = str(mod.device_path)
81+
root_part = mod.get_root_partition()
82+
flags: list[str] = []
83+
if root_part and root_part.fs_type:
84+
flags.append(root_part.fs_type.value)
85+
if disk_config.disk_encryption:
86+
flags.append(tr('LUKS'))
87+
disk_parts.append(f'{path} ({" + ".join(flags)})' if flags else path)
88+
rows.append((tr('Disks'), ', '.join(disk_parts)))
89+
90+
bl_config = self._config.bootloader_config
91+
if bl_config and bl_config.bootloader != Bootloader.NO_BOOTLOADER:
92+
rows.append((tr('Bootloader'), bl_config.bootloader.value))
93+
94+
kernels = self._config.kernels
95+
if kernels:
96+
rows.append((tr('Kernel'), ', '.join(kernels)))
97+
98+
profile_config = self._config.profile_config
99+
if profile_config and profile_config.profile:
100+
names = profile_config.profile.current_selection_names()
101+
rows.append((tr('Profile'), ', '.join(names) if names else profile_config.profile.name))
102+
if profile_config.greeter:
103+
rows.append((tr('Greeter'), profile_config.greeter.value))
104+
105+
packages = self._config.packages
106+
if packages:
107+
rows.append((tr('Packages'), str(len(packages))))
108+
109+
net_config = self._config.network_config
110+
if isinstance(net_config, NetworkConfiguration):
111+
rows.append((tr('Network'), net_config.type.display_msg()))
112+
113+
locale_config = self._config.locale_config
114+
if locale_config:
115+
rows.append((tr('Locale'), locale_config.sys_lang))
116+
117+
tz = self._config.timezone
118+
if tz:
119+
rows.append((tr('Timezone'), tz))
120+
121+
if not rows:
122+
return ''
123+
124+
label_width = max(len(label) for label, _ in rows) + 2
125+
return '\n'.join(f'{label:<{label_width}}{value}' for label, value in rows)
126+
61127
async def confirm_config(self) -> bool:
62128
header = f'{tr("The specified configuration will be applied")}. '
63129
header += tr('Would you like to continue?') + '\n'

archinstall/lib/global_menu.py

Lines changed: 3 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from archinstall.lib.authentication.authentication_menu import AuthenticationMenu
77
from archinstall.lib.bootloader.bootloader_menu import BootloaderMenu
88
from archinstall.lib.bootloader.utils import validate_bootloader_layout
9-
from archinstall.lib.configuration import save_config
9+
from archinstall.lib.configuration import ConfigurationOutput, save_config
1010
from archinstall.lib.disk.disk_menu import DiskLayoutConfigurationMenu
1111
from archinstall.lib.general.general_menu import select_hostname, select_ntp, select_timezone
1212
from archinstall.lib.general.system_menu import select_kernel, select_swap
@@ -498,70 +498,6 @@ def _validate_bootloader(self) -> str | None:
498498

499499
return None
500500

501-
def _install_summary(self) -> str:
502-
"""
503-
Render a concise two-column summary of the current install configuration.
504-
505-
The left column holds section labels, the right column holds values.
506-
Column width adapts to the longest translated label so translations
507-
do not break the alignment. Rows whose underlying config is not set
508-
are skipped.
509-
510-
Returns an empty string if nothing meaningful to show.
511-
"""
512-
rows: list[tuple[str, str]] = []
513-
514-
disk_config: DiskLayoutConfiguration | None = self._item_group.find_by_key('disk_config').value
515-
if disk_config and disk_config.device_modifications:
516-
disk_parts: list[str] = []
517-
for mod in disk_config.device_modifications:
518-
path = str(mod.device_path)
519-
root_part = mod.get_root_partition()
520-
flags: list[str] = []
521-
if root_part and root_part.fs_type:
522-
flags.append(root_part.fs_type.value)
523-
if disk_config.disk_encryption:
524-
flags.append(tr('LUKS'))
525-
disk_parts.append(f'{path} ({" + ".join(flags)})' if flags else path)
526-
rows.append((tr('Disks'), ', '.join(disk_parts)))
527-
528-
bl_config: BootloaderConfiguration | None = self._item_group.find_by_key('bootloader_config').value
529-
if bl_config and bl_config.bootloader != Bootloader.NO_BOOTLOADER:
530-
rows.append((tr('Bootloader'), bl_config.bootloader.value))
531-
532-
kernels: list[str] | None = self._item_group.find_by_key('kernels').value
533-
if kernels:
534-
rows.append((tr('Kernel'), ', '.join(kernels)))
535-
536-
profile_config: ProfileConfiguration | None = self._item_group.find_by_key('profile_config').value
537-
if profile_config and profile_config.profile:
538-
names = profile_config.profile.current_selection_names()
539-
rows.append((tr('Profile'), ', '.join(names) if names else profile_config.profile.name))
540-
if profile_config.greeter:
541-
rows.append((tr('Greeter'), profile_config.greeter.value))
542-
543-
packages: list[str] | None = self._item_group.find_by_key('packages').value
544-
if packages:
545-
rows.append((tr('Packages'), str(len(packages))))
546-
547-
net_config = self._item_group.find_by_key('network_config').value
548-
if isinstance(net_config, NetworkConfiguration):
549-
rows.append((tr('Network'), net_config.type.display_msg()))
550-
551-
locale_config: LocaleConfiguration | None = self._item_group.find_by_key('locale_config').value
552-
if locale_config:
553-
rows.append((tr('Locale'), locale_config.sys_lang))
554-
555-
tz = self._item_group.find_by_key('timezone').value
556-
if tz:
557-
rows.append((tr('Timezone'), tz))
558-
559-
if not rows:
560-
return ''
561-
562-
label_width = max(len(label) for label, _ in rows) + 2
563-
return '\n'.join(f'{label:<{label_width}}{value}' for label, value in rows)
564-
565501
def _prev_install_invalid_config(self, item: MenuItem) -> str | None:
566502
if missing := self._missing_configs():
567503
text = tr('Missing configurations:\n')
@@ -572,7 +508,8 @@ def _prev_install_invalid_config(self, item: MenuItem) -> str | None:
572508
if error := self._validate_bootloader():
573509
return tr(f'Invalid configuration: {error}')
574510

575-
summary = self._install_summary()
511+
self.sync_all_to_config()
512+
summary = ConfigurationOutput(self._arch_config).as_summary()
576513
if summary:
577514
return f'{tr("Ready to install")}\n\n{summary}'
578515
return tr('Ready to install')

0 commit comments

Comments
 (0)