From bc79e142e5098d1642b3be12b9c488e35644cfe3 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 12 Jun 2023 22:02:10 +0200 Subject: [PATCH] fix --- app/Models/Team.php | 9 +++ resources/js/components/MagicBar.vue | 76 +++++++++---------- resources/views/components/git-icon.blade.php | 12 +-- .../livewire/source/github/change.blade.php | 71 +++++++++-------- .../livewire/source/github/create.blade.php | 30 ++++---- resources/views/source/all.blade.php | 31 ++++++++ resources/views/source/new.blade.php | 5 +- routes/web.php | 14 ++++ 8 files changed, 157 insertions(+), 91 deletions(-) create mode 100644 resources/views/source/all.blade.php diff --git a/app/Models/Team.php b/app/Models/Team.php index 64bdf3c1c..562c3e1aa 100644 --- a/app/Models/Team.php +++ b/app/Models/Team.php @@ -68,4 +68,13 @@ class Team extends BaseModel implements SendsDiscord, SendsEmail { return $this->hasMany(TeamInvitation::class); } + public function sources() + { + $sources = collect([]); + $github_apps = $this->hasMany(GithubApp::class)->whereisPublic(false)->get(); + $gitlab_apps = $this->hasMany(GitlabApp::class)->whereisPublic(false)->get(); + // $bitbucket_apps = $this->hasMany(BitbucketApp::class)->get(); + $sources = $sources->merge($github_apps)->merge($gitlab_apps); + return $sources; + } } diff --git a/resources/js/components/MagicBar.vue b/resources/js/components/MagicBar.vue index 45123b942..95cbe9592 100644 --- a/resources/js/components/MagicBar.vue +++ b/resources/js/components/MagicBar.vue @@ -238,7 +238,6 @@ const possibleSequences = { }, } const magicActions = [{ - id: 0, name: 'Deploy: Public Repository', tags: 'git,github,public', icon: 'git', @@ -246,7 +245,6 @@ const magicActions = [{ sequence: ['main', 'server', 'destination', 'project', 'environment', 'redirect'] }, { - id: 1, name: 'Deploy: Private Repository (with GitHub Apps)', tags: 'git,github,private', icon: 'git', @@ -254,7 +252,6 @@ const magicActions = [{ sequence: ['main', 'server', 'destination', 'project', 'environment', 'redirect'] }, { - id: 2, name: 'Deploy: Private Repository (with Deploy Key)', tags: 'git,github,private,deploy,key', icon: 'git', @@ -262,15 +259,6 @@ const magicActions = [{ sequence: ['main', 'server', 'destination', 'project', 'environment', 'redirect'] }, { - id: 3, - name: 'Create: Private Key', - tags: 'private,key,ssh,new,create', - icon: 'key', - new: true, - sequence: ['main', 'redirect'] -}, -{ - id: 4, name: 'Create: Server', tags: 'server,ssh,new,create', icon: 'server', @@ -278,7 +266,20 @@ const magicActions = [{ sequence: ['main', 'redirect'] }, { - id: 5, + name: 'Create: Source', + tags: 'source,git,gitlab,github,bitbucket,gitea,new,create', + icon: 'git', + new: true, + sequence: ['main', 'redirect'] +}, +{ + name: 'Create: Private Key', + tags: 'private,key,ssh,new,create', + icon: 'key', + new: true, + sequence: ['main', 'redirect'] +}, +{ name: 'Create: Destination', tags: 'destination,docker,network,new,create', icon: 'destination', @@ -286,55 +287,46 @@ const magicActions = [{ sequence: ['main', 'server', 'redirect'] }, { - id: 6, name: 'Goto: Dashboard', icon: 'goto', sequence: ['main', 'redirect'] }, { - id: 7, name: 'Goto: Servers', icon: 'goto', sequence: ['main', 'redirect'] }, { - id: 8, name: 'Goto: Projects', icon: 'goto', sequence: ['main', 'redirect'] }, { - id: 9, name: 'Goto: Settings', icon: 'goto', sequence: ['main', 'redirect'] }, { - id: 10, name: 'Goto: Command Center', icon: 'goto', sequence: ['main', 'redirect'] }, { - id: 11, name: 'Goto: Notifications', icon: 'goto', sequence: ['main', 'redirect'] }, { - id: 12, name: 'Goto: Profile', icon: 'goto', sequence: ['main', 'redirect'] }, { - id: 13, name: 'Goto: Teams', icon: 'goto', sequence: ['main', 'redirect'] }, { - id: 14, name: 'Goto: Switch Teams', icon: 'goto', sequence: ['main', 'redirect'] @@ -427,12 +419,14 @@ async function goThroughSequence(actionId) { nextSequence = sequence[sequenceState.value.currentActionIndex + 1] sequenceState.value.sequence = sequence sequenceState.value.selected = { - main: id + // main: id + main: actionId + 1 } } else { currentSequence = sequenceState.value.sequence[sequenceState.value.currentActionIndex] nextSequence = sequenceState.value.sequence[sequenceState.value.currentActionIndex + 1] - let selectedId = sequenceState.value.magicActions[actionId].id + // let selectedId = sequenceState.value.magicActions[actionId].id + let selectedId = actionId + 1 if (uuidSelector.includes(currentSequence)) { selectedId = sequenceState.value.magicActions[actionId].uuid } @@ -490,59 +484,61 @@ async function redirect() { const selected = sequenceState.value.selected const { main, destination = null, project = null, environment = null, server = null } = selected switch (main) { - case 0: + case 1: targetUrl.pathname = `/project/${project}/${environment}/new` targetUrl.searchParams.append('type', 'public') targetUrl.searchParams.append('destination', destination) break; - case 1: + case 2: targetUrl.pathname = `/project/${project}/${environment}/new` targetUrl.searchParams.append('type', 'private-gh-app') targetUrl.searchParams.append('destination', destination) break; - case 2: + case 3: targetUrl.pathname = `/project/${project}/${environment}/new` targetUrl.searchParams.append('type', 'private-deploy-key') targetUrl.searchParams.append('destination', destination) break; - case 3: - targetUrl.pathname = `/private-key/new` - break; case 4: targetUrl.pathname = `/server/new` break; case 5: + targetUrl.pathname = `/source/new` + break; + case 6: + targetUrl.pathname = `/private-key/new` + break; + case 7: targetUrl.pathname = `/destination/new` targetUrl.searchParams.append('server', server) break; - case 6: + case 8: targetUrl.pathname = `/` break; - case 7: + case 9: targetUrl.pathname = `/servers` break; - case 8: + case 10: targetUrl.pathname = `/projects` break; - case 9: + case 11: targetUrl.pathname = `/settings` break; - case 10: + case 12: targetUrl.pathname = `/command-center` break; - case 11: + case 13: targetUrl.pathname = `/profile/team/notifications` break; - case 12: + case 14: targetUrl.pathname = `/profile` break; - case 13: + case 15: targetUrl.pathname = `/profile/team` break; - case 14: + case 16: targetUrl.pathname = `/profile/team` break; - } window.location.href = targetUrl; } diff --git a/resources/views/components/git-icon.blade.php b/resources/views/components/git-icon.blade.php index 46fbb7e72..47ae8f8bb 100644 --- a/resources/views/components/git-icon.blade.php +++ b/resources/views/components/git-icon.blade.php @@ -3,21 +3,21 @@ ]) @if ($git === 'App\Models\GithubApp') - + merge(['class' => 'w-6 h-6']) }} viewBox="0 0 24 24" + stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> @elseif($git === 'App\Models\GitlabApp') - + merge(['class' => 'w-6 h-6']) }} viewBox="0 0 24 24" + stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> @else - + merge(['class' => 'w-6 h-6']) }} viewBox="0 0 24 24" + stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> diff --git a/resources/views/livewire/source/github/change.blade.php b/resources/views/livewire/source/github/change.blade.php index 107db1cf1..f10c9861d 100644 --- a/resources/views/livewire/source/github/change.blade.php +++ b/resources/views/livewire/source/github/change.blade.php @@ -3,7 +3,7 @@

GitHub App

-
+
@if ($github_app->app_id) Save @@ -29,9 +29,10 @@ @endif
+
Your Private GitHub App for private repositories.
@if (!$github_app->app_id) -
-
You need to register a GitHub App before using this source!
+
+
You need to register a GitHub App before using this source:
Register a GitHub Application @@ -39,36 +40,46 @@
@endif - +
+ + @if ($github_app->app_id) + + @else + + @endif +
+
+ + +
+
+ @if ($github_app->html_url === 'https://github.com') + + + @else + + + @endif +
@if ($github_app->app_id) - - @else - - @endif - - - @if ($github_app->html_url === 'https://github.com') - - - @else - - - @endif - - @if ($github_app->app_id) - - - - - - - @else - -
- +
+ +
+
+ + + +
+ + @else + @endif @if (!$github_app->app_id) diff --git a/resources/views/livewire/source/github/create.blade.php b/resources/views/livewire/source/github/create.blade.php index 1a59bcfff..f54825f79 100644 --- a/resources/views/livewire/source/github/create.blade.php +++ b/resources/views/livewire/source/github/create.blade.php @@ -1,18 +1,22 @@
-
-
-

General

- - Save - + +

GitHub App

+
+ + +
+

Advanced

+
+ + +
+
+ +
- - -

Advanced

- - - - + + Create New Source +
diff --git a/resources/views/source/all.blade.php b/resources/views/source/all.blade.php new file mode 100644 index 000000000..6ca3fca40 --- /dev/null +++ b/resources/views/source/all.blade.php @@ -0,0 +1,31 @@ + +

Sources

+
All Sources
+
+ @forelse ($sources as $source) + @if ($source->getMorphClass() === 'App\Models\GithubApp') + + +
+
{{ $source->name }}
+
+
+ @endif + @if ($source->getMorphClass() === 'App\Models\GitlabApp') + + +
+
{{ $source->name }}
+
+
+ @endif + @empty +
+
No sources found.
+ +
+ @endforelse +
+
diff --git a/resources/views/source/new.blade.php b/resources/views/source/new.blade.php index 8a9f99102..81968cee4 100644 --- a/resources/views/source/new.blade.php +++ b/resources/views/source/new.blade.php @@ -1,7 +1,8 @@

New Source

+
Add source providers for your applications.
- diff --git a/routes/web.php b/routes/web.php index 4a4185386..9ea0a9f5d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -10,6 +10,7 @@ use App\Models\PrivateKey; use App\Models\StandaloneDocker; use App\Models\SwarmDocker; use App\Models\GithubApp; +use App\Models\GitlabApp; use App\Models\Server; use App\Models\User; use App\Notifications\TransactionalEmails\ResetPasswordEmail; @@ -92,6 +93,12 @@ Route::middleware(['auth'])->group(function () { Route::middleware(['auth'])->group(function () { Route::get('/source/new', fn () => view('source.new'))->name('source.new'); + Route::get('/sources', function () { + $sources = session('currentTeam')->sources(); + return view('source.all', [ + 'sources' => $sources, + ]); + })->name('source.all'); Route::get('/source/github/{github_app_uuid}', function (Request $request) { $github_app = GithubApp::where('uuid', request()->github_app_uuid)->first(); $name = Str::of(Str::kebab($github_app->name))->start('coolify-'); @@ -109,6 +116,13 @@ Route::middleware(['auth'])->group(function () { 'installation_url' => $installation_url, ]); })->name('source.github.show'); + + Route::get('/source/gitlab/{gitlab_app_uuid}', function (Request $request) { + $gitlab_app = GitlabApp::where('uuid', request()->gitlab_app_uuid)->first(); + return view('source.gitlab.show', [ + 'gitlab_app' => $gitlab_app, + ]); + })->name('source.gitlab.show'); }); Route::middleware(['auth'])->group(function () {