diff --git a/app/Enums/Users/GitlabUsersEnum.php b/app/Enums/Users/GitlabUsersEnum.php deleted file mode 100644 index 43cbcdd..0000000 --- a/app/Enums/Users/GitlabUsersEnum.php +++ /dev/null @@ -1,24 +0,0 @@ -name => "Default", - ]; -} diff --git a/app/Http/Controllers/Bo/TicketController.php b/app/Http/Controllers/Bo/TicketController.php index 6b8fed4..0470e35 100644 --- a/app/Http/Controllers/Bo/TicketController.php +++ b/app/Http/Controllers/Bo/TicketController.php @@ -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
", $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"));