delete application + init confirm modal
This commit is contained in:
parent
3e9e1e94d6
commit
cc1c08786f
@ -62,6 +62,15 @@ class Deploy extends Component
|
|||||||
return $this->redirectToDeployment();
|
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()
|
public function stop()
|
||||||
{
|
{
|
||||||
runRemoteCommandSync($this->destination->server, ["docker stop -t 0 {$this->application->uuid} >/dev/null 2>&1"]);
|
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 $swarm_docker;
|
||||||
public $chosenServer;
|
public $chosenServer;
|
||||||
public $chosenDestination;
|
public $chosenDestination;
|
||||||
|
public $is_static = false;
|
||||||
public $github_apps;
|
public $github_apps;
|
||||||
public $gitlab_apps;
|
public $gitlab_apps;
|
||||||
|
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'public_repository_url' => 'required|url',
|
'public_repository_url' => 'required|url',
|
||||||
|
'port' => 'required|numeric',
|
||||||
|
'is_static' => 'required|boolean',
|
||||||
];
|
];
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
@ -65,13 +68,14 @@ class PublicGitRepository extends Component
|
|||||||
'description' => fake()->sentence(),
|
'description' => fake()->sentence(),
|
||||||
'team_id' => session('currentTeam')->id,
|
'team_id' => session('currentTeam')->id,
|
||||||
]);
|
]);
|
||||||
|
$environment = $project->environments->first();
|
||||||
$application_init = [
|
$application_init = [
|
||||||
'name' => fake()->words(2, true),
|
'name' => fake()->words(2, true),
|
||||||
'git_repository' => $git_repository,
|
'git_repository' => $git_repository,
|
||||||
'git_branch' => $git_branch,
|
'git_branch' => $git_branch,
|
||||||
'build_pack' => 'nixpacks',
|
'build_pack' => 'nixpacks',
|
||||||
'ports_exposes' => $this->port,
|
'ports_exposes' => $this->port,
|
||||||
'environment_id' => $project->environments->first()->id,
|
'environment_id' => $environment->id,
|
||||||
'destination_id' => $this->chosenDestination->id,
|
'destination_id' => $this->chosenDestination->id,
|
||||||
'destination_type' => $this->chosenDestination->getMorphClass(),
|
'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_id'] = GitlabApp::where('name', 'Public GitLab')->first()->id;
|
||||||
$application_init['source_type'] = GitlabApp::class;
|
$application_init['source_type'] = GitlabApp::class;
|
||||||
} elseif ($git_host == 'bitbucket.org') {
|
} 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 @@ class Application extends BaseModel
|
|||||||
'application_id' => $application->id,
|
'application_id' => $application->id,
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
static::deleting(function ($application) {
|
||||||
|
$application->settings()->delete();
|
||||||
|
$application->persistentStorages()->delete();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $fillable = [
|
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.configuration', Route::current()->parameters()) }}">Configuration</a>
|
||||||
<a href="{{ route('project.application.deployments', Route::current()->parameters()) }}">Deployments</a>
|
<a href="{{ route('project.application.deployments', Route::current()->parameters()) }}">Deployments</a>
|
||||||
<livewire:project.application.deploy :applicationId="$applicationId" />
|
<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
|
@livewireStyles
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body x-data="confirmModal" x-on:keydown.escape="toggleConfirmModal">
|
||||||
<x-navbar />
|
<x-navbar />
|
||||||
<main>
|
<main>
|
||||||
{{ $slot }}
|
{{ $slot }}
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
<x-confirm-modal />
|
||||||
@livewireScripts
|
@livewireScripts
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<div>
|
<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')
|
@if ($application->status === 'running')
|
||||||
<button wire:click='start'>Restart</button>
|
<button wire:click='start'>Restart</button>
|
||||||
<button wire:click='forceRebuild'>Force Rebuild</button>
|
<button wire:click='forceRebuild'>Force Rebuild</button>
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
@isset($chosenDestination)
|
@isset($chosenDestination)
|
||||||
<form wire:submit.prevent='submit'>
|
<form wire:submit.prevent='submit'>
|
||||||
<x-form-input id="public_repository_url" label="Repository URL" />
|
<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" />
|
<x-form-input type="number" id="port" label="Port" />
|
||||||
<button type="submit">
|
<button type="submit">
|
||||||
Submit
|
Submit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user