Skip to content

Commit d2c3eef

Browse files
committed
feat(console-menu): merge review/summary into a single diff-against-DB step
Review step now renders a box that lists only fields whose value will actually change (old → new), with a "NEW INTERFACE" headline when no DB row exists for the selected interface. The box is embedded into the CliMenu title so it survives configureTerminal()->clear() on menu open — a prior stdout echo was being wiped immediately, causing the "flashes and disappears" behaviour. - NetworkWizard::reviewAndConfirm loads the live LanInterfaces row by interface name, hands it to renderChangesBoxed(), and embeds the result into the menu title. The intermediate "Press Enter to continue" prompt is gone — one screen, one decision. - WizardHelpers::renderChangesBoxed returns the box as a string instead of echoing. Width 60 leaves headroom for CliMenu's margin/border/padding. - New helpers: buildConfigDiff, labelIpv4Mode, labelIpv6Mode, labelIpv4Dns, labelIpv6Dns, formatDiffRow, padRight, boxTopLine, boxBottomLine, boxLine. - IPv4 and IPv6 DNS are diffed separately, so a manual IPv6 DNS change is no longer masked when IPv4 is DHCP. - Padding uses mb_strlen rather than sprintf '%-Ns' (which counts bytes), so UTF-8 box glyphs and em-dashes don't push columns sideways. - Dead code removed: showConfigSummary, showConfigSummaryBoxed, and the four printBox* helpers — there were no other callers.
1 parent b2ff938 commit d2c3eef

2 files changed

Lines changed: 215 additions & 178 deletions

File tree

src/Core/System/ConsoleMenu/Wizards/NetworkWizard.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,19 @@ private function configureDNS(CliMenu $menu, string $interfaceName, array $curre
447447
*/
448448
private function reviewAndConfirm(CliMenu $menu, array $config): ?bool
449449
{
450-
$this->helpers->showConfigSummaryBoxed($config);
450+
// Diff the pending config against the live DB record so the user sees
451+
// only what will actually change before pressing Apply.
452+
$current = LanInterfaces::findFirst([
453+
'interface = :interface:',
454+
'bind' => ['interface' => $config['interface']]
455+
]);
451456

452-
echo "\n" . $this->translation->_('cm_PressEnterToContinue') . "\n";
453-
fgets(STDIN);
457+
// Box is embedded in the menu title so it survives CliMenu's
458+
// configureTerminal() -> clear() on open. A naive echo before
459+
// $menu->open() would be wiped immediately.
460+
$title = $this->translation->_('cm_ReviewConfiguration')
461+
. "\n\n"
462+
. $this->helpers->renderChangesBoxed($config, $current);
454463

455464
$options = [
456465
'apply' => $this->translation->_('cm_ApplyConfiguration'),
@@ -460,7 +469,7 @@ private function reviewAndConfirm(CliMenu $menu, array $config): ?bool
460469

461470
$choice = $this->helpers->showArrowChoiceMenu(
462471
$menu,
463-
$this->translation->_('cm_ReviewConfiguration'),
472+
$title,
464473
$options
465474
);
466475

0 commit comments

Comments
 (0)