chore: svg + new validations

This commit is contained in:
David Buday 2024-11-18 09:00:07 +00:00
parent 65eb856916
commit 063d420db2
3 changed files with 48 additions and 27 deletions

View file

@ -2,24 +2,26 @@
namespace App\Livewire\Images\Registry;
use Livewire\Attributes\Validate;
use App\Models\DockerRegistry;
use Livewire\Component;
class Create extends Component
{
#[Validate('required|string|max:255')]
public string $name = '';
public string $type = 'docker_hub';
public ?string $url = null;
public ?string $username = null;
public ?string $token = null;
protected $rules = [
'name' => 'required|string|max:255',
'type' => 'required|string',
'url' => 'nullable|string|max:255',
'username' => 'nullable|string|max:255',
'token' => 'nullable|string',
];
#[Validate('required|string')]
public string $type = 'docker_hub';
#[Validate('nullable|string|max:255')]
public ?string $url = null;
#[Validate('nullable|string|max:255')]
public ?string $username = null;
#[Validate('nullable|string')]
public ?string $token = null;
public function getRegistryTypesProperty()
{
@ -28,6 +30,7 @@ class Create extends Component
public function submit()
{
// Validation is automatically applied based on attributes
$this->validate();
DockerRegistry::create([
@ -47,4 +50,4 @@ class Create extends Component
{
return view('livewire.images.registry.create');
}
}
};

View file

@ -3,24 +3,27 @@
namespace App\Livewire\Images\Registry;
use App\Models\DockerRegistry;
use Livewire\Attributes\Validate;
use Livewire\Component;
class Show extends Component
{
public DockerRegistry $registry;
public string $name = '';
public string $type = '';
public ?string $url = null;
public ?string $username = null;
public ?string $token = null;
protected $rules = [
'name' => 'required|string|max:255',
'type' => 'required|string',
'url' => 'nullable|string|max:255',
'username' => 'nullable|string|max:255',
'token' => 'nullable|string',
];
#[Validate('required|string|max:255')]
public string $name = '';
#[Validate('required|string')]
public string $type = '';
#[Validate('nullable|string|max:255')]
public ?string $url = null;
#[Validate('nullable|string|max:255')]
public ?string $username = null;
#[Validate('nullable|string')]
public ?string $token = null;
public function mount(DockerRegistry $registry)
{
@ -39,6 +42,7 @@ class Show extends Component
public function updateRegistry()
{
// Validation is automatically applied based on attributes
$this->validate();
$this->registry->update([
@ -58,7 +62,7 @@ class Show extends Component
$this->registry->applications()
->update([
'docker_registry_id' => null,
'docker_use_custom_registry' => false
'docker_use_custom_registry' => false,
]);
$this->registry->delete();
@ -79,4 +83,4 @@ class Show extends Component
|| $this->username !== $this->registry->username
|| $this->token !== $this->registry->token;
}
}
};

View file

@ -150,7 +150,21 @@
class="{{ request()->is('images*') ? 'menu-item-active menu-item' : 'menu-item' }}"
href="{{ route('images.images.index') }}" <svg xmlns="http://www.w3.org/2000/svg"
class="icon" viewBox="0 0 24 24">
<!-- docker svg -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" width="24"
height="24" stroke-width="2">
<path d="M6 17.6l-2 -1.1v-2.5"></path>
<path d="M4 10v-2.5l2 -1.1"></path>
<path d="M10 4.1l2 -1.1l2 1.1"></path>
<path d="M18 6.4l2 1.1v2.5"></path>
<path d="M20 14v2.5l-2 1.12"></path>
<path d="M14 19.9l-2 1.1l-2 -1.1"></path>
<path d="M12 12l2 -1.1"></path>
<path d="M18 8.6l2 -1.1"></path>
<path d="M12 12l0 2.5"></path>
<path d="M12 18.5l0 2.5"></path>
<path d="M12 12l-2 -1.12"></path>
<path d="M6 8.6l-2 -1.1"></path>
</svg>
Images
</a>