mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 14:06:15 +00:00
cleanup migration to filament
This commit is contained in:
@ -12,7 +12,7 @@ public function __construct(public string $href, public string $text, public boo
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('web.components.link');
|
||||
return view('components.link');
|
||||
}
|
||||
|
||||
public function toHtml(): View|string
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
abstract class Page extends BasePage
|
||||
{
|
||||
protected static string $view = 'web.components.page';
|
||||
protected static string $view = 'components.page';
|
||||
|
||||
protected ?string $live = '5s';
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
class AlertField extends Field
|
||||
{
|
||||
protected string $view = 'web.fields.alert';
|
||||
protected string $view = 'fields.alert';
|
||||
|
||||
public string $color = 'blue';
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
class CodeEditorField extends Field
|
||||
{
|
||||
protected string $view = 'web.fields.code-editor';
|
||||
protected string $view = 'fields.code-editor';
|
||||
|
||||
public string $lang = '';
|
||||
|
||||
|
@ -6,5 +6,5 @@
|
||||
|
||||
class ProviderField extends Field
|
||||
{
|
||||
protected string $view = 'web.fields.provider';
|
||||
protected string $view = 'fields.provider';
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ class Console extends Component
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('web.components.console', [
|
||||
return view('components.console', [
|
||||
'server' => $this->server,
|
||||
]);
|
||||
}
|
||||
|
@ -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?',
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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),
|
||||
|
@ -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 = '';
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user