feat: ✨ add to-dispatch label for bug tickets and change default assignee label

This commit is contained in:
Corentin Huet 2026-02-06 16:12:01 +01:00
parent 9b2248b146
commit a43c6c95b1
2 changed files with 14 additions and 30 deletions

View file

@ -1,24 +0,0 @@
<?php
namespace App\Enums\Users;
use App\Traits\Enums\BaseEnum;
enum GitlabUsersEnum: int
{
use BaseEnum;
/**
* Each user is associated to his ID on gitlab.
*
* 24 is Nicolas Demangeat
*/
case default = 24;
/**
* Optionnal labels definition
*/
private const LABELS = [
self::default->name => "Default",
];
}

View file

@ -13,6 +13,8 @@ use Illuminate\Http\Request;
use App\Jobs\UpdateIssueLabels;
use App\Lib\Helpers\ToolboxHelper;
use Illuminate\Support\Facades\DB;
use App\Enums\Tickets\TicketStatusEnum;
use App\Enums\Tickets\TicketTypeEnum;
use App\Events\NotifySubscriptions;
use App\Events\TicketStatusChanged;
use App\Enums\Users\GitlabUsersEnum;
@ -750,18 +752,19 @@ class TicketController extends Controller
*/
public function createGitlabIssue(Ticket $ticket)
{
$userGitlabId = auth()->user()->gitlab_id;
$gitlabRepoId = $ticket->site->gitlab_project_id;
$description = \sprintf("%s<br>", $ticket->text);
$cLabel = match ($ticket->type) {
TicketTypeEnum::bug => 'c-bug',
TicketTypeEnum::bug => 'c-bug,to-dispatch',
TicketTypeEnum::evolution => 'c-feature',
TicketTypeEnum::newsletter => 'c-feature,g-to-estimate',
};
$assigneeId = match ($ticket->type) {
TicketTypeEnum::bug => GitlabUsersEnum::default->value,
TicketTypeEnum::bug => $userGitlabId,
TicketTypeEnum::evolution,
TicketTypeEnum::newsletter => $ticket->site->projectManager?->gitlab_id ?? GitlabUsersEnum::default->value
TicketTypeEnum::newsletter => $ticket->site->projectManager?->gitlab_id
};
try {
@ -772,7 +775,7 @@ class TicketController extends Controller
}
}
$issue = GitLab::issues()->create($gitlabRepoId, [
$data = [
'title' => sprintf(
'ts-%s : %s',
$ticket->id,
@ -783,8 +786,13 @@ class TicketController extends Controller
'c-support',
$cLabel
]),
'assignee_id' => $assigneeId,
]);
];
if ($assigneeId) {
$data['assignee_id'] = $assigneeId;
}
$issue = GitLab::issues()->create($gitlabRepoId, $data);
} catch (\Exception $e) {
\report($e);
return back()->with('error', \trans("Une erreur est survenue"));