This commit is contained in:
Andras Bacsai 2023-06-19 09:44:39 +02:00
parent 716c9aa860
commit 7bcbfc13b0
10 changed files with 45 additions and 17 deletions

View File

@ -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);
}

View File

@ -65,7 +65,7 @@ public function delete()
return;
}
$this->server->delete();
redirect()->route('dashboard');
redirect()->route('server.all');
}
public function submit()
{

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -30,7 +30,7 @@
*
* Minimum: 3000 (in milliseconds)
*/
'duration' => 3000,
'duration' => 5000,
/**
* The horizontal position of each toast.

View File

@ -1,3 +1,3 @@
<?php
return '4.0.0-nightly.24';
return '4.0.0-nightly.25';

View File

@ -326,7 +326,7 @@ const magicActions = [{
{
id: 11,
name: 'Goto: Private Keys',
tags: 'destination,docker,network,new,create',
tags: 'destination,docker,network,new,create,ssh,private,key',
icon: 'goto',
sequence: ['main', 'redirect']
},

View File

@ -1,9 +1,9 @@
<div x-data="{ deleteApplication: false }">
<x-naked-modal show="deleteApplication" title="Delete Application"
message='This application will be deleted. It is not reversible. <br>Please think again.' />
<h2>Danger Zone</h2>
<h3>Danger Zone</h3>
<div class="">Woah. I hope you know what are you doing.</div>
<h3 class="pt-4">Delete Application</h3>
<h4 class="pt-4">Delete Application</h4>
<div class="pb-4">This will stop your containers, delete all related data, etc. Beware! There is no coming
back!
</div>

View File

@ -5,11 +5,7 @@
<div class="flex gap-2">
<h2>General</h2>
<x-forms.button type="submit">Save</x-forms.button>
@if ($server->id !== 0 || isDev())
<x-forms.button x-on:click.prevent="deleteServer = true">
Delete
</x-forms.button>
@endif
</div>
<div class="flex flex-col gap-2 ">
<div class="flex flex-col w-full gap-2 lg:flex-row">
@ -72,4 +68,15 @@
</div>
@endisset
</form>
<h3>Danger Zone</h3>
<div class="">Woah. I hope you know what are you doing.</div>
<h4 class="pt-4">Delete Server</h4>
<div class="pb-4">This will remove this server from Coolify. Beware! There is no coming
back!
</div>
@if ($server->id !== 0 || isDev())
<x-forms.button x-on:click.prevent="deleteServer = true">
Delete
</x-forms.button>
@endif
</div>

View File

@ -4,7 +4,7 @@
"version": "3.12.32"
},
"v4": {
"version": "4.0.0-nightly.24"
"version": "4.0.0-nightly.25"
}
}
}