From db92dc3636c355f5c9d2758bc30994bc599d58f1 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 9 May 2023 10:01:57 +0200 Subject: [PATCH] feat: delete gh app --- app/Http/Livewire/Source/Github/Change.php | 45 +++---------------- .../views/livewire/destination/form.blade.php | 2 +- .../livewire/private-key/change.blade.php | 2 +- .../project/application/deploy.blade.php | 2 +- .../environment-variable/show.blade.php | 2 +- .../application/storages/show.blade.php | 2 +- .../views/livewire/server/form.blade.php | 2 +- .../livewire/source/github/change.blade.php | 6 ++- 8 files changed, 17 insertions(+), 46 deletions(-) diff --git a/app/Http/Livewire/Source/Github/Change.php b/app/Http/Livewire/Source/Github/Change.php index 430ea9999..f7267d80b 100644 --- a/app/Http/Livewire/Source/Github/Change.php +++ b/app/Http/Livewire/Source/Github/Change.php @@ -58,46 +58,13 @@ public function mount() $this->parameters = getParameters(); $this->is_system_wide = $this->github_app->is_system_wide; } - public function createGithubApp() + public function delete() { - $settings = InstanceSettings::first(); - $fqdn = $settings->fqdn; - if (!$fqdn) { - $fqdn = $this->host; + try { + $this->github_app->delete(); + redirect()->route('dashboard'); + } catch (\Exception $e) { + return generalErrorHandlerLivewire($e, $this); } - if ($this->github_app->organization) { - $url = 'organizations/' . $this->github_app->organization . '/settings/apps/new'; - } else { - $url = 'settings/apps/new'; - } - $name = Str::kebab('coolify' . $this->github_app->name); - $data = [ - "name" => $name, - "url" => $fqdn, - "hook_attributes" => [ - "url" => "$fqdn/webhooks/github/events" - ], - "redirect_url" => "$fqdn/webhooks/github", - "callback_url" => [ - "$fqdn/login/github/app", - ], - "public" => false, - "request_oauth_on_install" => false, - "setup_url" => "$fqdn/webhooks/github/install?source_id=" . $this->github_app->uuid, - "setup_on_update" => true, - "default_permissions" => [ - "contents" => 'read', - "metadata" => 'read', - "pull_requests" => 'read', - "emails" => 'read' - ], - "default_events" => ['pull_request', 'push'] - ]; - $response = Http::asForm()->post("{$this->github_app->html_url}/{$url}?state={$this->github_app->uuid}", [ - 'id' => 'manifest', - 'name' => 'manifest', - 'data' => json_encode($data), - ]); - dd($response); } } diff --git a/resources/views/livewire/destination/form.blade.php b/resources/views/livewire/destination/form.blade.php index 0dbf68aa0..57f1fadde 100644 --- a/resources/views/livewire/destination/form.blade.php +++ b/resources/views/livewire/destination/form.blade.php @@ -10,7 +10,7 @@ Submit - + Delete diff --git a/resources/views/livewire/private-key/change.blade.php b/resources/views/livewire/private-key/change.blade.php index cec141247..931a82c86 100644 --- a/resources/views/livewire/private-key/change.blade.php +++ b/resources/views/livewire/private-key/change.blade.php @@ -7,7 +7,7 @@ Submit - + Delete diff --git a/resources/views/livewire/project/application/deploy.blade.php b/resources/views/livewire/project/application/deploy.blade.php index 03be4d2db..fcb0ca71b 100644 --- a/resources/views/livewire/project/application/deploy.blade.php +++ b/resources/views/livewire/project/application/deploy.blade.php @@ -8,7 +8,7 @@ Start Start (no cache) @endif - + Delete @if ($application->status === 'running') diff --git a/resources/views/livewire/project/application/environment-variable/show.blade.php b/resources/views/livewire/project/application/environment-variable/show.blade.php index 6e38b9881..7d5f9b971 100644 --- a/resources/views/livewire/project/application/environment-variable/show.blade.php +++ b/resources/views/livewire/project/application/environment-variable/show.blade.php @@ -10,7 +10,7 @@ Update - + Delete diff --git a/resources/views/livewire/project/application/storages/show.blade.php b/resources/views/livewire/project/application/storages/show.blade.php index 1f234e330..fa2138f94 100644 --- a/resources/views/livewire/project/application/storages/show.blade.php +++ b/resources/views/livewire/project/application/storages/show.blade.php @@ -7,7 +7,7 @@ Update - + Delete diff --git a/resources/views/livewire/server/form.blade.php b/resources/views/livewire/server/form.blade.php index a48159a4b..ddf6b5564 100644 --- a/resources/views/livewire/server/form.blade.php +++ b/resources/views/livewire/server/form.blade.php @@ -22,7 +22,7 @@ Submit Check Server Install Docker - + Delete diff --git a/resources/views/livewire/source/github/change.blade.php b/resources/views/livewire/source/github/change.blade.php index 652efd8f3..3e73a115b 100644 --- a/resources/views/livewire/source/github/change.blade.php +++ b/resources/views/livewire/source/github/change.blade.php @@ -1,4 +1,5 @@ -
+
+

Change Github App

@@ -23,6 +24,9 @@ @else
Save + + Delete +
@endif