Add project notification settings UI

This commit is contained in:
Eric Peters
2026-04-20 22:29:46 +02:00
parent e4762f8e32
commit ee15efe739
17 changed files with 1374 additions and 0 deletions
@@ -0,0 +1,70 @@
<?php
namespace App\Actions\Notifications;
use App\Enums\NotificationChannel;
use App\Enums\NotificationEventType;
use App\Http\Resources\NotificationActionResource;
use App\Http\Resources\ProjectResource;
use App\Models\Project;
class BuildProjectNotificationSettingsPayload
{
public function __construct(
private readonly ListProjectNotificationActions $listProjectNotificationActions,
) {}
/**
* @return array<string, mixed>
*/
public function handle(Project $project, mixed $status = null): array
{
return [
'channelOptions' => NotificationChannel::options(),
'eventTypeOptions' => NotificationEventType::options(),
'notificationActions' => NotificationActionResource::collection(
$this->listProjectNotificationActions->handle($project),
)->resolve(),
'project' => ProjectResource::make($project)->resolve(),
'status' => $status,
'templateVariables' => $this->templateVariables(),
];
}
/**
* @return array<int, array{description: string, value: string}>
*/
private function templateVariables(): array
{
return [
[
'description' => 'Absolute ticket URL for the status change event.',
'value' => '$url',
],
[
'description' => 'Project ticket key such as CORE-42.',
'value' => '$ticket_key',
],
[
'description' => 'Ticket title from the changed ticket.',
'value' => '$ticket_title',
],
[
'description' => 'Project name that owns the ticket.',
'value' => '$project_name',
],
[
'description' => 'Origin status label before the move.',
'value' => '$status_from',
],
[
'description' => 'Destination status label after the move.',
'value' => '$status_to',
],
[
'description' => 'Actor name when the move has a known user.',
'value' => '$actor_name',
],
];
}
}