mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-19 18:01:37 +00:00
move site logs to separate sub-menu (#449)
This commit is contained in:
parent
8b58834a31
commit
7b723bcba5
@ -3,6 +3,7 @@
|
|||||||
namespace App\Web\Pages\Servers\Sites;
|
namespace App\Web\Pages\Servers\Sites;
|
||||||
|
|
||||||
use App\Models\Queue;
|
use App\Models\Queue;
|
||||||
|
use App\Models\ServerLog;
|
||||||
use App\Models\Site;
|
use App\Models\Site;
|
||||||
use App\Models\Ssl;
|
use App\Models\Ssl;
|
||||||
use App\Web\Contracts\HasSecondSubNav;
|
use App\Web\Contracts\HasSecondSubNav;
|
||||||
@ -52,6 +53,16 @@ public function getSecondSubNavigation(): array
|
|||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($user->can('viewAny', [ServerLog::class, $this->server])) {
|
||||||
|
$items[] = NavigationItem::make(Pages\Logs\Index::getNavigationLabel())
|
||||||
|
->icon('heroicon-o-square-3-stack-3d')
|
||||||
|
->isActiveWhen(fn () => request()->routeIs(Pages\Logs\Index::getRouteName()))
|
||||||
|
->url(Pages\Logs\Index::getUrl(parameters: [
|
||||||
|
'server' => $this->server,
|
||||||
|
'site' => $this->site,
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
if ($user->can('update', [$this->site, $this->server])) {
|
if ($user->can('update', [$this->site, $this->server])) {
|
||||||
$items[] = NavigationItem::make(Settings::getNavigationLabel())
|
$items[] = NavigationItem::make(Settings::getNavigationLabel())
|
||||||
->icon('heroicon-o-wrench-screwdriver')
|
->icon('heroicon-o-wrench-screwdriver')
|
||||||
|
37
app/Web/Pages/Servers/Sites/Pages/Logs/Index.php
Normal file
37
app/Web/Pages/Servers/Sites/Pages/Logs/Index.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Web\Pages\Servers\Sites\Pages\Logs;
|
||||||
|
|
||||||
|
use App\Models\ServerLog;
|
||||||
|
use App\Web\Pages\Servers\Logs\Widgets\LogsList;
|
||||||
|
use App\Web\Pages\Servers\Sites\Page;
|
||||||
|
|
||||||
|
class Index extends Page
|
||||||
|
{
|
||||||
|
protected static ?string $slug = 'servers/{server}/sites/{site}/logs';
|
||||||
|
|
||||||
|
protected static ?string $title = 'Logs';
|
||||||
|
|
||||||
|
public function mount(): void
|
||||||
|
{
|
||||||
|
$this->authorize('viewAny', [ServerLog::class, $this->server]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getWidgets(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
LogsList::class, [
|
||||||
|
'server' => $this->server,
|
||||||
|
'site' => $this->site,
|
||||||
|
'label' => 'Logs',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
@ -7,9 +7,7 @@
|
|||||||
use App\Actions\Site\UpdateDeploymentScript;
|
use App\Actions\Site\UpdateDeploymentScript;
|
||||||
use App\Actions\Site\UpdateEnv;
|
use App\Actions\Site\UpdateEnv;
|
||||||
use App\Enums\SiteFeature;
|
use App\Enums\SiteFeature;
|
||||||
use App\Models\ServerLog;
|
|
||||||
use App\Web\Fields\CodeEditorField;
|
use App\Web\Fields\CodeEditorField;
|
||||||
use App\Web\Pages\Servers\Logs\Widgets\LogsList;
|
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Actions\ActionGroup;
|
use Filament\Actions\ActionGroup;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
@ -62,16 +60,6 @@ public function getWidgets(): array
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auth()->user()->can('viewAny', [ServerLog::class, $this->server])) {
|
|
||||||
$widgets[] = [
|
|
||||||
LogsList::class, [
|
|
||||||
'server' => $this->server,
|
|
||||||
'site' => $this->site,
|
|
||||||
'label' => 'Logs',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $widgets;
|
return $widgets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
37
tests/Feature/SiteLogsTest.php
Normal file
37
tests/Feature/SiteLogsTest.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Models\ServerLog;
|
||||||
|
use App\Web\Pages\Servers\Sites\Pages\Logs\Index;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This uses the server logs.
|
||||||
|
* All scenarios are covered in \Tests\Feature\LogsTest
|
||||||
|
*/
|
||||||
|
class SiteLogsTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
public function test_see_logs()
|
||||||
|
{
|
||||||
|
$this->actingAs($this->user);
|
||||||
|
|
||||||
|
/** @var ServerLog $lastLog */
|
||||||
|
$lastLog = ServerLog::factory()->create([
|
||||||
|
'server_id' => $this->server->id,
|
||||||
|
'site_id' => $this->site->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->get(
|
||||||
|
Index::getUrl([
|
||||||
|
'server' => $this->server,
|
||||||
|
'site' => $this->site,
|
||||||
|
])
|
||||||
|
)
|
||||||
|
->assertSuccessful()
|
||||||
|
->assertSee($lastLog->name);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user