From 1f711d9281ddc7cedb56847d61496613a8c12e9c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 15 Nov 2023 09:15:49 +0100 Subject: [PATCH 1/2] Update version and fix webhook generation --- bootstrap/helpers/shared.php | 3 ++- config/sentry.php | 2 +- config/version.php | 2 +- versions.json | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index a11e857ce..f997e4560 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -511,7 +511,8 @@ function generateDeployWebhook($resource) return $url; } function generateGitManualWebhook($resource, $type) { - if ($resource->source_id !== 0) { + ray($resource); + if ($resource->source_id !== 0 && !is_null($resource->source_id)) { return null; } if ($resource->getMorphClass() === 'App\Models\Application') { diff --git a/config/sentry.php b/config/sentry.php index 7ded77c7b..b29827de0 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.134', + 'release' => '4.0.0-beta.135', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index e74387c47..fe6dd8010 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Wed, 15 Nov 2023 09:34:27 +0100 Subject: [PATCH 2/2] Refactor storage connection handling and project initialization --- app/Http/Livewire/Boarding/Index.php | 2 +- app/Http/Livewire/Team/Storage/Create.php | 11 ----------- app/Http/Livewire/Team/Storage/Form.php | 7 ++----- app/Jobs/DatabaseBackupJob.php | 2 +- app/Models/S3Storage.php | 7 ++++--- bootstrap/helpers/shared.php | 1 - .../views/livewire/team/storage/create.blade.php | 2 +- 7 files changed, 9 insertions(+), 23 deletions(-) diff --git a/app/Http/Livewire/Boarding/Index.php b/app/Http/Livewire/Boarding/Index.php index 1d57f9b0a..d710b9e6f 100644 --- a/app/Http/Livewire/Boarding/Index.php +++ b/app/Http/Livewire/Boarding/Index.php @@ -33,7 +33,7 @@ class Index extends Component public ?string $remoteServerUser = 'root'; public ?Server $createdServer = null; - public Collection|array $projects = []; + public Collection $projects; public ?int $selectedExistingProject = null; public ?Project $createdProject = null; diff --git a/app/Http/Livewire/Team/Storage/Create.php b/app/Http/Livewire/Team/Storage/Create.php index 4d7fb4f12..6d140d96c 100644 --- a/app/Http/Livewire/Team/Storage/Create.php +++ b/app/Http/Livewire/Team/Storage/Create.php @@ -64,21 +64,10 @@ public function submit() } $this->storage->team_id = currentTeam()->id; $this->storage->testConnection(); - $this->storage->is_usable = true; $this->storage->save(); return redirect()->route('team.storages.show', $this->storage->uuid); } catch (\Throwable $e) { return handleError($e, $this); } } - - private function test_s3_connection() - { - try { - $this->storage->testConnection(); - return $this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.'); - } catch (\Throwable $e) { - return handleError($e, $this); - } - } } diff --git a/app/Http/Livewire/Team/Storage/Form.php b/app/Http/Livewire/Team/Storage/Form.php index 573c851d7..e49dc6741 100644 --- a/app/Http/Livewire/Team/Storage/Form.php +++ b/app/Http/Livewire/Team/Storage/Form.php @@ -32,7 +32,7 @@ class Form extends Component public function test_s3_connection() { try { - $this->storage->testConnection(); + $this->storage->testConnection(shouldSave: true); return $this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.'); } catch (\Throwable $e) { return handleError($e, $this); @@ -53,10 +53,7 @@ public function submit() { $this->validate(); try { - $this->storage->testConnection(); - $this->emit('success', 'Connection is working. Tested with "ListObjectsV2" action.'); - $this->storage->save(); - $this->emit('success', 'Storage settings saved.'); + $this->test_s3_connection(); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Jobs/DatabaseBackupJob.php b/app/Jobs/DatabaseBackupJob.php index 506e7cbf0..02ddb7a5d 100644 --- a/app/Jobs/DatabaseBackupJob.php +++ b/app/Jobs/DatabaseBackupJob.php @@ -434,7 +434,7 @@ private function upload_to_s3(): void // $region = $this->s3->region; $bucket = $this->s3->bucket; $endpoint = $this->s3->endpoint; - $this->s3->testConnection(); + $this->s3->testConnection(shouldSave: true); if (data_get($this->backup, 'database_type') === 'App\Models\ServiceDatabase') { $network = $this->database->service->destination->network; } else { diff --git a/app/Models/S3Storage.php b/app/Models/S3Storage.php index 21414681c..ec18477eb 100644 --- a/app/Models/S3Storage.php +++ b/app/Models/S3Storage.php @@ -36,14 +36,13 @@ public function awsUrl() return "{$this->endpoint}/{$this->bucket}"; } - public function testConnection() + public function testConnection(bool $shouldSave = false) { try { set_s3_target($this); Storage::disk('custom-s3')->files(); $this->unusable_email_sent = false; $this->is_usable = true; - return; } catch (\Throwable $e) { $this->is_usable = false; if ($this->unusable_email_sent === false && is_transactional_emails_active()) { @@ -65,7 +64,9 @@ public function testConnection() throw $e; } finally { - $this->save(); + if ($shouldSave) { + $this->save(); + } } } } diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index f997e4560..6e3c6ca4f 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -511,7 +511,6 @@ function generateDeployWebhook($resource) return $url; } function generateGitManualWebhook($resource, $type) { - ray($resource); if ($resource->source_id !== 0 && !is_null($resource->source_id)) { return null; } diff --git a/resources/views/livewire/team/storage/create.blade.php b/resources/views/livewire/team/storage/create.blade.php index 04717779c..1e970e1ab 100644 --- a/resources/views/livewire/team/storage/create.blade.php +++ b/resources/views/livewire/team/storage/create.blade.php @@ -1,6 +1,6 @@

Create a new S3 Storage

-
S3 Storage used to save backups / files
+
S3 Storage used to save backups / files