fix
This commit is contained in:
parent
ee515ff940
commit
c89ea2a1f0
31
app/Http/Livewire/Project/DeleteEnvironment.php
Normal file
31
app/Http/Livewire/Project/DeleteEnvironment.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Project;
|
||||
|
||||
use App\Models\Environment;
|
||||
use App\Models\Project;
|
||||
use Livewire\Component;
|
||||
|
||||
class DeleteEnvironment extends Component
|
||||
{
|
||||
public array $parameters;
|
||||
public int $environment_id;
|
||||
public int $resource_count = 0;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->parameters = getParameters();
|
||||
}
|
||||
public function delete()
|
||||
{
|
||||
$this->validate([
|
||||
'environment_id' => 'required|int',
|
||||
]);
|
||||
$environment = Environment::findOrFail($this->environment_id);
|
||||
if ($environment->applications->count() > 0) {
|
||||
return $this->emit('error', 'Environment has resources defined, please delete them first.');
|
||||
}
|
||||
$environment->delete();
|
||||
return redirect()->route('project.show', ['project_uuid' => $this->parameters['project_uuid']]);
|
||||
}
|
||||
}
|
@ -5,11 +5,16 @@
|
||||
use App\Models\Project;
|
||||
use Livewire\Component;
|
||||
|
||||
class Delete extends Component
|
||||
class DeleteProject extends Component
|
||||
{
|
||||
public array $parameters;
|
||||
public int $project_id;
|
||||
public int $resource_count = 0;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->parameters = getParameters();
|
||||
}
|
||||
public function delete()
|
||||
{
|
||||
$this->validate([
|
||||
@ -17,9 +22,9 @@ public function delete()
|
||||
]);
|
||||
$project = Project::findOrFail($this->project_id);
|
||||
if ($project->applications->count() > 0) {
|
||||
return $this->emit('error', 'Project has applications, please delete them first.');
|
||||
return $this->emit('error', 'Project has resources defined, please delete them first.');
|
||||
}
|
||||
$project->delete();
|
||||
return redirect()->route('dashboard');
|
||||
return redirect()->route('projects');
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
@auth
|
||||
<nav class="main-navbar">
|
||||
<ul class="gap-2 p-1 pt-2 menu">
|
||||
<ul class="gap-2 p-1 pt-2 menu" title="Dashboard">
|
||||
<li class="{{ request()->is('/') ? 'text-warning' : '' }}">
|
||||
<a @if (!request()->is('/')) href="/" @endif>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon" fill="none" viewBox="0 0 24 24"
|
||||
@ -10,20 +10,9 @@
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
<li class="{{ request()->is('server/*') || request()->is('servers') ? 'text-warning' : '' }}">
|
||||
<a @if (!request()->is('server/*')) href="/servers" @endif>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M3 4m0 3a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v2a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3z" />
|
||||
<path d="M3 12m0 3a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v2a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3z" />
|
||||
<path d="M7 8l0 .01" />
|
||||
<path d="M7 16l0 .01" />
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="{{ request()->is('project/*') || request()->is('projects') ? 'text-warning' : '' }}">
|
||||
<li class="{{ request()->is('project/*') || request()->is('projects') ? 'text-warning' : '' }}"
|
||||
title="Projects">
|
||||
<a @if (!request()->is('project/*')) href="/projects" @endif>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
@ -35,8 +24,21 @@
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="{{ request()->is('server/*') || request()->is('servers') ? 'text-warning' : '' }}" title="Servers">
|
||||
<a @if (!request()->is('server/*')) href="/servers" @endif>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M3 4m0 3a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v2a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3z" />
|
||||
<path d="M15 20h-9a3 3 0 0 1 -3 -3v-2a3 3 0 0 1 3 -3h12" />
|
||||
<path d="M7 8v.01" />
|
||||
<path d="M7 16v.01" />
|
||||
<path d="M20 15l-2 3h3l-2 3" />
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
@if (auth()->user()->isPartOfRootTeam())
|
||||
<li class="{{ request()->is('command-center') ? 'text-warning' : '' }}">
|
||||
<li class="{{ request()->is('command-center') ? 'text-warning' : '' }}" title="Command Center">
|
||||
<a @if (!request()->is('command-center')) href="/command-center" @endif>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
@ -46,8 +48,8 @@
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
<li
|
||||
class="{{ request()->is('settings') ? 'absolute bottom-0 pb-4 text-warning' : 'absolute bottom-0 pb-4' }}">
|
||||
<li class="{{ request()->is('settings') ? 'absolute bottom-0 pb-4 text-warning' : 'absolute bottom-0 pb-4' }}"
|
||||
title="Settings">
|
||||
<a @if (!request()->is('settings')) href="/settings" @endif>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
|
@ -0,0 +1,12 @@
|
||||
<div x-data="{ deleteEnvironment: false }">
|
||||
<x-naked-modal show="deleteEnvironment" message='Are you sure you would like to delete this environment?' />
|
||||
@if ($resource_count > 0)
|
||||
<x-inputs.button tooltip="First delete all resources." disabled>
|
||||
Delete
|
||||
</x-inputs.button>
|
||||
@else
|
||||
<x-inputs.button x-on:click.prevent="deleteEnvironment = true">
|
||||
Delete
|
||||
</x-inputs.button>
|
||||
@endif
|
||||
</div>
|
@ -9,5 +9,4 @@
|
||||
Delete
|
||||
</x-inputs.button>
|
||||
@endif
|
||||
|
||||
</div>
|
@ -2,7 +2,7 @@
|
||||
<div class="flex flex-col">
|
||||
<div class="flex items-center gap-2">
|
||||
<h1 class="pb-0">Resources</h1>
|
||||
<livewire:project.delete :project_id="$project->id" :resource_count="$project->applications->count()" />
|
||||
<livewire:project.delete-environment :environment_id="$environment->id" :resource_count="$environment->applications->count()" />
|
||||
</div>
|
||||
<div class="pb-10 text-sm breadcrumbs">
|
||||
<ul>
|
||||
@ -18,7 +18,7 @@
|
||||
</div>
|
||||
</div>
|
||||
@if ($environment->applications->count() === 0)
|
||||
<p>No resources yet.</p>
|
||||
<p>No resources found.</p>
|
||||
@endif
|
||||
<div class="flex flex-col gap-2">
|
||||
@foreach ($environment->applications->sortBy('name') as $application)
|
||||
|
@ -1,15 +1,20 @@
|
||||
<x-layout>
|
||||
<div class="flex items-center gap-2">
|
||||
<h1 class="pb-0">Environments</h1>
|
||||
<livewire:project.delete-project :project_id="$project->id" :resource_count="$project->applications->count()" />
|
||||
</div>
|
||||
<div class="pb-10 text-sm breadcrumbs">
|
||||
<ul>
|
||||
<li>{{ $project->name }} </li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2">
|
||||
@foreach ($project->environments as $environment)
|
||||
@forelse ($project->environments as $environment)
|
||||
<a class="box" href="{{ route('project.resources', [$project->uuid, $environment->name]) }}">
|
||||
{{ $environment->name }}
|
||||
</a>
|
||||
@endforeach
|
||||
@empty
|
||||
<p>No environments found.</p>
|
||||
@endforelse
|
||||
</div>
|
||||
</x-layout>
|
||||
|
Loading…
Reference in New Issue
Block a user