Skip to content

Commit

Permalink
Fix profile view
Browse files Browse the repository at this point in the history
  • Loading branch information
svartkanin committed Oct 1, 2024
1 parent 34635c9 commit ec5a915
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 20 deletions.
3 changes: 2 additions & 1 deletion archinstall/default_profiles/desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@ def do_on_select(self) -> Optional[SelectResult]:

result = SelectMenu(
group,
multi=True,
allow_reset=True,
allow_skip=True,
preview_style=PreviewStyle.RIGHT,
preview_size='auto',
preview_frame=FrameProperties.max('Info')
).multi()
).run()

match result.type_:
case ResultType.Selection:
Expand Down
25 changes: 10 additions & 15 deletions archinstall/default_profiles/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from enum import Enum, auto
from typing import List, Optional, Any, Dict, TYPE_CHECKING

from ..lib.utils.util import format_cols
from ..lib.storage import storage

if TYPE_CHECKING:
Expand Down Expand Up @@ -187,24 +186,20 @@ def preview_text(self) -> Optional[str]:
"""
return self.packages_text()

def packages_text(self, include_sub_packages: bool = False) -> Optional[str]:
header = str(_('Installed packages'))

text = ''
packages = []
def packages_text(self, include_sub_packages: bool = False) -> str:
packages = set()

if self.packages:
packages = self.packages
packages = set(self.packages)

if include_sub_packages:
for p in self.current_selection:
if p.packages:
packages += p.packages
for sub_profile in self.current_selection:
if sub_profile.packages:
packages.update(sub_profile.packages)

text += format_cols(sorted(set(packages)))
text = str(_('Installed packages')) + ':\n'

if text:
text = f'{header}: \n{text}'
return text
for pkg in sorted(packages):
text += f'\t- {pkg}\n'

return None
return text
8 changes: 5 additions & 3 deletions archinstall/lib/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from .general import SysCommand
from .networking import list_interfaces, enrich_iface_types
from .output import debug
from .utils.util import format_cols

if TYPE_CHECKING:
_: Any
Expand Down Expand Up @@ -78,9 +77,12 @@ def is_nvidia(self) -> bool:
return False

def packages_text(self) -> str:
text = str(_('Installed packages')) + ':\n'
pkg_names = [p.value for p in self.gfx_packages()]
text += format_cols(sorted(pkg_names))
text = str(_('Installed packages')) + ':\n'

for p in sorted(pkg_names):
text += f'\t- {p}\n'

return text

def gfx_packages(self) -> List[GfxPackage]:
Expand Down
2 changes: 2 additions & 0 deletions archinstall/lib/utils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,6 @@ def format_cols(items: List[str], header: Optional[str] = None) -> str:
col = 4

text += FormattedOutput.as_columns(items, col)
# remove whitespaces on each row
text = '\n'.join([t.strip() for t in text.split('\n')])
return text
10 changes: 9 additions & 1 deletion archinstall/tui/curses_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ class SelectMenu(AbstractCurses):
def __init__(
self,
group: MenuItemGroup,
multi: bool = False,
orientation: Orientation = Orientation.VERTICAL,
alignment: Alignment = Alignment.LEFT,
columns: int = 1,
Expand All @@ -797,9 +798,9 @@ def __init__(
):
super().__init__()

self._multi = multi
self._cursor_char = f'{cursor_char} '
self._search_enabled = search_enabled
self._multi = False
self._allow_skip = allow_skip
self._allow_reset = allow_reset
self._active_search = False
Expand Down Expand Up @@ -848,6 +849,11 @@ def _get_header_offset(self) -> int:
offset += 3
return offset

def run(self) -> Result:
result = tui.run(self)
self._clear_all()
return result

def single(self) -> Result[MenuItem]:
self._multi = False
result = tui.run(self)
Expand Down Expand Up @@ -1020,6 +1026,8 @@ def _determine_prev_size(
match self._preview_style:
case PreviewStyle.RIGHT:
menu_width = self._item_group.max_width + 5
if self._multi:
menu_width += 5
prev_size = self._max_width - menu_width
case PreviewStyle.BOTTOM:
menu_height = len(self._item_group.items) + 1 # leave empty line between menu and preview
Expand Down

0 comments on commit ec5a915

Please sign in to comment.