mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-04 07:22:34 +00:00
migrating tests (Application, Console and Cronjob)
This commit is contained in:
@ -24,9 +24,9 @@ class Index extends \App\Web\Pages\Servers\Page
|
||||
|
||||
protected static ?string $title = 'Sites';
|
||||
|
||||
public static function canAccess(): bool
|
||||
public function mount(): void
|
||||
{
|
||||
return auth()->user()?->can('viewAny', [Site::class, static::getServerFromRoute()]) ?? false;
|
||||
$this->authorize('viewAny', [Site::class, $this->server]);
|
||||
}
|
||||
|
||||
public function getWidgets(): array
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Web\Pages\Servers\Sites;
|
||||
|
||||
use App\Models\Queue;
|
||||
use App\Models\Site;
|
||||
use App\Models\Ssl;
|
||||
use App\Web\Contracts\HasSecondSubNav;
|
||||
use App\Web\Pages\Servers\Page as BasePage;
|
||||
use App\Web\Pages\Servers\Sites\Widgets\SiteSummary;
|
||||
@ -17,9 +19,10 @@ abstract class Page extends BasePage implements HasSecondSubNav
|
||||
|
||||
public function getSecondSubNavigation(): array
|
||||
{
|
||||
$user = auth()->user();
|
||||
$items = [];
|
||||
|
||||
if (View::canAccess()) {
|
||||
if ($user->can('view', [$this->site, $this->server])) {
|
||||
$items[] = NavigationItem::make(View::getNavigationLabel())
|
||||
->icon('heroicon-o-globe-alt')
|
||||
->isActiveWhen(fn () => request()->routeIs(View::getRouteName()))
|
||||
@ -29,7 +32,7 @@ public function getSecondSubNavigation(): array
|
||||
]));
|
||||
}
|
||||
|
||||
if (Pages\SSL\Index::canAccess()) {
|
||||
if ($user->can('viewAny', [Ssl::class, $this->site, $this->server])) {
|
||||
$items[] = NavigationItem::make(Pages\SSL\Index::getNavigationLabel())
|
||||
->icon('heroicon-o-lock-closed')
|
||||
->isActiveWhen(fn () => request()->routeIs(Pages\SSL\Index::getRouteName()))
|
||||
@ -39,7 +42,7 @@ public function getSecondSubNavigation(): array
|
||||
]));
|
||||
}
|
||||
|
||||
if (Pages\Queues\Index::canAccess()) {
|
||||
if ($user->can('viewAny', [Queue::class, $this->site, $this->server])) {
|
||||
$items[] = NavigationItem::make(Pages\Queues\Index::getNavigationLabel())
|
||||
->icon('heroicon-o-queue-list')
|
||||
->isActiveWhen(fn () => request()->routeIs(Pages\Queues\Index::getRouteName()))
|
||||
@ -49,7 +52,7 @@ public function getSecondSubNavigation(): array
|
||||
]));
|
||||
}
|
||||
|
||||
if (Settings::canAccess()) {
|
||||
if ($user->can('update', [$this->site, $this->server])) {
|
||||
$items[] = NavigationItem::make(Settings::getNavigationLabel())
|
||||
->icon('heroicon-o-wrench-screwdriver')
|
||||
->isActiveWhen(fn () => request()->routeIs(Settings::getRouteName()))
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Web\Pages\Servers\Sites\Pages\Queues;
|
||||
|
||||
use App\Actions\Queue\CreateQueue;
|
||||
use App\Models\Queue;
|
||||
use App\Web\Pages\Servers\Sites\Page;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\CreateAction;
|
||||
@ -18,9 +19,9 @@ class Index extends Page
|
||||
|
||||
protected static ?string $title = 'Queues';
|
||||
|
||||
public static function canAccess(): bool
|
||||
public function mount(): void
|
||||
{
|
||||
return true;
|
||||
$this->authorize('viewAny', [Queue::class, $this->site, $this->server]);
|
||||
}
|
||||
|
||||
public function getWidgets(): array
|
||||
|
@ -20,9 +20,9 @@ class Index extends Page
|
||||
|
||||
protected static ?string $title = 'SSL';
|
||||
|
||||
public static function canAccess(): bool
|
||||
public function mount(): void
|
||||
{
|
||||
return auth()->user()?->can('viewAny', [Ssl::class, static::getSiteFromRoute(), static::getServerFromRoute()]) ?? false;
|
||||
$this->authorize('viewAny', [Ssl::class, $this->site, $this->server]);
|
||||
}
|
||||
|
||||
public function getWidgets(): array
|
||||
|
@ -17,9 +17,9 @@ class Settings extends Page
|
||||
|
||||
protected $listeners = ['$refresh'];
|
||||
|
||||
public static function canAccess(): bool
|
||||
public function mount(): void
|
||||
{
|
||||
return auth()->user()?->can('update', [static::getSiteFromRoute(), static::getServerFromRoute()]) ?? false;
|
||||
$this->authorize('update', [$this->site, $this->server]);
|
||||
}
|
||||
|
||||
public function getWidgets(): array
|
||||
|
@ -28,12 +28,9 @@ class View extends Page
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->previousStatus = $this->site->status;
|
||||
}
|
||||
$this->authorize('view', [$this->site, $this->server]);
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('view', [static::getSiteFromRoute(), static::getServerFromRoute()]) ?? false;
|
||||
$this->previousStatus = $this->site->status;
|
||||
}
|
||||
|
||||
#[On('$refresh')]
|
||||
|
Reference in New Issue
Block a user