Implement webhook inspector

This commit is contained in:
2026-08-04 17:09:39 +02:00
parent b021836c14
commit 75d8b25b64
57 changed files with 5110 additions and 230 deletions
+69
View File
@@ -0,0 +1,69 @@
<?php
namespace App\Livewire;
use App\Actions\CreatePrivateEndpointAction;
use App\Models\User;
use App\Models\WebhookEndpoint;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;
use Illuminate\View\View;
use Livewire\Component;
class Dashboard extends Component
{
public string $endpointName = '';
public bool $showCreateForm = false;
public function saveEndpoint(CreatePrivateEndpointAction $createPrivateEndpoint): void
{
$this->validate([
'endpointName' => ['nullable', 'string', 'max:100'],
]);
/** @var User $user */
$user = Auth::user();
$endpoint = $createPrivateEndpoint->handle($user, $this->endpointName ?: null);
$this->redirect($endpoint->publicUrl(), navigate: true);
}
public function deleteEndpoint(string $endpointId): void
{
$endpoint = $this->ownedEndpoint($endpointId);
Gate::authorize('delete', $endpoint);
$endpoint->delete();
}
public function toggleEndpoint(string $endpointId): void
{
$endpoint = $this->ownedEndpoint($endpointId);
Gate::authorize('update', $endpoint);
$endpoint->update(['is_active' => ! $endpoint->is_active]);
}
public function render(): View
{
/** @var User $user */
$user = Auth::user();
return view('livewire.dashboard', [
'endpoints' => WebhookEndpoint::query()
->ownedBy($user)
->withCount('requests')
->latest()
->get(),
]);
}
private function ownedEndpoint(string $endpointId): WebhookEndpoint
{
/** @var User $user */
$user = Auth::user();
return WebhookEndpoint::query()
->ownedBy($user)
->findOrFail($endpointId);
}
}