Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

delete application + init confirm modal

Andras Bacsaicc1c08786fc1
diff --git a/app/Http/Livewire/Project/Application/Deploy.php b/app/Http/Livewire/Project/Application/Deploy.php
index a8696e506e..830018c6bc 100644
--- a/app/Http/Livewire/Project/Application/Deploy.php
+++ b/app/Http/Livewire/Project/Application/Deploy.php
@@ -62,6 +62,15 @@ class Deploy extends Component
return $this->redirectToDeployment();
}
+ public function delete()
+ {
+ $this->kill();
+ Application::find($this->applicationId)->delete();
+ return redirect()->route('project.resources', [
+ 'project_uuid' => $this->parameters['project_uuid'],
+ 'environment_name' => $this->parameters['environment_name']
+ ]);
+ }
public function stop()
{
runRemoteCommandSync($this->destination->server, ["docker stop -t 0 {$this->application->uuid} >/dev/null 2>&1"]);
diff --git a/app/Http/Livewire/Project/New/PublicGitRepository.php b/app/Http/Livewire/Project/New/PublicGitRepository.php
index 8433ee829f..d7ac933e85 100644
--- a/app/Http/Livewire/Project/New/PublicGitRepository.php
+++ b/app/Http/Livewire/Project/New/PublicGitRepository.php
@@ -24,11 +24,14 @@ class PublicGitRepository extends Component
public $swarm_docker;
public $chosenServer;
public $chosenDestination;
+ public $is_static = false;
public $github_apps;
public $gitlab_apps;
protected $rules = [
'public_repository_url' => 'required|url',
+ 'port' => 'required|numeric',
+ 'is_static' => 'required|boolean',
];
public function mount()
{
@@ -65,13 +68,14 @@ class PublicGitRepository extends Component
'description' => fake()->sentence(),
'team_id' => session('currentTeam')->id,
]);
+ $environment = $project->environments->first();
$application_init = [
'name' => fake()->words(2, true),
'git_repository' => $git_repository,
'git_branch' => $git_branch,
'build_pack' => 'nixpacks',
'ports_exposes' => $this->port,
- 'environment_id' => $project->environments->first()->id,
+ 'environment_id' => $environment->id,
'destination_id' => $this->chosenDestination->id,
'destination_type' => $this->chosenDestination->getMorphClass(),
];
@@ -82,9 +86,13 @@ class PublicGitRepository extends Component
$application_init['source_id'] = GitlabApp::where('name', 'Public GitLab')->first()->id;
$application_init['source_type'] = GitlabApp::class;
} elseif ($git_host == 'bitbucket.org') {
- // $application_init['source_id'] = GithubApp::where('name', 'Public Bitbucket')->first()->id;
- // $application_init['source_type'] = GithubApp::class;
}
- Application::create($application_init);
+ $application = Application::create($application_init);
+
+ return redirect()->route('project.application.configuration', [
+ 'project_uuid' => $project->uuid,
+ 'environment_name' => $environment->name,
+ 'application_uuid' => $application->uuid,
+ ]);
}
}
diff --git a/app/Models/Application.php b/app/Models/Application.php
index fdcbeb5be6..5f402e1637 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -14,6 +14,10 @@ class Application extends BaseModel
'application_id' => $application->id,
]);
});
+ static::deleting(function ($application) {
+ $application->settings()->delete();
+ $application->persistentStorages()->delete();
+ });
}
protected $fillable = [
diff --git a/resources/views/components/applications/navbar.blade.php b/resources/views/components/applications/navbar.blade.php
index ef6716338b..f4fb53b461 100644
--- a/resources/views/components/applications/navbar.blade.php
+++ b/resources/views/components/applications/navbar.blade.php
@@ -1,4 +1,4 @@
-<nav class="flex gap-4 py-2 bg-gray-100">
+<nav class="flex gap-4 py-2">
<a href="{{ route('project.application.configuration', Route::current()->parameters()) }}">Configuration</a>
<a href="{{ route('project.application.deployments', Route::current()->parameters()) }}">Deployments</a>
<livewire:project.application.deploy :applicationId="$applicationId" />
diff --git a/resources/views/components/confirm-modal.blade.php b/resources/views/components/confirm-modal.blade.php
new file mode 100644
index 0000000000..d259961232
--- /dev/null
+++ b/resources/views/components/confirm-modal.blade.php
@@ -0,0 +1,24 @@
+<script>
+ document.addEventListener('alpine:init', () => {
+ Alpine.data('confirmModal', () => ({
+ open: false,
+ message: 'Are you sure?',
+ toggleConfirmModal(customMessage) {
+ this.message = customMessage
+ this.open = !this.open
+ },
+ }))
+ })
+</script>
+<div x-cloak x-show="open" x-transition.opacity class="fixed inset-0 bg-slate-900/75"></div>
+<div x-cloak x-show="open" x-transition class="fixed inset-0 z-50 flex pt-10">
+ <div @click.away="open = false" class="w-screen h-20 max-w-xl mx-auto bg-black rounded-lg">
+ <div class="flex flex-col items-center justify-center h-full">
+ <div class="pb-5 text-white" x-text="message"></div>
+ <div>
+ <button x-on:click="open = false">Cancel</button>
+ <button x-on:click="$dispatch('confirm')">Confirm</button>
+ </div>
+ </div>
+ </div>
+</div>
diff --git a/resources/views/components/layout.blade.php b/resources/views/components/layout.blade.php
index 118c9ce50d..a16775485a 100644
--- a/resources/views/components/layout.blade.php
+++ b/resources/views/components/layout.blade.php
@@ -15,12 +15,13 @@
@livewireStyles
</head>
-<body>
+<body x-data="confirmModal" x-on:keydown.escape="toggleConfirmModal">
<x-navbar />
<main>
{{ $slot }}
</main>
+ <x-confirm-modal />
@livewireScripts
</body>
diff --git a/resources/views/livewire/project/application/deploy.blade.php b/resources/views/livewire/project/application/deploy.blade.php
index 24eb06471d..a01660a54a 100644
--- a/resources/views/livewire/project/application/deploy.blade.php
+++ b/resources/views/livewire/project/application/deploy.blade.php
@@ -1,4 +1,7 @@
<div>
+ <button class="bg-red-500" @confirm.window="$wire.delete()"
+ x-on:click="toggleConfirmModal('Are you sure you would like to delete this application?')">
+ Delete</button>
@if ($application->status === 'running')
<button wire:click='start'>Restart</button>
<button wire:click='forceRebuild'>Force Rebuild</button>
diff --git a/resources/views/livewire/project/new/public-git-repository.blade.php b/resources/views/livewire/project/new/public-git-repository.blade.php
index 934ba1e180..fcaa3f3993 100644
--- a/resources/views/livewire/project/new/public-git-repository.blade.php
+++ b/resources/views/livewire/project/new/public-git-repository.blade.php
@@ -21,6 +21,7 @@
@isset($chosenDestination)
<form wire:submit.prevent='submit'>
<x-form-input id="public_repository_url" label="Repository URL" />
+ <x-form-input type="checkbox" id="is_static" label="Static Site?" />
<x-form-input type="number" id="port" label="Port" />
<button type="submit">
Submit