Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat: move resources between projects / environments

Andras Bacsai2edf71a0dddd
diff --git a/app/Livewire/Project/Application/Heading.php b/app/Livewire/Project/Application/Heading.php
index 95dcbdf735..d91f44b802 100644
--- a/app/Livewire/Project/Application/Heading.php
+++ b/app/Livewire/Project/Application/Heading.php
@@ -3,7 +3,6 @@
namespace App\Livewire\Project\Application;
use App\Actions\Application\StopApplication;
-use App\Events\ApplicationStatusChanged;
use App\Jobs\ContainerStatusJob;
use App\Jobs\ServerStatusJob;
use App\Models\Application;
diff --git a/app/Livewire/Project/Shared/MoveResource.php b/app/Livewire/Project/Shared/MoveResource.php
new file mode 100644
index 0000000000..f4d69dd1dc
--- /dev/null
+++ b/app/Livewire/Project/Shared/MoveResource.php
@@ -0,0 +1,58 @@
+<?php
+
+namespace App\Livewire\Project\Shared;
+
+use App\Models\Environment;
+use App\Models\Project;
+use Livewire\Component;
+use Visus\Cuid2\Cuid2;
+
+class MoveResource extends Component
+{
+ public $resource;
+ public $projectUuid;
+ public $environmentName;
+ public $projects;
+
+ public function mount()
+ {
+ $parameters = get_route_parameters();
+ $this->projectUuid = $parameters['project_uuid'];
+ $this->environmentName = $parameters['environment_name'];
+ $this->projects = Project::ownedByCurrentTeam()->get();
+ }
+ public function moveTo($environment_id)
+ {
+ try {
+ $new_environment = Environment::findOrFail($environment_id);
+ $this->resource->update([
+ 'environment_id' => $environment_id
+ ]);
+ if ($this->resource->type() === 'application') {
+ return redirect()->route('project.application.configuration', [
+ 'project_uuid' => $new_environment->project->uuid,
+ 'environment_name' => $new_environment->name,
+ 'application_uuid' => $this->resource->uuid,
+ ]);
+ } else if (str($this->resource->type())->startsWith('standalone-')) {
+ return redirect()->route('project.database.configuration', [
+ 'project_uuid' => $new_environment->project->uuid,
+ 'environment_name' => $new_environment->name,
+ 'database_uuid' => $this->resource->uuid,
+ ]);
+ } else if ($this->resource->type() === 'service') {
+ return redirect()->route('project.service.configuration', [
+ 'project_uuid' => $new_environment->project->uuid,
+ 'environment_name' => $new_environment->name,
+ 'service_uuid' => $this->resource->uuid,
+ ]);
+ }
+ } catch (\Throwable $e) {
+ return handleError($e, $this);
+ }
+ }
+ public function render()
+ {
+ return view('livewire.project.shared.move-resource');
+ }
+}
diff --git a/resources/views/livewire/project/application/configuration.blade.php b/resources/views/livewire/project/application/configuration.blade.php
index 3a43a7769e..60a207acb2 100644
--- a/resources/views/livewire/project/application/configuration.blade.php
+++ b/resources/views/livewire/project/application/configuration.blade.php
@@ -59,7 +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>
<a :class="activeTab === 'danger' && 'text-white'"
@click.prevent="activeTab = 'danger'; window.location.hash = 'danger'" href="#">Danger Zone
</a>
@@ -106,6 +108,9 @@
<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>
<div x-cloak x-show="activeTab === 'danger'">
<livewire:project.shared.danger :resource="$application" />
</div>
diff --git a/resources/views/livewire/project/database/configuration.blade.php b/resources/views/livewire/project/database/configuration.blade.php
index 4ed308b40d..6e3f9a6139 100644
--- a/resources/views/livewire/project/database/configuration.blade.php
+++ b/resources/views/livewire/project/database/configuration.blade.php
@@ -44,7 +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>
<a :class="activeTab === 'danger' && 'text-white'"
@click.prevent="activeTab = 'danger';
window.location.hash = 'danger'"
@@ -83,6 +85,9 @@
<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>
<div x-cloak x-show="activeTab === 'danger'">
<livewire:project.shared.danger :resource="$database" />
</div>
diff --git a/resources/views/livewire/project/resource/index.blade.php b/resources/views/livewire/project/resource/index.blade.php
index 921e9c3602..26965aeefd 100644
--- a/resources/views/livewire/project/resource/index.blade.php
+++ b/resources/views/livewire/project/resource/index.blade.php
@@ -43,132 +43,134 @@
@if ($environment->isEmpty())
<a href="{{ route('project.resource.create', ['project_uuid' => request()->route('project_uuid'), 'environment_name' => request()->route('environment_name')]) }} "
class="items-center justify-center box">+ Add New Resource</a>
- @endif
- <div x-data="searchComponent()">
- <x-forms.input placeholder="Search for name, fqdn..." class="w-full" x-model="search" />
- <div class="grid gap-2 pt-4 lg:grid-cols-2">
- <template x-for="item in filteredApplications" :key="item.id">
- <a class="relative box group" :href="item.hrefLink">
- <div class="flex flex-col mx-6">
- <div class="pb-2 font-bold text-white" x-text="item.name"></div>
- <div class="description" x-text="item.description"></div>
- <div class="description" x-text="item.fqdn"></div>
- </div>
- <template x-if="item.status.startsWith('running')">
- <div class="absolute bg-success -top-1 -left-1 badge badge-xs"></div>
- </template>
- <template x-if="item.status.startsWith('exited')">
- <div class="absolute bg-error -top-1 -left-1 badge badge-xs"></div>
- </template>
- <template x-if="item.status.startsWith('restarting')">
- <div class="absolute bg-warning -top-1 -left-1 badge badge-xs"></div>
- </template>
- </a>
- </template>
- <template x-for="item in filteredPostgresqls" :key="item.id">
- <a class="relative box group" :href="item.hrefLink">
- <div class="flex flex-col mx-6">
- <div class="font-bold text-white" x-text="item.name"></div>
- <div class="description" x-text="item.description"></div>
- </div>
- <template x-if="item.status.startsWith('running')">
- <div class="absolute bg-success -top-1 -left-1 badge badge-xs"></div>
- </template>
- <template x-if="item.status.startsWith('exited')">
- <div class="absolute bg-error -top-1 -left-1 badge badge-xs"></div>
- </template>
- <template x-if="item.status.startsWith('restarting')">
- <div class="absolute bg-warning -top-1 -left-1 badge badge-xs"></div>
- </template>
- </a>
- </template>
- <template x-for="item in filteredRedis" :key="item.id">
- <a class="relative box group" :href="item.hrefLink">
- <div class="flex flex-col mx-6">
- <div class="font-bold text-white" x-text="item.name"></div>
- <div class="description" x-text="item.description"></div>
- </div>
- <template x-if="item.status.startsWith('running')">
- <div class="absolute bg-success -top-1 -left-1 badge badge-xs"></div>
- </template>
- <template x-if="item.status.startsWith('exited')">
- <div class="absolute bg-error -top-1 -left-1 badge badge-xs"></div>
- </template>
- <template x-if="item.status.startsWith('restarting')">
- <div class="absolute bg-warning -top-1 -left-1 badge badge-xs"></div>
- </template>
- </a>
- </template>
- <template x-for="item in filteredMongodbs" :key="item.id">
- <a class="relative box group" :href="item.hrefLink">
- <div class="flex flex-col mx-6">
- <div class="font-bold text-white" x-text="item.name"></div>
- <div class="description" x-text="item.description"></div>
- </div>
- <template x-if="item.status.startsWith('running')">
- <div class="absolute bg-success -top-1 -left-1 badge badge-xs"></div>
- </template>
- <template x-if="item.status.startsWith('exited')">
- <div class="absolute bg-error -top-1 -left-1 badge badge-xs"></div>
- </template>
- <template x-if="item.status.startsWith('restarting')">
- <div class="absolute bg-warning -top-1 -left-1 badge badge-xs"></div>
- </template>
- </a>
- </template>
- <template x-for="item in filteredMysqls" :key="item.id">
- <a class="relative box group" :href="item.hrefLink">
- <div class="flex flex-col mx-6">
- <div class="font-bold text-white" x-text="item.name"></div>
- <div class="description" x-text="item.description"></div>
- </div>
- <template x-if="item.status.startsWith('running')">
- <div class="absolute bg-success -top-1 -left-1 badge badge-xs"></div>
- </template>
- <template x-if="item.status.startsWith('exited')">
- <div class="absolute bg-error -top-1 -left-1 badge badge-xs"></div>
- </template>
- <template x-if="item.status.startsWith('restarting')">
- <div class="absolute bg-warning -top-1 -left-1 badge badge-xs"></div>
- </template>
- </a>
- </template>
- <template x-for="item in filteredMariadbs" :key="item.id">
- <a class="relative box group" :href="item.hrefLink">
- <div class="flex flex-col mx-6">
- <div class="font-bold text-white" x-text="item.name"></div>
- <div class="description" x-text="item.description"></div>
- </div>
- <template x-if="item.status.startsWith('running')">
- <div class="absolute bg-success -top-1 -left-1 badge badge-xs"></div>
- </template>
- <template x-if="item.status.startsWith('exited')">
- <div class="absolute bg-error -top-1 -left-1 badge badge-xs"></div>
- </template>
- <template x-if="item.status.startsWith('restarting')">
- <div class="absolute bg-warning -top-1 -left-1 badge badge-xs"></div>
- </template>
- </a>
- </template>
- <template x-for="item in filteredServices" :key="item.id">
- <a class="relative box group" :href="item.hrefLink">
- <div class="flex flex-col mx-6">
- <div class="font-bold text-white" x-text="item.name"></div>
- <div class="description" x-text="item.description"></div>
- </div>
- <template x-if="item.status.startsWith('running')">
- <div class="absolute bg-success -top-1 -left-1 badge badge-xs"></div>
- </template>
- <template x-if="item.status.startsWith('exited')">
- <div class="absolute bg-error -top-1 -left-1 badge badge-xs"></div>
- </template>
- <template x-if="item.status.startsWith('degraded')">
- <div class="absolute bg-warning -top-1 -left-1 badge badge-xs"></div>
- </template>
- </a>
- </template>
+ @else
+ <div x-data="searchComponent()">
+ <x-forms.input placeholder="Search for name, fqdn..." class="w-full" x-model="search" />
+ <div class="grid gap-2 pt-4 lg:grid-cols-2">
+ <template x-for="item in filteredApplications" :key="item.id">
+ <a class="relative box group" :href="item.hrefLink">
+ <div class="flex flex-col mx-6">
+ <div class="pb-2 font-bold text-white" x-text="item.name"></div>
+ <div class="description" x-text="item.description"></div>
+ <div class="description" x-text="item.fqdn"></div>
+ </div>
+ <template x-if="item.status.startsWith('running')">
+ <div class="absolute bg-success -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ <template x-if="item.status.startsWith('exited')">
+ <div class="absolute bg-error -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ <template x-if="item.status.startsWith('restarting')">
+ <div class="absolute bg-warning -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ </a>
+ </template>
+ <template x-for="item in filteredPostgresqls" :key="item.id">
+ <a class="relative box group" :href="item.hrefLink">
+ <div class="flex flex-col mx-6">
+ <div class="font-bold text-white" x-text="item.name"></div>
+ <div class="description" x-text="item.description"></div>
+ </div>
+ <template x-if="item.status.startsWith('running')">
+ <div class="absolute bg-success -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ <template x-if="item.status.startsWith('exited')">
+ <div class="absolute bg-error -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ <template x-if="item.status.startsWith('restarting')">
+ <div class="absolute bg-warning -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ </a>
+ </template>
+ <template x-for="item in filteredRedis" :key="item.id">
+ <a class="relative box group" :href="item.hrefLink">
+ <div class="flex flex-col mx-6">
+ <div class="font-bold text-white" x-text="item.name"></div>
+ <div class="description" x-text="item.description"></div>
+ </div>
+ <template x-if="item.status.startsWith('running')">
+ <div class="absolute bg-success -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ <template x-if="item.status.startsWith('exited')">
+ <div class="absolute bg-error -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ <template x-if="item.status.startsWith('restarting')">
+ <div class="absolute bg-warning -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ </a>
+ </template>
+ <template x-for="item in filteredMongodbs" :key="item.id">
+ <a class="relative box group" :href="item.hrefLink">
+ <div class="flex flex-col mx-6">
+ <div class="font-bold text-white" x-text="item.name"></div>
+ <div class="description" x-text="item.description"></div>
+ </div>
+ <template x-if="item.status.startsWith('running')">
+ <div class="absolute bg-success -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ <template x-if="item.status.startsWith('exited')">
+ <div class="absolute bg-error -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ <template x-if="item.status.startsWith('restarting')">
+ <div class="absolute bg-warning -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ </a>
+ </template>
+ <template x-for="item in filteredMysqls" :key="item.id">
+ <a class="relative box group" :href="item.hrefLink">
+ <div class="flex flex-col mx-6">
+ <div class="font-bold text-white" x-text="item.name"></div>
+ <div class="description" x-text="item.description"></div>
+ </div>
+ <template x-if="item.status.startsWith('running')">
+ <div class="absolute bg-success -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ <template x-if="item.status.startsWith('exited')">
+ <div class="absolute bg-error -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ <template x-if="item.status.startsWith('restarting')">
+ <div class="absolute bg-warning -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ </a>
+ </template>
+ <template x-for="item in filteredMariadbs" :key="item.id">
+ <a class="relative box group" :href="item.hrefLink">
+ <div class="flex flex-col mx-6">
+ <div class="font-bold text-white" x-text="item.name"></div>
+ <div class="description" x-text="item.description"></div>
+ </div>
+ <template x-if="item.status.startsWith('running')">
+ <div class="absolute bg-success -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ <template x-if="item.status.startsWith('exited')">
+ <div class="absolute bg-error -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ <template x-if="item.status.startsWith('restarting')">
+ <div class="absolute bg-warning -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ </a>
+ </template>
+ <template x-for="item in filteredServices" :key="item.id">
+ <a class="relative box group" :href="item.hrefLink">
+ <div class="flex flex-col mx-6">
+ <div class="font-bold text-white" x-text="item.name"></div>
+ <div class="description" x-text="item.description"></div>
+ </div>
+ <template x-if="item.status.startsWith('running')">
+ <div class="absolute bg-success -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ <template x-if="item.status.startsWith('exited')">
+ <div class="absolute bg-error -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ <template x-if="item.status.startsWith('degraded')">
+ <div class="absolute bg-warning -top-1 -left-1 badge badge-xs"></div>
+ </template>
+ </a>
+ </template>
+ </div>
</div>
- </div>
+ @endif
+
</div>
<script>
diff --git a/resources/views/livewire/project/service/configuration.blade.php b/resources/views/livewire/project/service/configuration.blade.php
index 157a4fa169..1ecec2f601 100644
--- a/resources/views/livewire/project/service/configuration.blade.php
+++ b/resources/views/livewire/project/service/configuration.blade.php
@@ -26,6 +26,9 @@
<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 === 'danger' && 'text-white'"
@click.prevent="activeTab = 'danger';
window.location.hash = 'danger'"
@@ -157,6 +160,9 @@
<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>
<div x-cloak x-show="activeTab === 'danger'">
<livewire:project.shared.danger :resource="$service" />
</div>
diff --git a/resources/views/livewire/project/shared/move-resource.blade.php b/resources/views/livewire/project/shared/move-resource.blade.php
new file mode 100644
index 0000000000..6dec754909
--- /dev/null
+++ b/resources/views/livewire/project/shared/move-resource.blade.php
@@ -0,0 +1,25 @@
+<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>