diff --git a/app/Http/Livewire/PrivateKey/Change.php b/app/Http/Livewire/PrivateKey/Change.php index 28b18494e..568ed7486 100644 --- a/app/Http/Livewire/PrivateKey/Change.php +++ b/app/Http/Livewire/PrivateKey/Change.php @@ -22,9 +22,12 @@ class Change extends Component public function delete() { try { - PrivateKey::where('uuid', $this->private_key_uuid)->delete(); - session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get(); - redirect()->route('dashboard'); + if ($this->private_key->isEmpty()) { + $this->private_key->delete(); + session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get(); + return redirect()->route('private-key.all'); + } + $this->emit('error', 'This private key is in use and cannot be deleted. Please delete all servers, applications, and GitHub/GitLab apps that use this private key before deleting it.'); } catch (\Exception $e) { return general_error_handler(err: $e, that: $this); } diff --git a/app/Http/Livewire/Server/Form.php b/app/Http/Livewire/Server/Form.php index 39aff9b95..f1435ea28 100644 --- a/app/Http/Livewire/Server/Form.php +++ b/app/Http/Livewire/Server/Form.php @@ -65,7 +65,7 @@ public function delete() return; } $this->server->delete(); - redirect()->route('dashboard'); + redirect()->route('server.all'); } public function submit() { diff --git a/app/Http/Livewire/Source/Github/Change.php b/app/Http/Livewire/Source/Github/Change.php index b2bb9f75a..7908b179c 100644 --- a/app/Http/Livewire/Source/Github/Change.php +++ b/app/Http/Livewire/Source/Github/Change.php @@ -57,7 +57,7 @@ public function delete() { try { $this->github_app->delete(); - redirect()->route('dashboard'); + redirect()->route('source.all'); } catch (\Exception $e) { return general_error_handler(err: $e, that: $this); } diff --git a/app/Models/PrivateKey.php b/app/Models/PrivateKey.php index 39a6a8c8c..337e1555a 100644 --- a/app/Models/PrivateKey.php +++ b/app/Models/PrivateKey.php @@ -16,9 +16,27 @@ static public function ownedByCurrentTeam(array $select = ['*']) $selectArray = collect($select)->concat(['id']); return PrivateKey::whereTeamId(session('currentTeam')->id)->where('id', '>', 0)->select($selectArray->all()); } - + public function applications() + { + return $this->hasMany(Application::class); + } + public function githubApps() + { + return $this->hasMany(GithubApp::class); + } + public function gitlabApps() + { + return $this->hasMany(GitlabApp::class); + } public function servers() { return $this->hasMany(Server::class); } + public function isEmpty() + { + if ($this->servers()->count() === 0 && $this->applications()->count() === 0 && $this->githubApps()->count() === 0 && $this->gitlabApps()->count() === 0) { + return true; + } + return false; + } } diff --git a/config/toaster.php b/config/toaster.php index 805927210..4dd1244b1 100644 --- a/config/toaster.php +++ b/config/toaster.php @@ -30,7 +30,7 @@ * * Minimum: 3000 (in milliseconds) */ - 'duration' => 3000, + 'duration' => 5000, /** * The horizontal position of each toast. diff --git a/config/version.php b/config/version.php index b6e6dc283..b71f4008d 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ -

Danger Zone

+

Danger Zone

Woah. I hope you know what are you doing.
-

Delete Application

+

Delete Application

This will stop your containers, delete all related data, etc. Beware! There is no coming back!
diff --git a/resources/views/livewire/server/form.blade.php b/resources/views/livewire/server/form.blade.php index 1ac087e2a..403c5f1eb 100644 --- a/resources/views/livewire/server/form.blade.php +++ b/resources/views/livewire/server/form.blade.php @@ -5,11 +5,7 @@

General

Save - @if ($server->id !== 0 || isDev()) - - Delete - - @endif +
@@ -72,4 +68,15 @@
@endisset +

Danger Zone

+
Woah. I hope you know what are you doing.
+

Delete Server

+
This will remove this server from Coolify. Beware! There is no coming + back! +
+ @if ($server->id !== 0 || isDev()) + + Delete + + @endif
diff --git a/versions.json b/versions.json index b1f7e7129..046a89010 100644 --- a/versions.json +++ b/versions.json @@ -4,7 +4,7 @@ "version": "3.12.32" }, "v4": { - "version": "4.0.0-nightly.24" + "version": "4.0.0-nightly.25" } } } \ No newline at end of file