cleanup migration to filament

This commit is contained in:
Saeed Vaziry
2024-10-06 21:46:03 +02:00
parent 06d690138d
commit a94d1d42d2
420 changed files with 39 additions and 15481 deletions

View File

@ -12,7 +12,7 @@ class Console extends Component
public function render(): View
{
return view('web.components.console', [
return view('components.console', [
'server' => $this->server,
]);
}

View File

@ -48,7 +48,7 @@ protected function getHeaderActions(): array
->form([
TextInput::make('command')
->rules(fn (callable $get) => CreateCronJob::rules($get())['command'])
->helperText(fn () => view('web.components.link', [
->helperText(fn () => view('components.link', [
'href' => 'https://vitodeploy.com/servers/cronjobs.html',
'external' => true,
'text' => 'How the command should look like?',

View File

@ -65,7 +65,7 @@ public function getTable(): Table
->color('gray')
->tooltip('Show backup files')
->authorize(fn (Backup $record) => auth()->user()->can('viewAny', [BackupFile::class, $record]))
->modalContent(fn (Backup $record) => view('web.components.dynamic-widget', [
->modalContent(fn (Backup $record) => view('components.dynamic-widget', [
'widget' => BackupFilesList::class,
'params' => [
'backup' => $record,

View File

@ -18,7 +18,7 @@ class FilterForm extends Widget implements HasForms
{
use InteractsWithForms;
protected static string $view = 'web.components.form';
protected static string $view = 'components.form';
public ?array $data = [
'period' => '1h',
@ -73,7 +73,7 @@ public function form(Form $form): Form
]),
ViewField::make('data')
->reactive()
->view('web.components.dynamic-widget', [
->view('components.dynamic-widget', [
'widget' => Metrics::class,
'params' => [
'server' => $this->server,

View File

@ -24,7 +24,7 @@ class MetricDetails extends Widget implements HasForms, HasInfolists
protected static bool $isLazy = false;
protected static string $view = 'web.components.infolist';
protected static string $view = 'components.infolist';
public Server $server;

View File

@ -22,7 +22,7 @@ class Installing extends Widget implements HasForms, HasInfolists
protected static bool $isLazy = false;
protected static string $view = 'web.components.infolist';
protected static string $view = 'components.infolist';
public Site $site;

View File

@ -32,7 +32,7 @@ class SiteDetails extends Widget implements HasForms, HasInfolists
protected static bool $isLazy = false;
protected static string $view = 'web.components.infolist';
protected static string $view = 'components.infolist';
public Site $site;

View File

@ -22,7 +22,7 @@ class SiteSummary extends Widget implements HasForms, HasInfolists
protected static bool $isLazy = false;
protected static string $view = 'web.components.infolist';
protected static string $view = 'components.infolist';
public Site $site;

View File

@ -22,7 +22,7 @@ class Installing extends Widget implements HasForms, HasInfolists
protected static bool $isLazy = false;
protected static string $view = 'web.components.infolist';
protected static string $view = 'components.infolist';
public Server $server;

View File

@ -1,101 +0,0 @@
<?php
namespace App\Web\Pages\Servers\Widgets;
use App\Models\Server;
use App\Web\Resources\Server\Pages\CreateServer;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Select;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Widgets\Widget;
use Illuminate\Database\Eloquent\Builder;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class SelectServer extends Widget implements HasForms
{
use InteractsWithForms;
protected static string $view = 'web.components.form';
public int|string|null $server = null;
/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function mount(): void
{
$server = Server::query()
->where('project_id', auth()->user()->current_project_id)
->find(session()->get('current_server_id'));
if ($server && auth()->user()->can('view', $server)) {
$this->server = $server->id;
}
}
protected function getFormSchema(): array
{
$options = $this->query()
->limit(10)
->pluck('name', 'id')
->toArray();
return [
Select::make('server')
->name('server')
->model($this->server)
->searchable()
->options($options)
->searchPrompt('Search...')
->getSearchResultsUsing(function ($search) {
return $this->query()
->where('name', 'like', "%{$search}%")
->limit(10)
->pluck('name', 'id')
->toArray();
})
->extraAttributes(['class' => '-mx-2 pointer-choices'])
->live()
->hintIcon('heroicon-o-question-mark-circle')
->hintIconTooltip('Filter resources by default based on a server')
->suffixAction(
Action::make('create')
->icon('heroicon-o-plus')
->tooltip('Create a new server')
->url(CreateServer::getUrl())
),
];
}
private function query(): Builder
{
return Server::query()
->where(function (Builder $query) {
$query->where('project_id', auth()->user()->current_project_id);
});
}
public function updatedServer($value): void
{
if (! $value) {
session()->forget('current_server_id');
$this->redirect(url()->previous());
return;
}
$server = Server::query()->find($value);
if (! $server) {
session()->forget('current_server_id');
return;
}
$this->authorize('view', $server);
session()->put('current_server_id', $value);
$this->redirect(url()->previous());
}
}

View File

@ -25,7 +25,7 @@ class ServerDetails extends Widget implements HasForms, HasInfolists
protected static bool $isLazy = false;
protected static string $view = 'web.components.infolist';
protected static string $view = 'components.infolist';
public Server $server;

View File

@ -25,7 +25,7 @@ class ServerSummary extends Widget implements HasForms, HasInfolists
protected static bool $isLazy = false;
protected static string $view = 'web.components.infolist';
protected static string $view = 'components.infolist';
public Server $server;

View File

@ -19,7 +19,7 @@ class UpdateServerInfo extends Widget implements HasForms
protected static bool $isLazy = false;
protected static string $view = 'web.components.form';
protected static string $view = 'components.form';
public Server $server;

View File

@ -18,7 +18,7 @@ class ProfileInformation extends Widget implements HasForms
protected static bool $isLazy = false;
protected static string $view = 'web.components.form';
protected static string $view = 'components.form';
public string $name;

View File

@ -26,7 +26,7 @@ class TwoFactor extends Widget implements HasForms, HasInfolists
protected static bool $isLazy = false;
protected static string $view = 'web.components.infolist';
protected static string $view = 'components.infolist';
public bool $enabled = false;
@ -52,7 +52,7 @@ public function infolist(Infolist $infolist): Infolist
->visible(! $this->enabled),
ViewEntry::make('qr_code')
->hiddenLabel()
->view('web.components.container', [
->view('components.container', [
'content' => $this->enabled ? auth()->user()->twoFactorQrCodeSvg() : null,
])
->visible($this->enabled && $this->showCodes),
@ -69,7 +69,7 @@ public function infolist(Infolist $infolist): Infolist
ViewEntry::make('recovery_codes')
->hiddenLabel()
->extraAttributes(['class' => 'rounded-lg border border-gray-100 p-2 dark:border-gray-700'])
->view('web.components.container', [
->view('components.container', [
'content' => $this->enabled ? implode('</br>', json_decode(decrypt(auth()->user()->two_factor_recovery_codes), true)) : null,
])
->visible($this->enabled),

View File

@ -17,7 +17,7 @@ class UpdatePassword extends Widget implements HasForms
protected static bool $isLazy = false;
protected static string $view = 'web.components.form';
protected static string $view = 'components.form';
public string $current_password = '';

View File

@ -16,7 +16,7 @@ class AddUser extends Widget implements HasForms
{
use InteractsWithForms;
protected static string $view = 'web.components.form';
protected static string $view = 'components.form';
public Project $project;

View File

@ -9,7 +9,7 @@
class SelectProject extends Widget
{
protected static string $view = 'web.widgets.select-project';
protected static string $view = 'widgets.select-project';
public ?Project $currentProject;

View File

@ -15,7 +15,7 @@ class UpdateProject extends Widget implements HasForms
{
use InteractsWithForms;
protected static string $view = 'web.components.form';
protected static string $view = 'components.form';
public Project $project;