mirror of
https://github.com/cupcakearmy/coolify.git
synced 2024-10-22 16:14:22 +02:00
ui: new modal component
This commit is contained in:
parent
f1a9e28d5a
commit
8ff7aeb78b
@ -9,6 +9,7 @@ class DeleteEnvironment extends Component
|
|||||||
{
|
{
|
||||||
public array $parameters;
|
public array $parameters;
|
||||||
public int $environment_id;
|
public int $environment_id;
|
||||||
|
public bool $disabled = false;
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
|
@ -9,6 +9,7 @@ class DeleteProject extends Component
|
|||||||
{
|
{
|
||||||
public array $parameters;
|
public array $parameters;
|
||||||
public int $project_id;
|
public int $project_id;
|
||||||
|
public bool $disabled = false;
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
|
@ -64,10 +64,13 @@ public function mongodbs()
|
|||||||
}
|
}
|
||||||
public function mysqls()
|
public function mysqls()
|
||||||
{
|
{
|
||||||
return $this->hasMany(StandaloneMysql::class, Environment::class);
|
return $this->hasManyThrough(StandaloneMysql::class, Environment::class);
|
||||||
}
|
}
|
||||||
public function mariadbs()
|
public function mariadbs()
|
||||||
{
|
{
|
||||||
return $this->hasMany(StandaloneMariadb::class, Environment::class);
|
return $this->hasManyThrough(StandaloneMariadb::class, Environment::class);
|
||||||
|
}
|
||||||
|
public function resource_count() {
|
||||||
|
return $this->applications()->count() + $this->postgresqls()->count() + $this->redis()->count() + $this->mongodbs()->count() + $this->mysqls()->count() + $this->mariadbs()->count();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
56
resources/views/components/new-modal.blade.php
Normal file
56
resources/views/components/new-modal.blade.php
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
@props([
|
||||||
|
'title' => 'Are you sure?',
|
||||||
|
'buttonTitle' => 'Open Modal',
|
||||||
|
'isErrorButton' => false,
|
||||||
|
'disabled' => false,
|
||||||
|
'action' => 'delete',
|
||||||
|
])
|
||||||
|
<div x-data="{ modalOpen: false }" @keydown.escape.window="modalOpen = false" :class="{ 'z-40': modalOpen }"
|
||||||
|
class="relative w-auto h-auto">
|
||||||
|
@if ($disabled)
|
||||||
|
<x-forms.button isError disabled>{{ $buttonTitle }}</x-forms.button>
|
||||||
|
@elseif ($isErrorButton)
|
||||||
|
<x-forms.button isError @click="modalOpen=true">{{ $buttonTitle }}</x-forms.button>
|
||||||
|
@else
|
||||||
|
<x-forms.button @click="modalOpen=true">{{ $buttonTitle }}</x-forms.button>
|
||||||
|
@endif
|
||||||
|
<template x-teleport="body">
|
||||||
|
<div x-show="modalOpen" class="fixed top-0 left-0 z-[99] flex items-center justify-center w-screen h-screen"
|
||||||
|
x-cloak>
|
||||||
|
<div x-show="modalOpen" x-transition:enter="ease-out duration-300" x-transition:enter-start="opacity-0"
|
||||||
|
x-transition:enter-end="opacity-100" x-transition:leave="ease-in duration-300"
|
||||||
|
x-transition:leave-start="opacity-100" x-transition:leave-end="opacity-0" @click="modalOpen=false"
|
||||||
|
class="absolute inset-0 w-full h-full bg-black backdrop-blur-sm bg-opacity-70"></div>
|
||||||
|
<div x-show="modalOpen" x-trap.inert.noscroll="modalOpen" x-transition:enter="ease-out duration-300"
|
||||||
|
x-transition:enter-start="opacity-0 -translate-y-2 sm:scale-95"
|
||||||
|
x-transition:enter-end="opacity-100 translate-y-0 sm:scale-100"
|
||||||
|
x-transition:leave="ease-in duration-200"
|
||||||
|
x-transition:leave-start="opacity-100 translate-y-0 sm:scale-100"
|
||||||
|
x-transition:leave-end="opacity-0 -translate-y-2 sm:scale-95"
|
||||||
|
class="relative w-full py-6 border shadow-lg bg-coolgray-100 px-7 border-coolgray-300 sm:max-w-lg sm:rounded-lg">
|
||||||
|
<div class="flex items-center justify-between pb-3">
|
||||||
|
<h3 class="text-lg font-semibold">{{ $title }}</h3>
|
||||||
|
<button @click="modalOpen=false"
|
||||||
|
class="absolute top-0 right-0 flex items-center justify-center w-8 h-8 mt-5 mr-5 text-white rounded-full hover:bg-coolgray-300">
|
||||||
|
<svg class="w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="relative w-auto pb-8">
|
||||||
|
{{ $slot }}
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2">
|
||||||
|
<x-forms.button @click="modalOpen=false" class="w-24 bg-coolgray-200 hover:bg-coolgray-300"
|
||||||
|
type="button">Cancel
|
||||||
|
</x-forms.button>
|
||||||
|
<div class="flex-1"></div>
|
||||||
|
<x-forms.button @click="modalOpen=false" class="w-24" isError type="button"
|
||||||
|
wire:click.prevent='{{ $action }}'>Continue
|
||||||
|
</x-forms.button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
@ -1,8 +1,3 @@
|
|||||||
<div>
|
<x-new-modal isErrorButton buttonTitle="Delete Environment" disabled="{{ $disabled }}">
|
||||||
<x-modal yesOrNo modalId="deleteEnvironment" modalTitle="Delete Environment">
|
This environment will be deleted. It is not reversible. <br>Please think again.
|
||||||
<x-slot:modalBody>
|
</x-new-modal>
|
||||||
<p>This environment will be deleted. It is not reversible. <br>Please think again.</p>
|
|
||||||
</x-slot:modalBody>
|
|
||||||
</x-modal>
|
|
||||||
<x-forms.button isError isModal modalId="deleteEnvironment"> Delete Environment</x-forms.button>
|
|
||||||
</div>
|
|
||||||
|
@ -1,10 +1,3 @@
|
|||||||
<div>
|
<x-new-modal isErrorButton buttonTitle="Delete Project" disabled="{{ $disabled }}">
|
||||||
<x-modal yesOrNo modalId="deleteProject" modalTitle="Delete Project">
|
This project will be deleted. It is not reversible. <br>Please think again.
|
||||||
<x-slot:modalBody>
|
</x-new-modal>
|
||||||
<p>This project will be deleted. It is not reversible. <br>Please think again.</p>
|
|
||||||
</x-slot:modalBody>
|
|
||||||
</x-modal>
|
|
||||||
<x-forms.button isError isModal modalId="deleteProject">
|
|
||||||
Delete Project
|
|
||||||
</x-forms.button>
|
|
||||||
</div>
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
<div class="flex items-end gap-2">
|
<div class="flex items-end gap-2">
|
||||||
<h2>General</h2>
|
<h2>General</h2>
|
||||||
<x-forms.button type="submit">Save</x-forms.button>
|
<x-forms.button type="submit">Save</x-forms.button>
|
||||||
|
<livewire:project.delete-project :disabled="$project->resource_count() > 0" :project_id="$project->id" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<x-forms.input label="Name" id="project.name" />
|
<x-forms.input label="Name" id="project.name" />
|
||||||
@ -23,7 +24,8 @@ class="font-normal text-white normal-case border-none rounded btn btn-primary bt
|
|||||||
Add</button>
|
Add</button>
|
||||||
</x-slide-over>
|
</x-slide-over>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-2 pb-4">You can use these variables anywhere with <span class="text-warning">@{{project.VARIABLENAME}}</span><x-helper
|
<div class="flex items-center gap-2 pb-4">You can use these variables anywhere with <span
|
||||||
|
class="text-warning">@{{ project.VARIABLENAME }}</span><x-helper
|
||||||
helper="More info <a class='text-white underline' href='https://coolify.io/docs/environment-variables#shared-variables' target='_blank'>here</a>."></x-helper>
|
helper="More info <a class='text-white underline' href='https://coolify.io/docs/environment-variables#shared-variables' target='_blank'>here</a>."></x-helper>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<div class="flex items-end gap-2">
|
<div class="flex items-end gap-2">
|
||||||
<h1>Environment: {{ data_get($environment, 'name') }}</h1>
|
<h1>Environment: {{ data_get($environment, 'name') }}</h1>
|
||||||
<x-forms.button type="submit">Save</x-forms.button>
|
<x-forms.button type="submit">Save</x-forms.button>
|
||||||
|
<livewire:project.delete-environment :disabled="!$environment->isEmpty()" :environment_id="$environment->id" />
|
||||||
</div>
|
</div>
|
||||||
<nav class="flex pt-2 pb-10">
|
<nav class="flex pt-2 pb-10">
|
||||||
<ol class="flex items-center">
|
<ol class="flex items-center">
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
href="{{ route('project.clone-me', ['project_uuid' => data_get($project, 'uuid'), 'environment_name' => request()->route('environment_name')]) }}">
|
href="{{ route('project.clone-me', ['project_uuid' => data_get($project, 'uuid'), 'environment_name' => request()->route('environment_name')]) }}">
|
||||||
Clone
|
Clone
|
||||||
</a>
|
</a>
|
||||||
<livewire:project.delete-environment :environment_id="$environment->id" />
|
|
||||||
@else
|
@else
|
||||||
<a href="{{ route('project.resource.create', ['project_uuid' => request()->route('project_uuid'), 'environment_name' => request()->route('environment_name')]) }} "
|
<a href="{{ route('project.resource.create', ['project_uuid' => request()->route('project_uuid'), 'environment_name' => request()->route('environment_name')]) }} "
|
||||||
class="font-normal text-white normal-case border-none rounded hover:no-underline btn btn-primary btn-sm no-animation">+
|
class="font-normal text-white normal-case border-none rounded hover:no-underline btn btn-primary btn-sm no-animation">+
|
||||||
@ -17,6 +16,7 @@ class="font-normal text-white normal-case border-none rounded hover:no-underline
|
|||||||
Clone
|
Clone
|
||||||
</a>
|
</a>
|
||||||
@endif
|
@endif
|
||||||
|
<livewire:project.delete-environment :disabled="!$environment->isEmpty()" :environment_id="$environment->id" />
|
||||||
</div>
|
</div>
|
||||||
<nav class="flex pt-2 pb-10">
|
<nav class="flex pt-2 pb-10">
|
||||||
<ol class="flex items-center">
|
<ol class="flex items-center">
|
||||||
|
@ -3,9 +3,7 @@
|
|||||||
<h1>Environments</h1>
|
<h1>Environments</h1>
|
||||||
<x-forms.button class="btn" onclick="newEnvironment.showModal()">+ Add</x-forms.button>
|
<x-forms.button class="btn" onclick="newEnvironment.showModal()">+ Add</x-forms.button>
|
||||||
<livewire:project.add-environment :project="$project" />
|
<livewire:project.add-environment :project="$project" />
|
||||||
@if ($project->applications->count() === 0)
|
<livewire:project.delete-project :disabled="$project->resource_count() > 0" :project_id="$project->id" />
|
||||||
<livewire:project.delete-project :project_id="$project->id" />
|
|
||||||
@endif
|
|
||||||
</div>
|
</div>
|
||||||
<div class="text-xs truncate subtitle lg:text-sm">{{ $project->name }}</div>
|
<div class="text-xs truncate subtitle lg:text-sm">{{ $project->name }}</div>
|
||||||
<div class="grid gap-2 lg:grid-cols-2">
|
<div class="grid gap-2 lg:grid-cols-2">
|
||||||
|
Loading…
Reference in New Issue
Block a user