mirror of
https://github.com/tiennm99/coolify.git
synced 2026-05-05 17:35:54 +00:00
refactor: improve cloud-init script UX and remove description field
Changes: 1. Remove description field from cloud-init scripts - Updated migration to remove description column - Updated model to remove description from fillable array 2. Redesign script name input layout - Move script name input next to checkbox (always visible) - Remove conditional rendering - input always shown - Use placeholder instead of label for cleaner look 3. Fix dropdown type error - Replace wire:change event with wire:model.live - Use updatedSelectedCloudInitScriptId() lifecycle hook - Add "disabled" attribute to placeholder option - Properly handle empty string vs null in type casting 4. Improve validation - Require both script content AND name for saving - Remove description validation rule - Add selected_cloud_init_script_id validation 5. Auto-populate name when loading saved script - When user selects saved script, auto-fill the name field 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -69,7 +69,7 @@ class ByHetzner extends Component
|
||||
|
||||
public ?string $cloud_init_script_name = null;
|
||||
|
||||
public ?string $cloud_init_script_description = null;
|
||||
public ?int $selected_cloud_init_script_id = null;
|
||||
|
||||
#[Locked]
|
||||
public Collection $saved_cloud_init_scripts;
|
||||
@@ -155,8 +155,8 @@ class ByHetzner extends Component
|
||||
'enable_ipv6' => 'required|boolean',
|
||||
'cloud_init_script' => 'nullable|string',
|
||||
'save_cloud_init_script' => 'boolean',
|
||||
'cloud_init_script_name' => 'required_if:save_cloud_init_script,true|nullable|string|max:255',
|
||||
'cloud_init_script_description' => 'nullable|string',
|
||||
'cloud_init_script_name' => 'nullable|string|max:255',
|
||||
'selected_cloud_init_script_id' => 'nullable|integer|exists:cloud_init_scripts,id',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -394,11 +394,12 @@ class ByHetzner extends Component
|
||||
ray('Image selected', $value);
|
||||
}
|
||||
|
||||
public function loadCloudInitScript(?int $scriptId)
|
||||
public function updatedSelectedCloudInitScriptId($value)
|
||||
{
|
||||
if ($scriptId) {
|
||||
$script = CloudInitScript::ownedByCurrentTeam()->findOrFail($scriptId);
|
||||
if ($value) {
|
||||
$script = CloudInitScript::ownedByCurrentTeam()->findOrFail($value);
|
||||
$this->cloud_init_script = $script->script;
|
||||
$this->cloud_init_script_name = $script->name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -496,14 +497,13 @@ class ByHetzner extends Component
|
||||
}
|
||||
|
||||
// Save cloud-init script if requested
|
||||
if ($this->save_cloud_init_script && ! empty($this->cloud_init_script)) {
|
||||
if ($this->save_cloud_init_script && ! empty($this->cloud_init_script) && ! empty($this->cloud_init_script_name)) {
|
||||
$this->authorize('create', CloudInitScript::class);
|
||||
|
||||
CloudInitScript::create([
|
||||
'team_id' => currentTeam()->id,
|
||||
'name' => $this->cloud_init_script_name,
|
||||
'script' => $this->cloud_init_script,
|
||||
'description' => $this->cloud_init_script_description,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user