From f952553c7694d34a7954e08ffd975c2ad9c3ecb7 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 26 Apr 2024 14:09:54 +0200 Subject: [PATCH] fix: move s3 storages to separate view --- app/Livewire/{Team => }/Storage/Create.php | 4 ++-- app/Livewire/{Team => }/Storage/Form.php | 4 ++-- app/Livewire/{Team => }/Storage/Index.php | 4 ++-- app/Livewire/Storage/Show.php | 22 +++++++++++++++++++ app/Livewire/Team/Storage/Show.php | 2 +- app/Models/S3Storage.php | 2 +- resources/views/components/navbar.blade.php | 14 ++++++++++++ .../views/components/team/navbar.blade.php | 6 +---- .../{team => }/storage/create.blade.php | 0 .../{team => }/storage/form.blade.php | 8 +++---- .../{team => }/storage/index.blade.php | 10 ++++----- .../views/livewire/storage/show.blade.php | 3 +++ .../livewire/team/storage/show.blade.php | 6 ----- .../livewire/team/storages/create.blade.php | 3 --- routes/web.php | 12 +++++----- 15 files changed, 61 insertions(+), 39 deletions(-) rename app/Livewire/{Team => }/Storage/Create.php (95%) rename app/Livewire/{Team => }/Storage/Form.php (94%) rename app/Livewire/{Team => }/Storage/Index.php (73%) create mode 100644 app/Livewire/Storage/Show.php rename resources/views/livewire/{team => }/storage/create.blade.php (100%) rename resources/views/livewire/{team => }/storage/form.blade.php (87%) rename resources/views/livewire/{team => }/storage/index.blade.php (71%) create mode 100644 resources/views/livewire/storage/show.blade.php delete mode 100644 resources/views/livewire/team/storage/show.blade.php delete mode 100644 resources/views/livewire/team/storages/create.blade.php diff --git a/app/Livewire/Team/Storage/Create.php b/app/Livewire/Storage/Create.php similarity index 95% rename from app/Livewire/Team/Storage/Create.php rename to app/Livewire/Storage/Create.php index a25fc9821..d1af807d5 100644 --- a/app/Livewire/Team/Storage/Create.php +++ b/app/Livewire/Storage/Create.php @@ -1,6 +1,6 @@ storage->team_id = currentTeam()->id; $this->storage->testConnection(); $this->storage->save(); - return redirect()->route('team.storage.show', $this->storage->uuid); + return redirect()->route('storage.show', $this->storage->uuid); } catch (\Throwable $e) { $this->dispatch('error', 'Failed to create storage.', $e->getMessage()); // return handleError($e, $this); diff --git a/app/Livewire/Team/Storage/Form.php b/app/Livewire/Storage/Form.php similarity index 94% rename from app/Livewire/Team/Storage/Form.php rename to app/Livewire/Storage/Form.php index 1fd0d470b..79c1f0c30 100644 --- a/app/Livewire/Team/Storage/Form.php +++ b/app/Livewire/Storage/Form.php @@ -1,6 +1,6 @@ storage->delete(); - return redirect()->route('team.storage.index'); + return redirect()->route('storage.index'); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Team/Storage/Index.php b/app/Livewire/Storage/Index.php similarity index 73% rename from app/Livewire/Team/Storage/Index.php rename to app/Livewire/Storage/Index.php index c15834564..f071a0af0 100644 --- a/app/Livewire/Team/Storage/Index.php +++ b/app/Livewire/Storage/Index.php @@ -1,6 +1,6 @@ storage = S3Storage::ownedByCurrentTeam()->whereUuid(request()->storage_uuid)->first(); + if (!$this->storage) { + abort(404); + } + } + public function render() + { + return view('livewire.storage.show'); + } +} diff --git a/app/Livewire/Team/Storage/Show.php b/app/Livewire/Team/Storage/Show.php index 6fbb6034f..ab2acbbb9 100644 --- a/app/Livewire/Team/Storage/Show.php +++ b/app/Livewire/Team/Storage/Show.php @@ -17,6 +17,6 @@ public function mount() } public function render() { - return view('livewire.team.storage.show'); + return view('livewire.storage.show'); } } diff --git a/app/Models/S3Storage.php b/app/Models/S3Storage.php index 9d60ce491..dc0b93466 100644 --- a/app/Models/S3Storage.php +++ b/app/Models/S3Storage.php @@ -48,7 +48,7 @@ public function testConnection(bool $shouldSave = false) if ($this->unusable_email_sent === false && is_transactional_emails_active()) { $mail = new MailMessage(); $mail->subject('Coolify: S3 Storage Connection Error'); - $mail->view('emails.s3-connection-error', ['name' => $this->name, 'reason' => $e->getMessage(), 'url' => route('team.storage.show', ['storage_uuid' => $this->uuid])]); + $mail->view('emails.s3-connection-error', ['name' => $this->name, 'reason' => $e->getMessage(), 'url' => route('storage.show', ['storage_uuid' => $this->uuid])]); $users = collect([]); $members = $this->team->members()->get(); foreach ($members as $user) { diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index 96af53d3f..0eebffd1e 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -156,6 +156,20 @@ class="{{ request()->is('destination*') ? 'menu-item-active menu-item' : 'menu-i Destinations +
  • + + + + + + + + + S3 Storages + +
  • -
    Team settings & shared environment variables.
    +
    Team wide configurations.