diff --git a/resources/views/admin/dashboard.blade.php b/resources/views/admin/dashboard.blade.php new file mode 100644 index 0000000..457104f --- /dev/null +++ b/resources/views/admin/dashboard.blade.php @@ -0,0 +1,78 @@ +@php + $toolbarItems = [ + [ + 'label' => 'Ideas', + 'href' => route('home'), + 'icon' => 'heroicon-o-light-bulb', + ], + [ + 'label' => 'Planning', + 'href' => '#planning', + 'icon' => 'heroicon-o-clipboard-document-list', + ], + [ + 'label' => 'Development', + 'href' => '#development', + 'icon' => 'heroicon-o-code-bracket-square', + ], + [ + 'label' => 'Testing', + 'href' => '#testing', + 'icon' => 'heroicon-o-beaker', + ], + [ + 'label' => 'Security', + 'href' => '#security', + 'icon' => 'heroicon-o-shield-check', + ], + [ + 'label' => 'Ops', + 'href' => '#ops', + 'icon' => 'heroicon-o-command-line', + ], + ]; + + $contextItems = [ + [ + 'label' => 'Dashboard', + 'href' => route('admin.dashboard'), + 'current' => true, + 'icon' => 'heroicon-o-squares-2x2', + ], + [ + 'label' => 'Users', + 'href' => '#users', + 'icon' => 'heroicon-o-users', + ], + [ + 'label' => 'Roles', + 'href' => '#roles', + 'icon' => 'heroicon-o-shield-check', + ], + ]; +@endphp + + +
+ + + +

+ This dashboard is the first admin-only landing surface. It uses the same shell and shared components as the rest of the app, + but it stays behind the authorization gate and will grow into user, role, and system management from here. +

+
+
+
diff --git a/resources/views/components/layouts/app-shell.blade.php b/resources/views/components/layouts/app-shell.blade.php index 7d39009..b715149 100644 --- a/resources/views/components/layouts/app-shell.blade.php +++ b/resources/views/components/layouts/app-shell.blade.php @@ -2,6 +2,7 @@ 'title' => config('app.name', 'Replicator'), 'toolbarItems' => [], 'contextItems' => [], + 'showAdminEntry' => false, ]) @php @@ -90,6 +91,15 @@ class="flex size-10 items-center justify-center rounded-lg bg-white/10 text-whit :current="$item['current'] ?? false" /> @endforeach + + @if ($showAdminEntry && auth()->user()?->isAn('admin')) + + @endif diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 5c62701..2224065 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -31,11 +31,6 @@ 'href' => '#ops', 'icon' => 'heroicon-o-command-line', ], - [ - 'label' => 'Admin', - 'href' => '#admin', - 'icon' => 'heroicon-o-cog-6-tooth', - ], ]; $contextItems = [ @@ -63,7 +58,12 @@ ]; @endphp - +
name('home'); Route::get('/admin', function () { - return view('home'); + return view('admin.dashboard'); })->middleware(['auth', 'can:access-admin'])->name('admin.dashboard'); diff --git a/tests/Feature/Auth/RbacTest.php b/tests/Feature/Auth/RbacTest.php index 52d8143..fdbfa81 100644 --- a/tests/Feature/Auth/RbacTest.php +++ b/tests/Feature/Auth/RbacTest.php @@ -31,3 +31,20 @@ ->get(route('admin.dashboard')) ->assertSuccessful(); }); + +it('shows the admin toolbar entry only to admins', function (): void { + $user = User::factory()->create(); + + $this->actingAs($user) + ->get(route('home')) + ->assertSuccessful() + ->assertDontSee('href="'.route('admin.dashboard').'"', false); + + $admin = User::factory()->create(); + $admin->assign('admin'); + + $this->actingAs($admin) + ->get(route('home')) + ->assertSuccessful() + ->assertSee('href="'.route('admin.dashboard').'"', false); +});