- 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.
99 lines
2.9 KiB
PHP
99 lines
2.9 KiB
PHP
<?php
|
|
|
|
use App\Concerns\HandlesOperations;
|
|
use App\Data\Ui\ConnectedApps\ConnectedAppData;
|
|
use App\Data\Ui\TableHeader;
|
|
use App\Services\ConnectedAppService;
|
|
use Livewire\Attributes\Computed;
|
|
use Livewire\Attributes\Title;
|
|
use Livewire\Component;
|
|
use Livewire\WithPagination;
|
|
use Spatie\LaravelData\Attributes\DataCollectionOf;
|
|
use Spatie\LaravelData\DataCollection;
|
|
use Spatie\LaravelData\PaginatedDataCollection;
|
|
|
|
new
|
|
#[Title('Connected Apps')]
|
|
class extends Component {
|
|
use WithPagination, HandlesOperations;
|
|
|
|
protected ConnectedAppService $service;
|
|
|
|
#[DataCollectionOf(TableHeader::class)]
|
|
public DataCollection $headers;
|
|
|
|
public function boot(ConnectedAppService $service): void
|
|
{
|
|
$this->service = $service;
|
|
}
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->initTableHeaders();
|
|
}
|
|
|
|
private function initTableHeaders(): void
|
|
{
|
|
$this->headers = TableHeader::collect([
|
|
new TableHeader(key: 'name', label: 'Name',),
|
|
new TableHeader(key: 'provider', label: 'Provider'),
|
|
new TableHeader(key: 'protocol', label: 'Protocol'),
|
|
new TableHeader(key: 'status', label: 'Status'),
|
|
], DataCollection::class);
|
|
}
|
|
|
|
/**
|
|
* @return PaginatedDataCollection<int, ConnectedAppData>
|
|
*/
|
|
#[Computed]
|
|
public function getConnectedApps(): PaginatedDataCollection
|
|
{
|
|
return $this->service->getAll();
|
|
}
|
|
|
|
public function edit(int $appId): void
|
|
{
|
|
$this->redirectRoute('apps.edit', ['id' => $appId], navigate: true);
|
|
}
|
|
|
|
public function delete(int $appId): void
|
|
{
|
|
$this->attempt(
|
|
action: fn() => $this->service->delete($appId),
|
|
successMessage: 'The app has been deleted !'
|
|
);
|
|
}
|
|
};
|
|
?>
|
|
|
|
<div>
|
|
<x-shared.card title="Connected Apps" class="pb-2">
|
|
<x-slot:actions>
|
|
<x-mary-button :link="route('apps.create')" wire:navigate icon="lucide.plus">Add App
|
|
</x-mary-button>
|
|
</x-slot:actions>
|
|
<x-mary-table
|
|
:headers="$headers->toArray()"
|
|
:rows="$this->getConnectedApps->items()"
|
|
with-pagination
|
|
>
|
|
@scope('cell_protocol', $row)
|
|
{{$row->protocol->name}}
|
|
@endscope
|
|
|
|
@scope('cell_status', $row)
|
|
<x-shared.connection-status :status="$row->status"/>
|
|
@endscope
|
|
@scope('actions', $row)
|
|
<div class="flex">
|
|
<x-mary-button icon="lucide.edit" wire:click="edit({{$row->id}})" spinner="edit({{$row->id}})"
|
|
class="mr-2 btn-sm text-gray-500"/>
|
|
<x-mary-button icon="lucide.trash" wire:click="delete({{$row->id}})" spinner="delete({{$row->id}})"
|
|
variant="danger"
|
|
class="btn-sm btn-error btn-soft"/>
|
|
</div>
|
|
@endscope
|
|
</x-mary-table>
|
|
</x-shared.card>
|
|
</div>
|