- Added `ConnectionProviderData`, `NavItemData`, and `NavSubItemData` DTOs for structured data handling. - Implemented CRUD operations for `ConnectionProviderService`, including transaction-safe create, update, and delete methods. - Introduced Livewire components for ConnectionProvider list, edit, and create pages with dynamic and reusable UI elements. - Refactored routes to consolidate paths under the `apps` prefix and updated navigation to dynamically include new sections for providers. - Enhanced sidebar with structured submenu for ConnectionProviders and Settings using dynamic collections. - Updated existing Create and Edit templates to use consistent route naming and validation handling. - Replaced hardcoded navigation items with dynamically generated structures leveraging the `NavItemData` collection.
61 lines
1.8 KiB
PHP
61 lines
1.8 KiB
PHP
<?php
|
|
|
|
use App\Concerns\HandlesOperations;
|
|
use App\Data\ConnectedApp\StoreConnectionProviderRequestData;
|
|
use App\Livewire\Forms\StoreConnectionProviderForm;
|
|
use App\Services\ConnectionProviderService;
|
|
use Laravel\Mcp\Server\Attributes\Title;
|
|
use Livewire\Component;
|
|
use Mary\Traits\Toast;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
new
|
|
#[Title('Edit Connection Provider')]
|
|
class extends Component {
|
|
use HandlesOperations;
|
|
|
|
public StoreConnectionProviderForm $form;
|
|
public string $currentProviderSlug;
|
|
|
|
protected ConnectionProviderService $service;
|
|
|
|
public function boot(ConnectionProviderService $service): void
|
|
{
|
|
$this->service = $service;
|
|
}
|
|
|
|
public function mount(string $slug): void
|
|
{
|
|
$this->currentProviderSlug = $slug;
|
|
$data = $this->service->getProvider($slug);
|
|
$this->form->set($data);
|
|
}
|
|
|
|
public function save(): void
|
|
{
|
|
$this->attempt(
|
|
action: function () {
|
|
$this->form->validate();
|
|
$data = new StoreConnectionProviderRequestData(
|
|
name: $this->form->name,
|
|
);
|
|
$this->service->update($this->currentProviderSlug, $data);
|
|
$this->redirectRoute('apps.connectionProviders.index', navigate: true);
|
|
},
|
|
);
|
|
}
|
|
};
|
|
?>
|
|
|
|
<div>
|
|
<x-shared.card :title="__('Edit Connection Provider')">
|
|
<x-mary-form :no-separator="true" class="p-4" wire:submit="save">
|
|
<x-mary-input wire:model.blur="form.name" :label="__('Name')"/>
|
|
<x-slot:actions>
|
|
<x-mary-button class="btn-primary" type="submit" spinner="save" wire:click="form.store"
|
|
:label="__('Save')"/>
|
|
</x-slot:actions>
|
|
</x-mary-form>
|
|
</x-shared.card>
|
|
</div>
|