From fda8e9139646769f0188be911b4d4072d0b396f4 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Tue, 21 Jul 2026 20:59:09 +0200 Subject: [PATCH] fix(ui): simplify GitLab source setup view Use the red incomplete-setup alert like GitHub, keep name + OAuth credentials front-and-center, and tuck GitLab URL / API / SSH / system wide options into an Advanced accordion for self-hosted users. --- app/Livewire/Source/Gitlab/Change.php | 15 ++ .../livewire/source/gitlab/change.blade.php | 129 +++++++++++++----- tests/Feature/GitlabSourceChangeViewTest.php | 59 ++++++++ 3 files changed, 166 insertions(+), 37 deletions(-) create mode 100644 tests/Feature/GitlabSourceChangeViewTest.php diff --git a/app/Livewire/Source/Gitlab/Change.php b/app/Livewire/Source/Gitlab/Change.php index 0cb36a5f8..2e36a1e1f 100644 --- a/app/Livewire/Source/Gitlab/Change.php +++ b/app/Livewire/Source/Gitlab/Change.php @@ -59,6 +59,8 @@ class Change extends Component public ?string $oauthState = null; + private bool $shouldDeriveApiUrlAfterHtmlUrlUpdate = false; + protected function rules(): array { return [ @@ -76,6 +78,19 @@ class Change extends Component ]; } + public function updatingHtmlUrl(): void + { + $this->shouldDeriveApiUrlAfterHtmlUrlUpdate = blank($this->apiUrl) + || $this->apiUrl === rtrim($this->htmlUrl, '/').'/api/v4'; + } + + public function updatedHtmlUrl(): void + { + if ($this->shouldDeriveApiUrlAfterHtmlUrlUpdate) { + $this->apiUrl = rtrim($this->htmlUrl, '/').'/api/v4'; + } + } + public function mount() { try { diff --git a/resources/views/livewire/source/gitlab/change.blade.php b/resources/views/livewire/source/gitlab/change.blade.php index 3072f457d..830a9a0a7 100644 --- a/resources/views/livewire/source/gitlab/change.blade.php +++ b/resources/views/livewire/source/gitlab/change.blade.php @@ -29,28 +29,67 @@
-
- - -
-
- - -
@if (!isCloud())
-
+ @if ($isSystemWide) + + System-wide GitLab Apps are shared across all teams on this Coolify instance. This means any team + can use this GitLab App to deploy applications from your repositories. For better security and + isolation, it's recommended to create team-specific GitLab Apps instead. + + @endif @endif

OAuth Credentials

+
+
+ +
+
+
+ + +
+
+ + +
+
+ + + @foreach ($privateKeys as $key) + + @endforeach + +
+
+
+
+
+

Webhook

@@ -63,19 +102,6 @@ helper="Set this same token in your GitLab webhook's 'Secret token' field." />
-

SSH Key (Optional)

-
- Only needed if you prefer SSH-based git clone over HTTPS OAuth token. -
-
- - - @foreach ($privateKeys as $key) - - @endforeach - -
- @if ($applications->count() > 0)

Applications Using This Source

@@ -112,13 +138,13 @@
Connect your GitLab instance to deploy private repositories.
-
+
- Complete the setup below to connect this GitLab source. + You must complete this step before you can use this source!
@@ -140,24 +166,53 @@

Step 2: Enter the credentials

-
- - -
- -
- - + +
+
+ +
+
+
+ + +
+ +
+ + +
+ @if (!isCloud()) +
+ +
+ @endif +
+
+
- @if (!isCloud()) - - @endif + Save Credentials diff --git a/tests/Feature/GitlabSourceChangeViewTest.php b/tests/Feature/GitlabSourceChangeViewTest.php new file mode 100644 index 000000000..b99875e6b --- /dev/null +++ b/tests/Feature/GitlabSourceChangeViewTest.php @@ -0,0 +1,59 @@ +team = Team::factory()->create(); + $this->user = User::factory()->create(); + $this->team->members()->attach($this->user->id, ['role' => 'owner']); + + $this->actingAs($this->user); + session(['currentTeam' => $this->team]); + + InstanceSettings::forceCreate([ + 'id' => 0, + 'fqdn' => null, + 'public_ipv4' => null, + 'public_ipv6' => null, + ]); + + $this->gitlabApp = GitlabApp::create([ + 'name' => 'Self-hosted GitLab', + 'api_url' => 'https://gitlab.com/api/v4', + 'html_url' => 'https://gitlab.com', + 'custom_user' => 'git', + 'custom_port' => 22, + 'team_id' => $this->team->id, + 'is_system_wide' => false, + 'is_public' => false, + ]); +}); + +describe('GitLab source setup view', function () { + test('shows red incomplete-setup alert and keeps advanced fields collapsed', function () { + Livewire::withQueryParams(['gitlab_app_uuid' => $this->gitlabApp->uuid]) + ->test(Change::class) + ->assertSee('You must complete this step before you can use this source!') + ->assertSeeHtml('alert-error') + ->assertSee('Advanced / Self-hosted') + ->assertSee('Application ID') + ->assertSee('Application Secret') + ->assertSee('Save Credentials') + ->assertDontSee('alert-warning'); + }); + + test('derives api url when gitlab url changes', function () { + Livewire::withQueryParams(['gitlab_app_uuid' => $this->gitlabApp->uuid]) + ->test(Change::class) + ->set('htmlUrl', 'https://gitlab.example.com') + ->assertSet('apiUrl', 'https://gitlab.example.com/api/v4'); + }); +});