From 00a9d8b9a3e68ce60e5db8391d504458f52df630 Mon Sep 17 00:00:00 2001 From: boban Date: Thu, 25 Jun 2026 20:20:46 +0200 Subject: [PATCH] feat(ui): shield-only 2FA indicator in the sidebar + terminal search from 2 servers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - sidebar: the "2FA on/off" text badge next to the user name was visually noisy. Replace it with a single status shield — a cyan shield-check when 2FA is on, a muted struck-through shield when off; the label moves to the hover/aria title so it stays reachable. - terminal: the server-target search now appears once there is more than one server (was 5+), so it is there as soon as filtering helps; added a clear (×) button + an accent focus ring. Browser-verified: sidebar shows just the shield (no text); search filters the rail (homelab → only homelab-01) with a working clear button; both badge states render correctly. 465 pass. Co-Authored-By: Claude Opus 4.8 --- app/Livewire/Terminal/Index.php | 4 ++-- lang/de/terminal.php | 1 + lang/en/terminal.php | 1 + resources/views/components/icon.blade.php | 2 ++ resources/views/components/sidebar.blade.php | 4 ++-- .../views/components/two-factor-badge.blade.php | 12 ++++++++---- resources/views/livewire/terminal/index.blade.php | 12 +++++++++--- tests/Feature/TerminalTest.php | 12 +++++------- 8 files changed, 30 insertions(+), 18 deletions(-) diff --git a/app/Livewire/Terminal/Index.php b/app/Livewire/Terminal/Index.php index 6637202..8de8791 100644 --- a/app/Livewire/Terminal/Index.php +++ b/app/Livewire/Terminal/Index.php @@ -20,8 +20,8 @@ use Livewire\Component; #[Layout('layouts.app')] class Index extends Component { - /** Show the server search box once the fleet is large enough to warrant filtering. */ - private const SEARCH_THRESHOLD = 5; + /** Show the server search box once there is more than one server to filter between. */ + private const SEARCH_THRESHOLD = 1; /** 'host' or a server uuid — drives the active-target highlight in the rail. */ public string $activeKey = ''; diff --git a/lang/de/terminal.php b/lang/de/terminal.php index 20458ee..6f2e982 100644 --- a/lang/de/terminal.php +++ b/lang/de/terminal.php @@ -13,6 +13,7 @@ return [ 'host_configure' => 'Host-Login einrichten', 'servers_heading' => 'Server', 'search_placeholder' => 'Server suchen…', + 'search_clear' => 'Suche zurücksetzen', 'no_match' => 'Keine Treffer.', 'no_servers' => 'Noch keine Server angelegt.', 'no_target' => 'Kein Ziel gewählt', diff --git a/lang/en/terminal.php b/lang/en/terminal.php index 88ca869..accbba5 100644 --- a/lang/en/terminal.php +++ b/lang/en/terminal.php @@ -13,6 +13,7 @@ return [ 'host_configure' => 'Set up host login', 'servers_heading' => 'Servers', 'search_placeholder' => 'Search servers…', + 'search_clear' => 'Clear search', 'no_match' => 'No matches.', 'no_servers' => 'No servers added yet.', 'no_target' => 'No target selected', diff --git a/resources/views/components/icon.blade.php b/resources/views/components/icon.blade.php index 00edc0e..e7634af 100644 --- a/resources/views/components/icon.blade.php +++ b/resources/views/components/icon.blade.php @@ -24,6 +24,8 @@ 'switcher' => '', 'search' => '', 'shield' => '', + 'shield-check' => '', + 'shield-off' => '', 'plus' => '', 'logout' => '', 'alert' => '', diff --git a/resources/views/components/sidebar.blade.php b/resources/views/components/sidebar.blade.php index 514572a..49acee9 100644 --- a/resources/views/components/sidebar.blade.php +++ b/resources/views/components/sidebar.blade.php @@ -54,8 +54,8 @@
{{ strtoupper(substr($u?->name ?? 'U', 0, 2)) }} - - {{ $u?->name ?? '—' }} + + {{ $u?->name ?? '—' }} diff --git a/resources/views/components/two-factor-badge.blade.php b/resources/views/components/two-factor-badge.blade.php index eb5d217..3aa9c24 100644 --- a/resources/views/components/two-factor-badge.blade.php +++ b/resources/views/components/two-factor-badge.blade.php @@ -1,8 +1,12 @@ @props(['enabled' => false]) +{{-- Status by colour, not a text badge: a cyan shield = 2FA on, a muted struck-through shield = off. + The label rides the title/aria-label (hover tooltip) so the meaning stays reachable. --}} @if ($enabled) - - {{ __('settings.two_factor_on') }} - + + + @else - {{ __('settings.two_factor_off') }} + + + @endif diff --git a/resources/views/livewire/terminal/index.blade.php b/resources/views/livewire/terminal/index.blade.php index e914088..5167789 100644 --- a/resources/views/livewire/terminal/index.blade.php +++ b/resources/views/livewire/terminal/index.blade.php @@ -35,10 +35,16 @@
{{ __('terminal.servers_heading') }}
@if ($showSearch) -
+
- + + @if ($search !== '') + + @endif
@endif diff --git a/tests/Feature/TerminalTest.php b/tests/Feature/TerminalTest.php index e6d669c..f3ada32 100644 --- a/tests/Feature/TerminalTest.php +++ b/tests/Feature/TerminalTest.php @@ -233,14 +233,12 @@ class TerminalTest extends TestCase ->assertDontSee('beta-db'); } - public function test_search_box_appears_only_past_the_threshold(): void + public function test_search_box_appears_once_there_is_more_than_one_server(): void { - $this->get(route('terminal'))->assertDontSee(__('terminal.search_placeholder')); + Server::create(['name' => 'only-one', 'ip' => '10.0.0.1', 'status' => 'online']); + $this->get(route('terminal'))->assertDontSee(__('terminal.search_placeholder')); // 1 server → no search - foreach (range(1, 6) as $i) { - Server::create(['name' => 'srv-'.$i, 'ip' => '10.0.0.'.$i, 'status' => 'online']); - } - - $this->get(route('terminal'))->assertSee(__('terminal.search_placeholder')); + Server::create(['name' => 'second', 'ip' => '10.0.0.2', 'status' => 'online']); + $this->get(route('terminal'))->assertSee(__('terminal.search_placeholder')); // 2 servers → search shows } }