mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-05 07:52:34 +00:00
Add phpstan level 7(#544)
This commit is contained in:
@ -18,6 +18,9 @@ class Installing extends Widget implements HasForms, HasInfolists
|
||||
use InteractsWithForms;
|
||||
use InteractsWithInfolists;
|
||||
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
protected $listeners = ['$refresh'];
|
||||
|
||||
protected static bool $isLazy = false;
|
||||
|
@ -21,6 +21,9 @@ class ServerDetails extends Widget implements HasForms, HasInfolists
|
||||
use InteractsWithForms;
|
||||
use InteractsWithInfolists;
|
||||
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
protected $listeners = ['$refresh'];
|
||||
|
||||
protected static bool $isLazy = false;
|
||||
@ -55,7 +58,7 @@ public function infolist(Infolist $infolist): Infolist
|
||||
Action::make('check-update')
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->tooltip('Check Now')
|
||||
->action(function (Server $record) {
|
||||
->action(function (Server $record): void {
|
||||
$record->checkForUpdates();
|
||||
|
||||
$this->dispatch('$refresh');
|
||||
@ -63,7 +66,7 @@ public function infolist(Infolist $infolist): Infolist
|
||||
Notification::make()
|
||||
->info()
|
||||
->title('Available updates:')
|
||||
->body($record->updates)
|
||||
->body((string) $record->updates)
|
||||
->send();
|
||||
})
|
||||
),
|
||||
@ -75,7 +78,7 @@ public function infolist(Infolist $infolist): Infolist
|
||||
->icon('heroicon-o-check-circle')
|
||||
->tooltip('Update Now')
|
||||
->requiresConfirmation()
|
||||
->action(function (Server $record) {
|
||||
->action(function (Server $record): void {
|
||||
app(Update::class)->update($record);
|
||||
|
||||
$this->dispatch('$refresh');
|
||||
@ -91,11 +94,11 @@ public function infolist(Infolist $infolist): Infolist
|
||||
->inlineLabel(),
|
||||
TextEntry::make('tags.*')
|
||||
->default('No tags')
|
||||
->formatStateUsing(fn ($state) => is_object($state) ? $state->name : $state)
|
||||
->formatStateUsing(fn ($state) => is_object($state) && isset($state->name) ? $state->name : $state)
|
||||
->inlineLabel()
|
||||
->badge()
|
||||
->color(fn ($state) => is_object($state) ? $state->color : 'gray')
|
||||
->icon(fn ($state) => is_object($state) ? 'heroicon-o-tag' : '')
|
||||
->color(fn ($state) => is_object($state) && isset($state->color) ? $state->color : 'gray')
|
||||
->icon(fn ($state): string => is_object($state) ? 'heroicon-o-tag' : '')
|
||||
->suffixAction(
|
||||
EditTags::infolist($this->server)
|
||||
),
|
||||
|
@ -16,17 +16,17 @@ protected function getStats(): array
|
||||
{
|
||||
$stats = [];
|
||||
|
||||
if ($this->server->webserver()) {
|
||||
if ($this->server->webserver() instanceof \App\Models\Service) {
|
||||
$stats[] = Stat::make('Sites', $this->server->sites()->count())
|
||||
->icon('heroicon-o-cursor-arrow-ripple');
|
||||
}
|
||||
|
||||
if ($this->server->database()) {
|
||||
if ($this->server->database() instanceof \App\Models\Service) {
|
||||
$stats[] = Stat::make('Databases', $this->server->databases()->count())
|
||||
->icon('heroicon-o-circle-stack');
|
||||
}
|
||||
|
||||
if ($this->server->defaultService('php')) {
|
||||
if ($this->server->defaultService('php') instanceof \App\Models\Service) {
|
||||
$stats[] = Stat::make('PHP Version', $this->server->defaultService('php')->version)
|
||||
->icon('heroicon-o-command-line');
|
||||
}
|
||||
|
@ -21,6 +21,9 @@ class ServerSummary extends Widget implements HasForms, HasInfolists
|
||||
use InteractsWithForms;
|
||||
use InteractsWithInfolists;
|
||||
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
protected $listeners = ['$refresh'];
|
||||
|
||||
protected static bool $isLazy = false;
|
||||
@ -39,7 +42,7 @@ public function infolist(Infolist $infolist): Infolist
|
||||
->schema([
|
||||
TextEntry::make('name')
|
||||
->label('Name')
|
||||
->url(fn (Server $record) => View::getUrl(parameters: ['server' => $record])),
|
||||
->url(fn (Server $record): string => View::getUrl(parameters: ['server' => $record])),
|
||||
TextEntry::make('ip')
|
||||
->label('IP Address')
|
||||
->icon('heroicon-o-clipboard-document')
|
||||
@ -48,14 +51,12 @@ public function infolist(Infolist $infolist): Infolist
|
||||
TextEntry::make('status')
|
||||
->label('Status')
|
||||
->badge()
|
||||
->color(static function ($state): string {
|
||||
return Server::$statusColors[$state];
|
||||
})
|
||||
->color(static fn ($state): string => Server::$statusColors[$state])
|
||||
->suffixAction(
|
||||
Action::make('check-status')
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->tooltip('Check Connection')
|
||||
->action(function (Server $record) {
|
||||
->action(function (Server $record): void {
|
||||
$previousStatus = $record->status;
|
||||
|
||||
$record = $record->checkConnection();
|
||||
|
@ -14,16 +14,22 @@
|
||||
|
||||
class ServersList extends Widget
|
||||
{
|
||||
/**
|
||||
* @return Builder<Server>
|
||||
*/
|
||||
protected function getTableQuery(): Builder
|
||||
{
|
||||
return Server::query()->where('project_id', auth()->user()->current_project_id);
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return Server::query()->where('project_id', $user->current_project_id);
|
||||
}
|
||||
|
||||
protected function getTableColumns(): array
|
||||
{
|
||||
return [
|
||||
IconColumn::make('provider')
|
||||
->icon(fn (Server $record) => 'icon-'.$record->provider)
|
||||
->icon(fn (Server $record): string => 'icon-'.$record->provider)
|
||||
->tooltip(fn (Server $record) => $record->provider)
|
||||
->width(24),
|
||||
TextColumn::make('name')
|
||||
@ -53,17 +59,20 @@ protected function getTableColumns(): array
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return $table
|
||||
->heading(null)
|
||||
->query($this->getTableQuery())
|
||||
->columns($this->getTableColumns())
|
||||
->recordUrl(fn (Server $record) => View::getUrl(parameters: ['server' => $record]))
|
||||
->recordUrl(fn (Server $record): string => View::getUrl(parameters: ['server' => $record]))
|
||||
->actions([
|
||||
Action::make('settings')
|
||||
->label('Settings')
|
||||
->icon('heroicon-o-cog-6-tooth')
|
||||
->authorize(fn ($record) => auth()->user()->can('update', $record))
|
||||
->url(fn (Server $record) => Settings::getUrl(parameters: ['server' => $record])),
|
||||
->authorize(fn ($record) => $user->can('update', $record))
|
||||
->url(fn (Server $record): string => Settings::getUrl(parameters: ['server' => $record])),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,9 @@ class UpdateServerInfo extends Widget implements HasForms
|
||||
|
||||
public string $ip;
|
||||
|
||||
public ?string $local_ip;
|
||||
public ?string $local_ip = null;
|
||||
|
||||
public string $port;
|
||||
public int $port;
|
||||
|
||||
public function mount(Server $server): void
|
||||
{
|
||||
|
Reference in New Issue
Block a user