An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat(ui): add admin navigation link for root users
Andras Bacsai3fe1349ac4b8
diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.phpindex b062352216..80c96f9744 100644--- a/resources/views/components/navbar.blade.php+++ b/resources/views/components/navbar.blade.php@@ -195,9 +195,18 @@</a></li>@endif-<li class="flex-1" aria-hidden="true"></li>@endif+ @if (auth()->id() === 0 && (isCloud() || isDev()))+ <li>+ <a title="Admin" {{ wireNavigate() }}+ class="{{ request()->is('admin') ? 'menu-item-active menu-item' : 'menu-item' }}"+ :class="collapsed && 'lg:justify-center lg:px-0'" href="{{ route('admin.index') }}">+ <x-reicon name="fire" class="menu-item-icon text-pink-500" />+ <span class="menu-item-label" :class="collapsed && 'lg:hidden'">Admin</span>+ </a>+ </li>+ @endif@if (isCloud() && ! isSubscribed()){{-- Unsubscribed cloud has no workspace items — keep these at the top of the list. --}}<li class="nav-section" :class="collapsed && 'lg:hidden'">Account</li>diff --git a/resources/views/components/reicon.blade.php b/resources/views/components/reicon.blade.phpindex d932dd8fe6..04471497f5 100644--- a/resources/views/components/reicon.blade.php+++ b/resources/views/components/reicon.blade.php@@ -6,6 +6,7 @@// copy the inner markup from the reicon Outline weight and swap// #000000 -> currentColor. See DESIGN.md.$icons = [+ 'fire' => '<path d="M12.83 2.18a.75.75 0 0 0-1.15.64c0 2.04-.88 3.72-2.31 5.19-.45-1.13-.59-2.31-.42-3.55a.75.75 0 0 0-1.17-.72C4.55 5.96 2.75 9.25 2.75 13a9.25 9.25 0 0 0 18.5 0c0-4.72-3.28-8.6-8.42-10.82ZM12 20.75A7.75 7.75 0 0 1 4.25 13c0-2.67 1.07-5.1 3.05-6.94.08 1.37.46 2.68 1.12 3.93a.75.75 0 0 0 1.18.19c1.85-1.62 3.03-3.48 3.43-5.6 4.13 2.09 6.72 5.13 6.72 8.42A7.75 7.75 0 0 1 12 20.75Z" fill="currentColor"/><path d="M12.38 10.13a.75.75 0 0 0-1.26.32c-.33 1.2-1.06 2.06-1.7 2.82-.69.81-1.17 1.52-1.17 2.73a3.75 3.75 0 0 0 7.5 0c0-2.13-1.2-4.1-3.37-5.87ZM12 18.25A2.25 2.25 0 0 1 9.75 16c0-.65.24-1.03.82-1.72.48-.57 1.03-1.21 1.45-2.06 1.47 1.37 2.23 2.63 2.23 3.78A2.25 2.25 0 0 1 12 18.25Z" fill="currentColor"/>','cloud' => '<path d="M7.5 19.25h9.75a4.5 4.5 0 0 0 .62-8.96A6.25 6.25 0 0 0 5.8 8.65 5.25 5.25 0 0 0 7.5 19.25Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>','code' => '<path d="m8.5 7-5 5 5 5M15.5 7l5 5-5 5M13.5 4l-3 16" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>','mail' => '<path fill-rule="evenodd" clip-rule="evenodd" d="M5.5 3.25h13A4.25 4.25 0 0 1 22.75 7.5v9a4.25 4.25 0 0 1-4.25 4.25h-13A4.25 4.25 0 0 1 1.25 16.5v-9A4.25 4.25 0 0 1 5.5 3.25Zm-2.75 4.5v8.75a2.75 2.75 0 0 0 2.75 2.75h13a2.75 2.75 0 0 0 2.75-2.75V7.75l-6.6 5.13a4.25 4.25 0 0 1-5.3 0l-6.6-5.13Zm18.4-1.3A2.75 2.75 0 0 0 18.5 4.75h-13a2.75 2.75 0 0 0-2.65 1.7l7.42 5.77a2.75 2.75 0 0 0 3.46 0l7.42-5.77Z" fill="currentColor"/>',diff --git a/tests/Feature/AdminAccessAuthorizationTest.php b/tests/Feature/AdminAccessAuthorizationTest.phpindex 97895ecda8..478f381d5a 100644--- a/tests/Feature/AdminAccessAuthorizationTest.php+++ b/tests/Feature/AdminAccessAuthorizationTest.php@@ -5,6 +5,7 @@ use App\Models\InstanceSettings;use App\Models\Team;use App\Models\User;use Illuminate\Foundation\Testing\RefreshDatabase;+use Illuminate\Support\Facades\Blade;use Livewire\Livewire;uses(RefreshDatabase::class);@@ -157,3 +158,28 @@ test('admin route has auth middleware applied', function () {expect($middleware)->toContain('auth');});++test('root user sees the admin link in the navbar', function () {+ config()->set('constants.coolify.self_hosted', false);++ $rootUser = User::factory()->create(['id' => 0]);+ $this->actingAs($rootUser);++ $navbar = Blade::render('<x-navbar />');++ expect($navbar)+ ->toContain('href="'.route('admin.index').'"')+ ->toContain('title="Admin"')+ ->toContain('text-pink-500');+});++test('non-root user does not see the admin link in the navbar', function () {+ config()->set('constants.coolify.self_hosted', false);++ $user = User::factory()->create();+ $this->actingAs($user);++ $navbar = Blade::render('<x-navbar />');++ expect($navbar)->not->toContain('href="'.route('admin.index').'"');+});