feat: clone any resource

This commit is contained in:
Andras Bacsai
2024-01-22 16:08:18 +01:00
parent 2edf71a0dd
commit abcc004953
7 changed files with 235 additions and 96 deletions

View File

@@ -59,8 +59,9 @@
href="#">Resource Limits
</a>
@endif
<a :class="activeTab === 'move' && 'text-white'"
@click.prevent="activeTab = 'move'; window.location.hash = 'move'" href="#">Move Resource
<a :class="activeTab === 'resource-operations' && 'text-white'"
@click.prevent="activeTab = 'resource-operations'; window.location.hash = 'resource-operations'"
href="#">Resource Operations
</a>
<a :class="activeTab === 'danger' && 'text-white'"
@click.prevent="activeTab = 'danger'; window.location.hash = 'danger'" href="#">Danger Zone
@@ -108,8 +109,8 @@
<div x-cloak x-show="activeTab === 'scheduled-tasks'">
<livewire:project.shared.scheduled-task.all :resource="$application" />
</div>
<div x-cloak x-show="activeTab === 'move'">
<livewire:project.shared.move-resource :resource="$application" />
<div x-cloak x-show="activeTab === 'resource-operations'">
<livewire:project.shared.resource-operations :resource="$application" />
</div>
<div x-cloak x-show="activeTab === 'danger'">
<livewire:project.shared.danger :resource="$application" />

View File

@@ -44,8 +44,9 @@
window.location.hash = 'resource-limits'"
href="#">Resource Limits
</a>
<a :class="activeTab === 'move' && 'text-white'"
@click.prevent="activeTab = 'move'; window.location.hash = 'move'" href="#">Move Resource
<a :class="activeTab === 'resource-operations' && 'text-white'"
@click.prevent="activeTab = 'resource-operations'; window.location.hash = 'resource-operations'"
href="#">Resource Operations
</a>
<a :class="activeTab === 'danger' && 'text-white'"
@click.prevent="activeTab = 'danger';
@@ -85,8 +86,8 @@
<div x-cloak x-show="activeTab === 'import'">
<livewire:project.database.import :resource="$database" />
</div>
<div x-cloak x-show="activeTab === 'move'">
<livewire:project.shared.move-resource :resource="$database" />
<div x-cloak x-show="activeTab === 'resource-operations'">
<livewire:project.shared.resource-operations :resource="$database" />
</div>
<div x-cloak x-show="activeTab === 'danger'">
<livewire:project.shared.danger :resource="$database" />

View File

@@ -26,9 +26,10 @@
<a :class="activeTab === 'webhooks' && 'text-white'"
@click.prevent="activeTab = 'webhooks'; window.location.hash = 'webhooks'" href="#">Webhooks
</a>
<a :class="activeTab === 'move' && 'text-white'"
@click.prevent="activeTab = 'move'; window.location.hash = 'move'" href="#">Move Resource
</a>
<a :class="activeTab === 'resource-operations' && 'text-white'"
@click.prevent="activeTab = 'resource-operations'; window.location.hash = 'resource-operations'"
href="#">Resource Operations
</a>
<a :class="activeTab === 'danger' && 'text-white'"
@click.prevent="activeTab = 'danger';
window.location.hash = 'danger'"
@@ -160,8 +161,8 @@
<div x-cloak x-show="activeTab === 'environment-variables'">
<livewire:project.shared.environment-variable.all :resource="$service" />
</div>
<div x-cloak x-show="activeTab === 'move'">
<livewire:project.shared.move-resource :resource="$service" />
<div x-cloak x-show="activeTab === 'resource-operations'">
<livewire:project.shared.resource-operations :resource="$service" />
</div>
<div x-cloak x-show="activeTab === 'danger'">
<livewire:project.shared.danger :resource="$service" />

View File

@@ -1,25 +0,0 @@
<div>
<h2>Move Resource</h2>
<div class="pb-4">You can easily move this resource to another project.</div>
<div>
<div class="pb-8">
This resource is currently in the <span
class="font-bold text-warning">{{ $resource->environment->project->name }} /
{{ $resource->environment->name }}</span> environment.
</div>
<div class="grid grid-flow-col grid-rows-2 gap-4">
@forelse ($projects as $project)
<div class="grid grid-flow-col grid-rows-2 gap-4">
@foreach ($project->environments as $environment)
<div class="flex flex-col gap-2 box" wire:click="moveTo('{{ data_get($environment, 'id') }}')">
<div class="font-bold text-white">{{ $project->name }}</div>
<div><span class="text-warning">{{ $environment->name }}</span> environment</div>
</div>
@endforeach
</div>
@empty
<div>No projects found to move to</div>
@endforelse
</div>
</div>
</div>

View File

@@ -0,0 +1,46 @@
<div>
<h2>Resource Operations</h2>
<div class="pb-4">You can easily make different kind of operations on this resource.</div>
<h4>Clone</h4>
<div class="pb-8">
<div class="pb-8">
Clone this resource to another project / environment.
</div>
<div class="flex flex-col gap-4">
@foreach ($servers->sortBy('id') as $server)
<div>
<div class="grid grid-cols-1 gap-2 pb-4 lg:grid-cols-4">
@foreach ($server->destinations() as $destination)
<div class="flex flex-col gap-2 box" wire:click="cloneTo('{{ data_get($destination, 'id') }}')">
<div class="font-bold text-white">{{ $server->name }}</div>
<div>{{ $destination->name }}</div>
</div>
@endforeach
</div>
</div>
@endforeach
</div>
</div>
<h4>Move</h4>
<div>
<div class="pb-8">
This resource is currently in the <span
class="font-bold text-warning">{{ $resource->environment->project->name }} /
{{ $resource->environment->name }}</span> environment.
</div>
<div class="grid gap-4">
@forelse ($projects as $project)
<div class="flex flex-row flex-wrap gap-2">
@foreach ($project->environments as $environment)
<div class="flex flex-col gap-2 box" wire:click="moveTo('{{ data_get($environment, 'id') }}')">
<div class="font-bold text-white">{{ $project->name }}</div>
<div><span class="text-warning">{{ $environment->name }}</span> environment</div>
</div>
@endforeach
</div>
@empty
<div>No projects found to move to</div>
@endforelse
</div>
</div>
</div>