Files
panel-pelican-dev/app/Filament/Resources/NodeResource/Pages/EditNode.php

82 lines
2.8 KiB
PHP
Raw Normal View History

2024-03-24 01:48:03 -04:00
<?php
namespace App\Filament\Resources\NodeResource\Pages;
use App\Filament\Resources\NodeResource;
2024-03-31 01:39:24 -04:00
use App\Models\Node;
2024-03-24 01:48:03 -04:00
use Filament\Actions;
2024-03-24 14:42:36 -04:00
use Filament\Forms;
2024-04-04 20:16:14 -04:00
use Filament\Forms\Components\Tabs;
2024-03-24 01:48:03 -04:00
use Filament\Resources\Pages\EditRecord;
2024-03-31 01:39:24 -04:00
use Illuminate\Support\HtmlString;
use Webbingbrasil\FilamentCopyActions\Forms\Actions\CopyAction;
2024-03-24 01:48:03 -04:00
class EditNode extends EditRecord
{
protected static string $resource = NodeResource::class;
2024-03-24 14:42:36 -04:00
public function form(Forms\Form $form): Forms\Form
{
2024-04-04 20:16:14 -04:00
return $form->schema([
Tabs::make('Tabs')
2024-04-16 18:47:12 -04:00
->columns([
'default' => 2,
'sm' => 3,
'md' => 3,
'lg' => 4,
])
2024-04-04 20:16:14 -04:00
->persistTabInQueryString()
->columnSpanFull()
->tabs([
Tabs\Tab::make('Basic Settings')
->icon('tabler-server')
2024-03-24 14:42:36 -04:00
->schema((new CreateNode())->form($form)->getComponents()),
// Tabs\Tab::make('Advanced Settings')
// ->icon('tabler-server-cog')
// ->schema([
// Forms\Components\Placeholder::make('Coming soon!'),
// ]),
2024-04-04 20:16:14 -04:00
Tabs\Tab::make('Configuration')
->icon('tabler-code')
2024-03-24 14:42:36 -04:00
->schema([
2024-03-31 01:39:24 -04:00
Forms\Components\Placeholder::make('instructions')
->columnSpanFull()
->content(new HtmlString('
2024-04-11 00:45:33 -04:00
Save this file to your <span title="usually /etc/pelican/">daemon\'s root directory</span>, named <code>config.yml</code>
2024-03-31 01:39:24 -04:00
')),
Forms\Components\Textarea::make('config')
2024-04-11 00:45:33 -04:00
->label('/etc/pelican/config.yml')
2024-03-31 01:39:24 -04:00
->disabled()
->rows(19)
->hintAction(CopyAction::make())
->columnSpanFull(),
2024-03-24 14:42:36 -04:00
]),
2024-04-13 16:30:20 +03:00
]),
2024-04-04 20:16:14 -04:00
]);
2024-03-24 14:42:36 -04:00
}
2024-03-31 01:39:24 -04:00
protected function mutateFormDataBeforeFill(array $data): array
{
$node = Node::findOrFail($data['id']);
$data['config'] = $node->getYamlConfiguration();
return $data;
}
2024-03-24 14:42:36 -04:00
protected function getSteps(): array
{
return [
];
}
2024-03-24 01:48:03 -04:00
protected function getHeaderActions(): array
{
return [
2024-05-10 17:57:42 -04:00
Actions\DeleteAction::make()
->disabled(fn (Node $node) => $node->servers()->count() > 0)
->label(fn (Node $node) => $node->servers()->count() > 0 ? 'Node Has Servers' : 'Delete'),
2024-03-24 01:48:03 -04:00
];
}
}