mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-04 15:32:35 +00:00
migrating tests (DatabaseUser, Firewall and Logs)
This commit is contained in:
@ -30,7 +30,7 @@ public function mount(): void
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('Create User')
|
||||
Action::make('create')
|
||||
->icon('heroicon-o-plus')
|
||||
->modalWidth(MaxWidth::Large)
|
||||
->authorize(fn () => auth()->user()?->can('create', [DatabaseUser::class, $this->server]))
|
||||
|
@ -3,11 +3,14 @@
|
||||
namespace App\Web\Pages\Servers\Logs;
|
||||
|
||||
use App\Models\ServerLog;
|
||||
use App\Web\Contracts\HasSecondSubNav;
|
||||
use App\Web\Pages\Servers\Logs\Widgets\LogsList;
|
||||
use App\Web\Pages\Servers\Page;
|
||||
|
||||
class Index extends Page
|
||||
class Index extends Page implements HasSecondSubNav
|
||||
{
|
||||
use Traits\Navigation;
|
||||
|
||||
protected static ?string $slug = 'servers/{server}/logs';
|
||||
|
||||
protected static ?string $title = 'Logs';
|
||||
|
54
app/Web/Pages/Servers/Logs/RemoteLogs.php
Normal file
54
app/Web/Pages/Servers/Logs/RemoteLogs.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Web\Pages\Servers\Logs;
|
||||
|
||||
use App\Actions\Server\CreateServerLog;
|
||||
use App\Models\ServerLog;
|
||||
use App\Web\Contracts\HasSecondSubNav;
|
||||
use App\Web\Pages\Servers\Logs\Widgets\LogsList;
|
||||
use App\Web\Pages\Servers\Page;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Support\Enums\MaxWidth;
|
||||
|
||||
class RemoteLogs extends Page implements HasSecondSubNav
|
||||
{
|
||||
use Traits\Navigation;
|
||||
|
||||
protected static ?string $slug = 'servers/{server}/logs/remote';
|
||||
|
||||
protected static ?string $title = 'Remote Logs';
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->authorize('viewAny', [ServerLog::class, $this->server]);
|
||||
}
|
||||
|
||||
public function getWidgets(): array
|
||||
{
|
||||
return [
|
||||
[LogsList::class, ['server' => $this->server, 'remote' => true]],
|
||||
];
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('create')
|
||||
->icon('heroicon-o-plus')
|
||||
->modalWidth(MaxWidth::Large)
|
||||
->authorize(fn () => auth()->user()?->can('create', [ServerLog::class, $this->server]))
|
||||
->form([
|
||||
TextInput::make('path')
|
||||
->helperText('The full path of the log file on the server')
|
||||
->rules(fn (callable $get) => CreateServerLog::rules()['path']),
|
||||
])
|
||||
->modalSubmitActionLabel('Create')
|
||||
->action(function (array $data) {
|
||||
app(CreateServerLog::class)->create($this->server, $data);
|
||||
|
||||
$this->dispatch('$refresh');
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
34
app/Web/Pages/Servers/Logs/Traits/Navigation.php
Normal file
34
app/Web/Pages/Servers/Logs/Traits/Navigation.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Web\Pages\Servers\Logs\Traits;
|
||||
|
||||
use App\Models\ServerLog;
|
||||
use App\Web\Pages\Servers\Logs\Index;
|
||||
use App\Web\Pages\Servers\Logs\RemoteLogs;
|
||||
use Filament\Navigation\NavigationGroup;
|
||||
use Filament\Navigation\NavigationItem;
|
||||
|
||||
trait Navigation
|
||||
{
|
||||
public function getSecondSubNavigation(): array
|
||||
{
|
||||
$items = [];
|
||||
|
||||
if (auth()->user()->can('viewAny', [ServerLog::class, $this->server])) {
|
||||
$items[] = NavigationItem::make(Index::getNavigationLabel())
|
||||
->icon('heroicon-o-square-3-stack-3d')
|
||||
->isActiveWhen(fn () => request()->routeIs(Index::getRouteName()))
|
||||
->url(Index::getUrl(parameters: ['server' => $this->server]));
|
||||
|
||||
$items[] = NavigationItem::make(RemoteLogs::getNavigationLabel())
|
||||
->icon('heroicon-o-wifi')
|
||||
->isActiveWhen(fn () => request()->routeIs(RemoteLogs::getRouteName()))
|
||||
->url(RemoteLogs::getUrl(parameters: ['server' => $this->server]));
|
||||
}
|
||||
|
||||
return [
|
||||
NavigationGroup::make()
|
||||
->items($items),
|
||||
];
|
||||
}
|
||||
}
|
@ -26,6 +26,8 @@ class LogsList extends Widget
|
||||
|
||||
public ?string $label = '';
|
||||
|
||||
public bool $remote = false;
|
||||
|
||||
protected $listeners = ['$refresh'];
|
||||
|
||||
protected function getTableQuery(): Builder
|
||||
@ -36,7 +38,8 @@ protected function getTableQuery(): Builder
|
||||
if ($this->site) {
|
||||
$query->where('site_id', $this->site->id);
|
||||
}
|
||||
});
|
||||
})
|
||||
->where('is_remote', $this->remote);
|
||||
}
|
||||
|
||||
protected function getTableColumns(): array
|
||||
|
Reference in New Issue
Block a user