- Applied `Confirmation` trait to multiple Livewire components for unified confirmation handling. - Replaced inline confirmation modals with `requireConfirmation` method for streamlined interaction. - Updated button styles and added reusable confirmation prompts for delete/detach actions. - Enhanced `AppRoleService` and `ConnectionProviderService` to support deletion with confirmation.
90 lines
2.7 KiB
PHP
90 lines
2.7 KiB
PHP
<?php
|
|
|
|
use App\Concerns\Confirmation;
|
|
use App\Concerns\HandlesOperations;
|
|
use App\Data\Ui\TableHeader;
|
|
use App\Services\ConnectionProviderService;
|
|
use Livewire\Attributes\Computed;
|
|
use Livewire\Component;
|
|
use Livewire\WithPagination;
|
|
use Spatie\LaravelData\Attributes\DataCollectionOf;
|
|
use Spatie\LaravelData\DataCollection;
|
|
|
|
new class extends Component {
|
|
use WithPagination, HandlesOperations, Confirmation;
|
|
|
|
protected ConnectionProviderService $service;
|
|
|
|
#[DataCollectionOf(TableHeader::class)]
|
|
public DataCollection $headers;
|
|
|
|
public string $selectedProvider = '';
|
|
|
|
public function boot(ConnectionProviderService $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',),
|
|
], DataCollection::class);
|
|
}
|
|
|
|
#[Computed]
|
|
public function getAllProviders()
|
|
{
|
|
return $this->service->getAll();
|
|
}
|
|
|
|
public function edit(string $providerSlug): void
|
|
{
|
|
$this->redirectRoute('apps.connectionProviders.edit', ['slug' => $providerSlug]);
|
|
}
|
|
|
|
public function delete(): void
|
|
{
|
|
$this->attempt(
|
|
action: function () {
|
|
$this->service->delete($this->selectedProvider);
|
|
$this->selectedProvider = '';
|
|
}
|
|
);
|
|
}
|
|
|
|
public function showModal(string $providerSlug): void
|
|
{
|
|
$this->selectedProvider = $providerSlug;
|
|
$this->requireConfirmation('delete', description: 'This will delete all the connected apps of this provider.');
|
|
}
|
|
};
|
|
?>
|
|
|
|
<div>
|
|
<x-shared.card title="Connection Providers" class="pb-2">
|
|
<x-slot:actions>
|
|
<x-mary-button :link="route('apps.connectionProviders.create')" wire:navigate icon="lucide.plus">Add
|
|
Provider
|
|
</x-mary-button>
|
|
</x-slot:actions>
|
|
<x-mary-table :headers="$headers->toArray()" :rows="$this->getAllProviders->items()" with-pagination>
|
|
@scope('actions', $row)
|
|
<div class="flex">
|
|
<x-mary-button icon="lucide.edit" wire:click="edit('{{$row->slug}}')" spinner="edit('{{$row->slug}}')"
|
|
class="mr-2 btn-sm btn-circle text-gray-500"/>
|
|
<x-mary-button icon="lucide.trash" wire:click="showModal('{{$row->slug}}')"
|
|
spinner="showModal('{{$row->slug}}')"
|
|
variant="danger"
|
|
class="btn-sm btn-error btn-circle btn-soft"/>
|
|
</div>
|
|
@endscope
|
|
</x-mary-table>
|
|
</x-shared.card>
|
|
</div>
|