diff --git a/app/Actions/Notifications/BuildProjectNotificationSettingsPayload.php b/app/Actions/Notifications/BuildProjectNotificationSettingsPayload.php new file mode 100644 index 0000000..995a4f3 --- /dev/null +++ b/app/Actions/Notifications/BuildProjectNotificationSettingsPayload.php @@ -0,0 +1,70 @@ + + */ + 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 + */ + 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', + ], + ]; + } +} diff --git a/app/Actions/Notifications/DeleteProjectNotificationAction.php b/app/Actions/Notifications/DeleteProjectNotificationAction.php new file mode 100644 index 0000000..2c8d349 --- /dev/null +++ b/app/Actions/Notifications/DeleteProjectNotificationAction.php @@ -0,0 +1,17 @@ +notificationActions() + ->whereKey($notificationAction->id) + ->firstOrFail() + ->delete(); + } +} diff --git a/app/Actions/Notifications/ListProjectNotificationActions.php b/app/Actions/Notifications/ListProjectNotificationActions.php new file mode 100644 index 0000000..6462a9b --- /dev/null +++ b/app/Actions/Notifications/ListProjectNotificationActions.php @@ -0,0 +1,18 @@ + + */ + public function handle(Project $project): Collection + { + return $project->notificationActions()->get(); + } +} diff --git a/app/Actions/Notifications/StoreProjectNotificationAction.php b/app/Actions/Notifications/StoreProjectNotificationAction.php new file mode 100644 index 0000000..17d3270 --- /dev/null +++ b/app/Actions/Notifications/StoreProjectNotificationAction.php @@ -0,0 +1,45 @@ +|null, + * delivery_url: string, + * enabled: bool, + * event_type: mixed, + * message_template?: string|null, + * name: string + * } $validated + */ + public function handle(Project $project, array $validated): NotificationAction + { + return $project->notificationActions()->create([ + 'channel' => Arr::get($validated, 'channel'), + 'channel_configuration' => Arr::get($validated, 'channel_configuration') ?? [], + 'delivery_url' => trim((string) Arr::get($validated, 'delivery_url')), + 'enabled' => (bool) Arr::get($validated, 'enabled'), + 'event_type' => Arr::get($validated, 'event_type'), + 'message_template' => $this->normalizeMessageTemplate(Arr::get($validated, 'message_template')), + 'name' => trim((string) Arr::get($validated, 'name')), + ]); + } + + private function normalizeMessageTemplate(mixed $messageTemplate): ?string + { + if (! is_string($messageTemplate)) { + return null; + } + + $messageTemplate = trim($messageTemplate); + + return $messageTemplate === '' ? null : $messageTemplate; + } +} diff --git a/app/Actions/Notifications/UpdateProjectNotificationAction.php b/app/Actions/Notifications/UpdateProjectNotificationAction.php new file mode 100644 index 0000000..59faabd --- /dev/null +++ b/app/Actions/Notifications/UpdateProjectNotificationAction.php @@ -0,0 +1,87 @@ +|null, + * delivery_url?: string|null, + * enabled?: bool, + * event_type?: mixed, + * message_template?: string|null, + * name?: string + * } $validated + */ + public function handle( + Project $project, + NotificationAction $notificationAction, + array $validated, + ): NotificationAction { + $notificationAction = $this->resolveProjectNotificationAction($project, $notificationAction); + + $attributes = []; + + if (array_key_exists('name', $validated)) { + $attributes['name'] = trim((string) Arr::get($validated, 'name')); + } + + if (array_key_exists('enabled', $validated)) { + $attributes['enabled'] = (bool) Arr::get($validated, 'enabled'); + } + + if (array_key_exists('event_type', $validated)) { + $attributes['event_type'] = Arr::get($validated, 'event_type'); + } + + if (array_key_exists('channel', $validated)) { + $attributes['channel'] = Arr::get($validated, 'channel'); + } + + if (array_key_exists('channel_configuration', $validated)) { + $attributes['channel_configuration'] = Arr::get($validated, 'channel_configuration') ?? []; + } + + if (array_key_exists('message_template', $validated)) { + $attributes['message_template'] = $this->normalizeMessageTemplate( + Arr::get($validated, 'message_template'), + ); + } + + $deliveryUrl = Arr::get($validated, 'delivery_url'); + + if (is_string($deliveryUrl) && trim($deliveryUrl) !== '') { + $attributes['delivery_url'] = trim($deliveryUrl); + } + + $notificationAction->update($attributes); + + return $notificationAction->fresh(); + } + + private function normalizeMessageTemplate(mixed $messageTemplate): ?string + { + if (! is_string($messageTemplate)) { + return null; + } + + $messageTemplate = trim($messageTemplate); + + return $messageTemplate === '' ? null : $messageTemplate; + } + + private function resolveProjectNotificationAction( + Project $project, + NotificationAction $notificationAction, + ): NotificationAction { + return $project->notificationActions() + ->whereKey($notificationAction->id) + ->firstOrFail(); + } +} diff --git a/app/Enums/NotificationChannel.php b/app/Enums/NotificationChannel.php new file mode 100644 index 0000000..a869ce7 --- /dev/null +++ b/app/Enums/NotificationChannel.php @@ -0,0 +1,31 @@ + 'Discord', + self::Webhook => 'Webhook', + }; + } + + /** + * @return array + */ + public static function options(): array + { + return array_map( + fn (self $channel): array => [ + 'label' => $channel->label(), + 'value' => $channel->value, + ], + self::cases(), + ); + } +} diff --git a/app/Enums/NotificationDeliveryStatus.php b/app/Enums/NotificationDeliveryStatus.php new file mode 100644 index 0000000..cd9ef60 --- /dev/null +++ b/app/Enums/NotificationDeliveryStatus.php @@ -0,0 +1,21 @@ + 'Failed', + self::Pending => 'Pending', + self::Retryable => 'Retryable', + self::Succeeded => 'Succeeded', + }; + } +} diff --git a/app/Enums/NotificationEventType.php b/app/Enums/NotificationEventType.php new file mode 100644 index 0000000..c9e120b --- /dev/null +++ b/app/Enums/NotificationEventType.php @@ -0,0 +1,29 @@ + 'Ticket status changed', + }; + } + + /** + * @return array + */ + public static function options(): array + { + return array_map( + fn (self $eventType): array => [ + 'label' => $eventType->label(), + 'value' => $eventType->value, + ], + self::cases(), + ); + } +} diff --git a/app/Http/Controllers/ProjectNotificationSettingsController.php b/app/Http/Controllers/ProjectNotificationSettingsController.php new file mode 100644 index 0000000..8abb088 --- /dev/null +++ b/app/Http/Controllers/ProjectNotificationSettingsController.php @@ -0,0 +1,94 @@ +abortUnlessCanManage($request, $project); + + return Inertia::render( + 'projects/settings/Notifications', + $this->buildProjectNotificationSettingsPayload->handle($project, session('status')), + ); + } + + public function store( + StoreProjectNotificationActionRequest $request, + Project $project, + ): RedirectResponse { + $this->abortUnlessCanManage($request, $project); + + $notificationAction = $this->storeProjectNotificationAction->handle($project, $request->validated()); + + return to_route('projects.settings.notifications', $project) + ->with('status', "{$notificationAction->name} notification was added."); + } + + public function update( + UpdateProjectNotificationActionRequest $request, + Project $project, + NotificationAction $notificationAction, + ): RedirectResponse { + $this->abortUnlessCanManage($request, $project); + + $notificationAction = $this->updateProjectNotificationAction->handle( + $project, + $notificationAction, + $request->validated(), + ); + + return to_route('projects.settings.notifications', $project) + ->with('status', "{$notificationAction->name} notification was updated."); + } + + public function destroy( + Request $request, + Project $project, + NotificationAction $notificationAction, + ): RedirectResponse { + $this->abortUnlessCanManage($request, $project); + + $notificationAction = $project->notificationActions() + ->whereKey($notificationAction->id) + ->firstOrFail(); + $deletedName = $notificationAction->name; + + $this->deleteProjectNotificationAction->handle($project, $notificationAction); + + return to_route('projects.settings.notifications', $project) + ->with('status', "{$deletedName} notification was deleted."); + } + + private function abortUnlessCanManage(Request $request, Project $project): void + { + abort_unless( + $this->permissionService->allows($request->user(), Permission::ProjectAdmin, $project), + 403, + ); + } +} diff --git a/app/Http/Requests/StoreProjectNotificationActionRequest.php b/app/Http/Requests/StoreProjectNotificationActionRequest.php new file mode 100644 index 0000000..ed7f636 --- /dev/null +++ b/app/Http/Requests/StoreProjectNotificationActionRequest.php @@ -0,0 +1,71 @@ +user() !== null; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'name' => ['required', 'string', 'max:255'], + 'event_type' => ['required', 'string', Rule::in($this->eventTypes())], + 'channel' => ['required', 'string', Rule::in($this->channels())], + 'enabled' => ['required', 'boolean'], + 'delivery_url' => ['required', 'string', 'max:2048', 'url'], + 'message_template' => $this->messageTemplateRules(), + ]; + } + + /** + * @return array + */ + private function channels(): array + { + return array_map( + static fn (NotificationChannel $channel): string => $channel->value, + NotificationChannel::cases(), + ); + } + + /** + * @return array + */ + private function eventTypes(): array + { + return array_map( + static fn (NotificationEventType $eventType): string => $eventType->value, + NotificationEventType::cases(), + ); + } + + /** + * @return array + */ + private function messageTemplateRules(): array + { + if ($this->input('channel') === NotificationChannel::Discord->value) { + return ['required', 'string', 'max:2000']; + } + + return ['nullable', 'string', 'max:2000']; + } +} diff --git a/app/Http/Requests/UpdateProjectNotificationActionRequest.php b/app/Http/Requests/UpdateProjectNotificationActionRequest.php new file mode 100644 index 0000000..0e281bf --- /dev/null +++ b/app/Http/Requests/UpdateProjectNotificationActionRequest.php @@ -0,0 +1,71 @@ +user() !== null; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'name' => ['required', 'string', 'max:255'], + 'event_type' => ['required', 'string', Rule::in($this->eventTypes())], + 'channel' => ['required', 'string', Rule::in($this->channels())], + 'enabled' => ['required', 'boolean'], + 'delivery_url' => ['nullable', 'string', 'max:2048', 'url'], + 'message_template' => $this->messageTemplateRules(), + ]; + } + + /** + * @return array + */ + private function channels(): array + { + return array_map( + static fn (NotificationChannel $channel): string => $channel->value, + NotificationChannel::cases(), + ); + } + + /** + * @return array + */ + private function eventTypes(): array + { + return array_map( + static fn (NotificationEventType $eventType): string => $eventType->value, + NotificationEventType::cases(), + ); + } + + /** + * @return array + */ + private function messageTemplateRules(): array + { + if ($this->input('channel') === NotificationChannel::Discord->value) { + return ['required', 'string', 'max:2000']; + } + + return ['nullable', 'string', 'max:2000']; + } +} diff --git a/app/Http/Resources/NotificationActionResource.php b/app/Http/Resources/NotificationActionResource.php new file mode 100644 index 0000000..d510ae2 --- /dev/null +++ b/app/Http/Resources/NotificationActionResource.php @@ -0,0 +1,34 @@ + + */ + public function toArray(Request $request): array + { + return [ + 'id' => $this->id, + 'project_id' => $this->project_id, + 'name' => $this->name, + 'enabled' => $this->enabled, + 'event_type' => $this->event_type->value, + 'event_type_label' => $this->event_type->label(), + 'channel' => $this->channel->value, + 'channel_label' => $this->channel->label(), + 'channel_configuration' => $this->channel_configuration ?? [], + 'has_delivery_url' => $this->resource instanceof NotificationAction && filled($this->delivery_url), + 'message_template' => $this->message_template, + 'created_at' => $this->created_at?->toISOString(), + 'updated_at' => $this->updated_at?->toISOString(), + ]; + } +} diff --git a/app/Http/Resources/NotificationDeliveryLogResource.php b/app/Http/Resources/NotificationDeliveryLogResource.php new file mode 100644 index 0000000..f485129 --- /dev/null +++ b/app/Http/Resources/NotificationDeliveryLogResource.php @@ -0,0 +1,37 @@ + + */ + public function toArray(Request $request): array + { + return [ + 'id' => $this->id, + 'notification_action_id' => $this->notification_action_id, + 'event_type' => $this->event_type->value, + 'event_type_label' => $this->event_type->label(), + 'channel' => $this->channel->value, + 'channel_label' => $this->channel->label(), + 'delivery_status' => $this->delivery_status->value, + 'delivery_status_label' => $this->delivery_status->label(), + 'attempt_count' => $this->attempt_count, + 'http_status' => $this->http_status, + 'response_excerpt' => $this->response_excerpt, + 'error_excerpt' => $this->error_excerpt, + 'payload_metadata' => $this->payload_metadata, + 'last_attempted_at' => $this->last_attempted_at?->toISOString(), + 'delivered_at' => $this->delivered_at?->toISOString(), + 'created_at' => $this->created_at?->toISOString(), + 'updated_at' => $this->updated_at?->toISOString(), + ]; + } +} diff --git a/app/Models/NotificationAction.php b/app/Models/NotificationAction.php new file mode 100644 index 0000000..3e42278 --- /dev/null +++ b/app/Models/NotificationAction.php @@ -0,0 +1,62 @@ + */ + use HasFactory; + + /** + * @return array + */ + protected function casts(): array + { + return [ + 'channel' => NotificationChannel::class, + 'channel_configuration' => 'array', + 'delivery_url' => 'encrypted', + 'enabled' => 'boolean', + 'event_type' => NotificationEventType::class, + ]; + } + + public function scopeEnabled(Builder $query): Builder + { + return $query->where('enabled', true); + } + + public function deliveryLogs(): HasMany + { + return $this->hasMany(NotificationDeliveryLog::class) + ->orderByDesc('created_at') + ->orderByDesc('id'); + } + + public function project(): BelongsTo + { + return $this->belongsTo(Project::class); + } +} diff --git a/app/Models/NotificationDeliveryLog.php b/app/Models/NotificationDeliveryLog.php new file mode 100644 index 0000000..0a24637 --- /dev/null +++ b/app/Models/NotificationDeliveryLog.php @@ -0,0 +1,53 @@ + */ + use HasFactory; + + /** + * @return array + */ + protected function casts(): array + { + return [ + 'attempt_count' => 'integer', + 'channel' => NotificationChannel::class, + 'delivered_at' => 'datetime', + 'delivery_status' => NotificationDeliveryStatus::class, + 'event_type' => NotificationEventType::class, + 'http_status' => 'integer', + 'last_attempted_at' => 'datetime', + 'payload_metadata' => 'array', + ]; + } + + public function notificationAction(): BelongsTo + { + return $this->belongsTo(NotificationAction::class); + } +} diff --git a/app/Models/Project.php b/app/Models/Project.php index 5ee7809..51cd5f5 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -88,6 +88,13 @@ class Project extends Model ->orderBy('repository_full_name'); } + public function notificationActions(): HasMany + { + return $this->hasMany(NotificationAction::class) + ->orderBy('name') + ->orderBy('id'); + } + public function tickets(): HasMany { return $this->hasMany(Ticket::class) diff --git a/database/factories/NotificationActionFactory.php b/database/factories/NotificationActionFactory.php new file mode 100644 index 0000000..59daa68 --- /dev/null +++ b/database/factories/NotificationActionFactory.php @@ -0,0 +1,58 @@ + + */ +class NotificationActionFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'channel' => NotificationChannel::Webhook, + 'channel_configuration' => [], + 'delivery_url' => 'https://hooks.'.fake()->domainName().'/kanbangit/'.fake()->uuid(), + 'enabled' => true, + 'event_type' => NotificationEventType::TicketStatusChanged, + 'message_template' => null, + 'name' => fake()->unique()->sentence(3), + 'project_id' => Project::factory(), + ]; + } + + public function discord(): static + { + return $this->state(fn (): array => [ + 'channel' => NotificationChannel::Discord, + 'delivery_url' => 'https://discord.com/api/webhooks/'.fake()->numberBetween(100_000, 999_999).'/'.fake()->uuid(), + 'message_template' => '$ticket_key moved from $status_from to $status_to by $actor_name: $url', + ]); + } + + public function disabled(): static + { + return $this->state(fn (): array => [ + 'enabled' => false, + ]); + } + + public function webhook(): static + { + return $this->state(fn (): array => [ + 'channel' => NotificationChannel::Webhook, + 'message_template' => null, + ]); + } +} diff --git a/database/factories/NotificationDeliveryLogFactory.php b/database/factories/NotificationDeliveryLogFactory.php new file mode 100644 index 0000000..23a33eb --- /dev/null +++ b/database/factories/NotificationDeliveryLogFactory.php @@ -0,0 +1,98 @@ + + */ +class NotificationDeliveryLogFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'attempt_count' => 0, + 'channel' => NotificationChannel::Webhook, + 'delivered_at' => null, + 'delivery_status' => NotificationDeliveryStatus::Pending, + 'error_excerpt' => null, + 'event_type' => NotificationEventType::TicketStatusChanged, + 'http_status' => null, + 'last_attempted_at' => null, + 'notification_action_id' => NotificationAction::factory()->webhook(), + 'payload_metadata' => [ + 'project_key' => fake()->regexify('[A-Z]{4}'), + 'ticket_key' => fake()->regexify('[A-Z]{4}-[0-9]{1,3}'), + ], + 'response_excerpt' => null, + ]; + } + + public function forNotificationAction(NotificationAction $notificationAction): static + { + return $this->for($notificationAction, 'notificationAction')->state(fn (): array => [ + 'channel' => $notificationAction->channel, + 'event_type' => $notificationAction->event_type, + ]); + } + + public function failed(): static + { + return $this->state(fn (): array => [ + 'attempt_count' => 3, + 'delivery_status' => NotificationDeliveryStatus::Failed, + 'error_excerpt' => 'Webhook returned a permanent validation error.', + 'http_status' => 422, + 'last_attempted_at' => Carbon::now(), + ]); + } + + public function pending(): static + { + return $this->state(fn (): array => [ + 'attempt_count' => 0, + 'delivered_at' => null, + 'delivery_status' => NotificationDeliveryStatus::Pending, + 'error_excerpt' => null, + 'http_status' => null, + 'last_attempted_at' => null, + 'response_excerpt' => null, + ]); + } + + public function retryable(): static + { + return $this->state(fn (): array => [ + 'attempt_count' => 1, + 'delivery_status' => NotificationDeliveryStatus::Retryable, + 'error_excerpt' => 'Connection timed out while contacting the remote endpoint.', + 'http_status' => null, + 'last_attempted_at' => Carbon::now(), + ]); + } + + public function succeeded(): static + { + return $this->state(fn (): array => [ + 'attempt_count' => 1, + 'delivered_at' => Carbon::now(), + 'delivery_status' => NotificationDeliveryStatus::Succeeded, + 'error_excerpt' => null, + 'http_status' => 204, + 'last_attempted_at' => Carbon::now(), + 'response_excerpt' => 'No Content', + ]); + } +} diff --git a/database/migrations/2026_04_20_194646_create_notification_actions_table.php b/database/migrations/2026_04_20_194646_create_notification_actions_table.php new file mode 100644 index 0000000..ad4e055 --- /dev/null +++ b/database/migrations/2026_04_20_194646_create_notification_actions_table.php @@ -0,0 +1,38 @@ +id(); + $table->foreignId('project_id')->constrained()->cascadeOnDelete(); + $table->string('name'); + $table->boolean('enabled')->default(true); + $table->string('event_type'); + $table->string('channel'); + $table->json('channel_configuration'); + $table->text('message_template')->nullable(); + $table->text('delivery_url'); + $table->timestamps(); + + $table->index(['project_id', 'event_type', 'enabled']); + $table->index(['project_id', 'channel']); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('notification_actions'); + } +}; diff --git a/database/migrations/2026_04_20_194646_create_notification_delivery_logs_table.php b/database/migrations/2026_04_20_194646_create_notification_delivery_logs_table.php new file mode 100644 index 0000000..8dd33b8 --- /dev/null +++ b/database/migrations/2026_04_20_194646_create_notification_delivery_logs_table.php @@ -0,0 +1,41 @@ +id(); + $table->foreignId('notification_action_id')->constrained()->cascadeOnDelete(); + $table->string('event_type'); + $table->string('channel'); + $table->string('delivery_status'); + $table->unsignedInteger('attempt_count')->default(0); + $table->unsignedSmallInteger('http_status')->nullable(); + $table->text('response_excerpt')->nullable(); + $table->text('error_excerpt')->nullable(); + $table->json('payload_metadata')->nullable(); + $table->timestamp('last_attempted_at')->nullable(); + $table->timestamp('delivered_at')->nullable(); + $table->timestamps(); + + $table->index(['notification_action_id', 'delivery_status']); + $table->index(['notification_action_id', 'created_at']); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('notification_delivery_logs'); + } +}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 33909c8..3ef6473 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -16,6 +16,8 @@ class DatabaseSeeder extends Seeder UserSeeder::class, UserGitConnectionSeeder::class, ProjectSeeder::class, + NotificationActionSeeder::class, + NotificationDeliveryLogSeeder::class, RepositoryConnectionSeeder::class, BoardColumnSeeder::class, ProjectTicketMetadataSeeder::class, diff --git a/database/seeders/NotificationActionSeeder.php b/database/seeders/NotificationActionSeeder.php new file mode 100644 index 0000000..8abcee3 --- /dev/null +++ b/database/seeders/NotificationActionSeeder.php @@ -0,0 +1,52 @@ +where('key', 'CORE')->first() + ?? Project::query()->orderBy('id')->first(); + + if ($project === null) { + return; + } + + $project->notificationActions()->updateOrCreate( + [ + 'name' => 'Core Status Webhook', + ], + [ + 'channel' => NotificationChannel::Webhook, + 'channel_configuration' => [], + 'delivery_url' => 'https://hooks.example.test/kanbangit/core-status', + 'enabled' => true, + 'event_type' => NotificationEventType::TicketStatusChanged, + 'message_template' => null, + ], + ); + + $project->notificationActions()->updateOrCreate( + [ + 'name' => 'Core Status Discord', + ], + [ + 'channel' => NotificationChannel::Discord, + 'channel_configuration' => [], + 'delivery_url' => 'https://discord.com/api/webhooks/123456/core-status', + 'enabled' => false, + 'event_type' => NotificationEventType::TicketStatusChanged, + 'message_template' => '$ticket_key moved from $status_from to $status_to: $url', + ], + ); + } +} diff --git a/database/seeders/NotificationDeliveryLogSeeder.php b/database/seeders/NotificationDeliveryLogSeeder.php new file mode 100644 index 0000000..b21354a --- /dev/null +++ b/database/seeders/NotificationDeliveryLogSeeder.php @@ -0,0 +1,42 @@ +orderBy('id')->first(); + + if ($notificationAction === null || $notificationAction->deliveryLogs()->exists()) { + return; + } + + NotificationDeliveryLog::factory() + ->forNotificationAction($notificationAction) + ->succeeded() + ->create([ + 'payload_metadata' => [ + 'project_key' => 'CORE', + 'ticket_key' => 'CORE-1', + ], + ]); + + NotificationDeliveryLog::factory() + ->forNotificationAction($notificationAction) + ->retryable() + ->create([ + 'payload_metadata' => [ + 'project_key' => 'CORE', + 'ticket_key' => 'CORE-2', + ], + ]); + } +} diff --git a/resources/js/pages/projects/Show.vue b/resources/js/pages/projects/Show.vue index 1591081..46d86bd 100644 --- a/resources/js/pages/projects/Show.vue +++ b/resources/js/pages/projects/Show.vue @@ -19,6 +19,7 @@ import { board as boardSettings, general as generalSettings, metadata as metadataSettings, + notifications as notificationSettings, repositories as repositorySettings, } from '@/routes/projects/settings'; import type { BreadcrumbItem, ProjectShowPageProps } from '@/types'; @@ -128,6 +129,12 @@ const projectAreas = [ + + diff --git a/resources/js/pages/projects/settings/Board.vue b/resources/js/pages/projects/settings/Board.vue index 1d24f50..e56e69c 100644 --- a/resources/js/pages/projects/settings/Board.vue +++ b/resources/js/pages/projects/settings/Board.vue @@ -19,6 +19,8 @@ import { index, show } from '@/routes/projects/index'; import { board as boardSettings, general as generalSettings, + metadata as metadataSettings, + notifications as notificationSettings, repositories as repositorySettings, } from '@/routes/projects/settings'; import type { BreadcrumbItem, ProjectBoardSettingsPageProps } from '@/types'; @@ -105,12 +107,24 @@ const statusAllowsTarget = ( + + + + diff --git a/resources/js/pages/projects/settings/General.vue b/resources/js/pages/projects/settings/General.vue index 3ae452a..f309dd8 100644 --- a/resources/js/pages/projects/settings/General.vue +++ b/resources/js/pages/projects/settings/General.vue @@ -20,6 +20,7 @@ import { board as boardSettings, general as generalSettings, metadata as metadataSettings, + notifications as notificationSettings, repositories as repositorySettings, } from '@/routes/projects/settings'; import type { BreadcrumbItem, ProjectGeneralSettingsPageProps } from '@/types'; @@ -98,6 +99,12 @@ const submitDelete = (): void => { + + diff --git a/resources/js/pages/projects/settings/Metadata.vue b/resources/js/pages/projects/settings/Metadata.vue index 3df2aa9..5b0274c 100644 --- a/resources/js/pages/projects/settings/Metadata.vue +++ b/resources/js/pages/projects/settings/Metadata.vue @@ -20,6 +20,7 @@ import { board as boardSettings, general as generalSettings, metadata as metadataSettings, + notifications as notificationSettings, repositories as repositorySettings, } from '@/routes/projects/settings'; import type { @@ -90,6 +91,12 @@ const replacementTicketTypes = (ticketTypeId: number) => + + diff --git a/resources/js/pages/projects/settings/Notifications.vue b/resources/js/pages/projects/settings/Notifications.vue new file mode 100644 index 0000000..45fba9c --- /dev/null +++ b/resources/js/pages/projects/settings/Notifications.vue @@ -0,0 +1,640 @@ + + +