delete application + init confirm modal
This commit is contained in:
parent
3e9e1e94d6
commit
cc1c08786f
@ -62,6 +62,15 @@ public function forceRebuild()
|
||||
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"]);
|
||||
|
@ -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 @@ public function submit()
|
||||
'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 @@ public function submit()
|
||||
$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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,10 @@ protected static function booted()
|
||||
'application_id' => $application->id,
|
||||
]);
|
||||
});
|
||||
static::deleting(function ($application) {
|
||||
$application->settings()->delete();
|
||||
$application->persistentStorages()->delete();
|
||||
});
|
||||
}
|
||||
|
||||
protected $fillable = [
|
||||
|
@ -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" />
|
||||
|
24
resources/views/components/confirm-modal.blade.php
Normal file
24
resources/views/components/confirm-modal.blade.php
Normal file
@ -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>
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user