The repeater admin actions start every label in the same cell
↻ and ⌨ draw one cell among two-cell siblings, so the rows' icon-plus-space labels started Read settings and Command line a column left of the rows under them. The Actions list now measures its icon column once and pads every mark out to it, like channels and the node page. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
a849556a33
commit
0257c53d8e
2 files changed
+44
-8
No files matched your search
@@ -39,8 +39,10 @@ from ..core.remote_config import (
|
||||
from .menus import (
|
||||
confirm_discard,
|
||||
exit_rows,
|
||||
icon_lane,
|
||||
lane_header,
|
||||
lane_row,
|
||||
marked_label,
|
||||
menu_rows,
|
||||
section_heading,
|
||||
)
|
||||
@@ -283,17 +285,23 @@ def _menu_items(node: Contact, cache: dict, pending: dict[str, str]) -> tuple[st
|
||||
Choice(title=lane_row(label, value, help_text, label_w, value_w), value=key)
|
||||
)
|
||||
|
||||
# ↻ and ⌨ are one cell where 📡 🕒 🔐 🔄 are two, so the column is measured once and
|
||||
# every mark padded out to it — otherwise Read settings and Command line start their
|
||||
# labels a column left of the rows under them.
|
||||
actions = [
|
||||
("↻", "Read settings", "Fetch every value from the node, one paced get", _READ),
|
||||
("⌨", "Command line…", "Talk to the node's CLI directly", _CLI),
|
||||
("📡", "Send advert…", "Have the node announce itself now", _ADVERT),
|
||||
("🕒", "Sync clock…", "Set the node's clock over the mesh", _CLOCK),
|
||||
("🔐", "Admin password…", "Change the node's admin password", _PASSWORD),
|
||||
("🔄", "Reboot node…", "Restart it remotely", _REBOOT),
|
||||
]
|
||||
lane = icon_lane(icon for icon, _, _, _ in actions)
|
||||
items.append(section_heading("Actions"))
|
||||
items.extend(
|
||||
menu_rows(
|
||||
[
|
||||
("↻ Read settings", "Fetch every value from the node, one paced get", _READ),
|
||||
("⌨ Command line…", "Talk to the node's CLI directly", _CLI),
|
||||
("📡 Send advert…", "Have the node announce itself now", _ADVERT),
|
||||
("🕒 Sync clock…", "Set the node's clock over the mesh", _CLOCK),
|
||||
("🔐 Admin password…", "Change the node's admin password", _PASSWORD),
|
||||
("🔄 Reboot node…", "Restart it remotely", _REBOOT),
|
||||
]
|
||||
(marked_label(icon, label, "", lane=lane), help_text, value)
|
||||
for icon, label, help_text, value in actions
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -366,6 +366,34 @@ def test_admin_menu_pins_the_column_header_over_the_category() -> None:
|
||||
assert above is True
|
||||
|
||||
|
||||
def test_admin_actions_start_every_label_in_the_same_cell() -> None:
|
||||
"""``↻`` and ``⌨`` are one cell among two-cell siblings; the icon column absorbs it.
|
||||
|
||||
The Actions rows used to write ``icon + " "``, which started *Read settings* and
|
||||
*Command line…* a column left of *Send advert…* below them.
|
||||
"""
|
||||
from rich.cells import cell_len
|
||||
|
||||
from meshterm.ui.repeater_admin import _menu_items
|
||||
from meshterm.ui.tui import Choice
|
||||
|
||||
_title, items = _menu_items(NODE, {}, {})
|
||||
labels = ("Read settings", "Command line…", "Send advert…", "Sync clock…", "Reboot node…")
|
||||
rows = [
|
||||
item.title.plain
|
||||
for item in items
|
||||
if isinstance(item, Choice)
|
||||
and hasattr(item.title, "plain")
|
||||
and any(label in item.title.plain for label in labels)
|
||||
]
|
||||
assert len(rows) == len(labels)
|
||||
starts = set()
|
||||
for row in rows:
|
||||
label = next(label for label in labels if label in row)
|
||||
starts.add(cell_len(row[: row.index(label)]))
|
||||
assert len(starts) == 1, "a label starts a column early"
|
||||
|
||||
|
||||
def test_admin_menu_header_abbreviates_rather_than_wrapping() -> None:
|
||||
"""Too narrow for the whole line, the last label shortens — the header stays one row."""
|
||||
from rich.cells import cell_len
|
||||
|
||||
Reference in new issue
Block a user