mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 05:14:46 +02:00

* Add `Egg` `copy from` for Process & Install Script * Add builtin `ReplicateAction` * Use `CopyFrom` for less duplicated code * Hide label & add tooltip to `ReplicateAction` * use `iconButton()` instead of `hiddenLabel()` * use `iconButton()` for every Actions * Use our translation instead * Copy egg_variables aswell * remove `get()` Co-authored-by: Boy132 <Boy132@users.noreply.github.com> --------- Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
70 lines
1.9 KiB
PHP
70 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Components\Forms\Fields;
|
|
|
|
use App\Models\Egg;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Set;
|
|
use Livewire\Component;
|
|
|
|
class CopyFrom extends Select
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->label(trans('admin/egg.copy_from'));
|
|
|
|
$this->placeholder(trans('admin/egg.none'));
|
|
|
|
$this->live();
|
|
}
|
|
|
|
public function process(): static
|
|
{
|
|
$this->helperText(trans('admin/egg.copy_from_help'));
|
|
|
|
$this->relationship('configFrom', 'name', ignoreRecord: true);
|
|
|
|
$this->afterStateUpdated(function ($state, Set $set) {
|
|
$set('copy_script_from', $state);
|
|
if ($state === null) {
|
|
$set('config_stop', '');
|
|
$set('config_startup', '{}');
|
|
$set('config_files', '{}');
|
|
$set('config_logs', '{}');
|
|
|
|
return;
|
|
}
|
|
$egg = Egg::find($state);
|
|
$set('config_stop', $egg->config_stop);
|
|
$set('config_startup', $egg->config_startup);
|
|
$set('config_files', $egg->config_files);
|
|
$set('config_logs', $egg->config_logs);
|
|
});
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function script(): static
|
|
{
|
|
$this->relationship('scriptFrom', 'name', ignoreRecord: true);
|
|
|
|
$this->afterStateUpdated(function ($state, Set $set, Component $livewire) {
|
|
if ($state === null) {
|
|
$set('script_container', 'ghcr.io/pelican-eggs/installers:debian');
|
|
$set('script_entry', 'bash');
|
|
$livewire->dispatch('setContent', content: '');
|
|
|
|
return;
|
|
}
|
|
$egg = Egg::find($state);
|
|
$set('script_container', $egg->script_container);
|
|
$set('script_entry', $egg->script_entry);
|
|
$livewire->dispatch('setContent', content: $egg->script_install);
|
|
});
|
|
|
|
return $this;
|
|
}
|
|
}
|