@forelse ($project->environments->sortBy('created_at') as $environment)
-
+
From 5f1adc98d8802130489717e52923281149a2bcd6 Mon Sep 17 00:00:00 2001
From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Date: Fri, 22 Nov 2024 15:45:46 +0100
Subject: [PATCH 08/32] fix environment select
---
app/Livewire/Project/Resource/EnvironmentSelect.php | 4 ++--
.../livewire/project/resource/environment-select.blade.php | 7 +++----
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/app/Livewire/Project/Resource/EnvironmentSelect.php b/app/Livewire/Project/Resource/EnvironmentSelect.php
index efb1b6ca2..a38d750da 100644
--- a/app/Livewire/Project/Resource/EnvironmentSelect.php
+++ b/app/Livewire/Project/Resource/EnvironmentSelect.php
@@ -15,7 +15,7 @@ class EnvironmentSelect extends Component
public function mount()
{
- $this->selectedEnvironment = request()->route('environment_name');
+ $this->selectedEnvironment = request()->route('environment_uuid');
$this->project_uuid = request()->route('project_uuid');
}
@@ -28,7 +28,7 @@ class EnvironmentSelect extends Component
} else {
return redirect()->route('project.resource.index', [
'project_uuid' => $this->project_uuid,
- 'environment_name' => $value,
+ 'environment_uuid' => $value,
]);
}
}
diff --git a/resources/views/livewire/project/resource/environment-select.blade.php b/resources/views/livewire/project/resource/environment-select.blade.php
index c03466d28..725b282a8 100644
--- a/resources/views/livewire/project/resource/environment-select.blade.php
+++ b/resources/views/livewire/project/resource/environment-select.blade.php
@@ -1,8 +1,7 @@
-
-
@foreach ($environments as $environment)
-
+
@endforeach
+
+
From d183d33025d0a39d5220804034e4a0999a94e3e9 Mon Sep 17 00:00:00 2001
From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Date: Fri, 22 Nov 2024 15:51:25 +0100
Subject: [PATCH 09/32] boarding new uuid
---
app/Livewire/Boarding/Index.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/Livewire/Boarding/Index.php b/app/Livewire/Boarding/Index.php
index b6c799c4e..897737907 100644
--- a/app/Livewire/Boarding/Index.php
+++ b/app/Livewire/Boarding/Index.php
@@ -9,6 +9,7 @@ use App\Models\Server;
use App\Models\Team;
use Illuminate\Support\Collection;
use Livewire\Component;
+use Visus\Cuid2\Cuid2;
class Index extends Component
{
@@ -340,6 +341,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
$this->createdProject = Project::create([
'name' => 'My first project',
'team_id' => currentTeam()->id,
+ 'uuid' => (string) new Cuid2,
]);
$this->currentState = 'create-resource';
}
@@ -352,7 +354,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
'project.resource.create',
[
'project_uuid' => $this->createdProject->uuid,
- 'environment_name' => 'production',
+ 'environment_uuid' => $this->createdProject->environments->first()->uuid,
'server' => $this->createdServer->id,
]
);
From 9630efce67a78e2418afdf065c517a6ade43fd2f Mon Sep 17 00:00:00 2001
From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Date: Fri, 22 Nov 2024 15:52:36 +0100
Subject: [PATCH 10/32] uuid deplyment
---
app/Livewire/Project/Application/Deployment/Show.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/Livewire/Project/Application/Deployment/Show.php b/app/Livewire/Project/Application/Deployment/Show.php
index 04170fa28..dba0d8ae5 100644
--- a/app/Livewire/Project/Application/Deployment/Show.php
+++ b/app/Livewire/Project/Application/Deployment/Show.php
@@ -26,7 +26,7 @@ class Show extends Component
if (! $project) {
return redirect()->route('dashboard');
}
- $environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
+ $environment = $project->load(['environments'])->environments->where('uuid', request()->route('environment_uuid'))->first()->load(['applications']);
if (! $environment) {
return redirect()->route('dashboard');
}
@@ -46,7 +46,7 @@ class Show extends Component
if (! $application_deployment_queue) {
return redirect()->route('project.application.deployment.index', [
'project_uuid' => $project->uuid,
- 'environment_name' => $environment->name,
+ 'environment_uuid' => $environment->uuid,
'application_uuid' => $application->uuid,
]);
}
From 5a8bff5e96404e650454789e320e563916ac0451 Mon Sep 17 00:00:00 2001
From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Date: Fri, 22 Nov 2024 15:53:11 +0100
Subject: [PATCH 11/32] Update Heading.php
---
app/Livewire/Project/Application/Heading.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/Livewire/Project/Application/Heading.php b/app/Livewire/Project/Application/Heading.php
index 3edb21974..b0c150299 100644
--- a/app/Livewire/Project/Application/Heading.php
+++ b/app/Livewire/Project/Application/Heading.php
@@ -90,7 +90,7 @@ class Heading extends Component
'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $this->deploymentUuid,
- 'environment_name' => $this->parameters['environment_name'],
+ 'environment_uuid' => $this->parameters['environment_uuid'],
]);
}
@@ -132,7 +132,7 @@ class Heading extends Component
'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $this->deploymentUuid,
- 'environment_name' => $this->parameters['environment_name'],
+ 'environment_uuid' => $this->parameters['environment_uuid'],
]);
}
From 277fd78769cf109487ad61f2df913b034015eeb5 Mon Sep 17 00:00:00 2001
From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Date: Fri, 22 Nov 2024 16:03:20 +0100
Subject: [PATCH 12/32] new uuid routes
---
app/Livewire/Project/AddEmpty.php | 2 ++
.../Project/Application/Configuration.php | 2 +-
.../Project/Application/Deployment/Index.php | 2 +-
app/Livewire/Project/Application/Previews.php | 2 +-
app/Livewire/Project/Application/Rollback.php | 2 +-
app/Livewire/Project/CloneMe.php | 8 ++++---
.../Project/Database/Backup/Execution.php | 2 +-
.../Project/Database/Backup/Index.php | 4 ++--
.../Project/Database/Configuration.php | 2 +-
app/Livewire/Project/EnvironmentEdit.php | 9 +++++---
app/Livewire/Project/New/DockerCompose.php | 4 ++--
app/Livewire/Project/New/DockerImage.php | 4 ++--
app/Livewire/Project/New/EmptyProject.php | 4 +++-
.../Project/New/GithubPrivateRepository.php | 4 ++--
.../New/GithubPrivateRepositoryDeployKey.php | 4 ++--
.../Project/New/PublicGitRepository.php | 8 +++----
app/Livewire/Project/New/Select.php | 18 ++++-----------
app/Livewire/Project/New/SimpleDockerfile.php | 4 ++--
app/Livewire/Project/Resource/Create.php | 6 ++---
app/Livewire/Project/Resource/Index.php | 22 +++++++++----------
app/Livewire/Project/Shared/Danger.php | 6 ++---
app/Livewire/Project/Shared/Destination.php | 2 +-
.../Project/Shared/ResourceOperations.php | 16 +++++++-------
.../SharedVariables/Environment/Show.php | 4 ++--
app/Livewire/Source/Github/Change.php | 4 ++--
app/Models/Application.php | 4 ++--
app/Models/Project.php | 18 ++-------------
app/Models/Service.php | 4 ++--
app/Models/StandaloneClickhouse.php | 2 +-
app/Models/StandaloneDragonfly.php | 2 +-
app/Models/StandaloneKeydb.php | 2 +-
app/Models/StandaloneMariadb.php | 2 +-
app/Models/StandaloneMongodb.php | 2 +-
app/Models/StandaloneMysql.php | 2 +-
app/Models/StandalonePostgresql.php | 2 +-
app/Models/StandaloneRedis.php | 2 +-
.../resources/breadcrumbs.blade.php | 4 +++-
.../project/environment-edit.blade.php | 2 +-
.../livewire/project/resource/index.blade.php | 8 +++----
39 files changed, 94 insertions(+), 107 deletions(-)
diff --git a/app/Livewire/Project/AddEmpty.php b/app/Livewire/Project/AddEmpty.php
index fd976548a..07873c059 100644
--- a/app/Livewire/Project/AddEmpty.php
+++ b/app/Livewire/Project/AddEmpty.php
@@ -5,6 +5,7 @@ namespace App\Livewire\Project;
use App\Models\Project;
use Livewire\Attributes\Validate;
use Livewire\Component;
+use Visus\Cuid2\Cuid2;
class AddEmpty extends Component
{
@@ -22,6 +23,7 @@ class AddEmpty extends Component
'name' => $this->name,
'description' => $this->description,
'team_id' => currentTeam()->id,
+ 'uuid' => (string) new Cuid2,
]);
return redirect()->route('project.show', $project->uuid);
diff --git a/app/Livewire/Project/Application/Configuration.php b/app/Livewire/Project/Application/Configuration.php
index d4ec8f581..2b781a8c7 100644
--- a/app/Livewire/Project/Application/Configuration.php
+++ b/app/Livewire/Project/Application/Configuration.php
@@ -20,7 +20,7 @@ class Configuration extends Component
if (! $project) {
return redirect()->route('dashboard');
}
- $environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
+ $environment = $project->load(['environments'])->environments->where('uuid', request()->route('environment_uuid'))->first()->load(['applications']);
if (! $environment) {
return redirect()->route('dashboard');
}
diff --git a/app/Livewire/Project/Application/Deployment/Index.php b/app/Livewire/Project/Application/Deployment/Index.php
index 4f761c2cf..b847c40ef 100644
--- a/app/Livewire/Project/Application/Deployment/Index.php
+++ b/app/Livewire/Project/Application/Deployment/Index.php
@@ -34,7 +34,7 @@ class Index extends Component
if (! $project) {
return redirect()->route('dashboard');
}
- $environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
+ $environment = $project->load(['environments'])->environments->where('uuid', request()->route('environment_uuid'))->first()->load(['applications']);
if (! $environment) {
return redirect()->route('dashboard');
}
diff --git a/app/Livewire/Project/Application/Previews.php b/app/Livewire/Project/Application/Previews.php
index d42bf03d7..bdf62706c 100644
--- a/app/Livewire/Project/Application/Previews.php
+++ b/app/Livewire/Project/Application/Previews.php
@@ -171,7 +171,7 @@ class Previews extends Component
'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $this->deployment_uuid,
- 'environment_name' => $this->parameters['environment_name'],
+ 'environment_uuid' => $this->parameters['environment_uuid'],
]);
} catch (\Throwable $e) {
return handleError($e, $this);
diff --git a/app/Livewire/Project/Application/Rollback.php b/app/Livewire/Project/Application/Rollback.php
index 1e58a1458..ff5db1e08 100644
--- a/app/Livewire/Project/Application/Rollback.php
+++ b/app/Livewire/Project/Application/Rollback.php
@@ -37,7 +37,7 @@ class Rollback extends Component
'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $deployment_uuid,
- 'environment_name' => $this->parameters['environment_name'],
+ 'environment_uuid' => $this->parameters['environment_uuid'],
]);
}
diff --git a/app/Livewire/Project/CloneMe.php b/app/Livewire/Project/CloneMe.php
index 4d2bc6589..e2013a50d 100644
--- a/app/Livewire/Project/CloneMe.php
+++ b/app/Livewire/Project/CloneMe.php
@@ -12,7 +12,7 @@ class CloneMe extends Component
{
public string $project_uuid;
- public string $environment_name;
+ public string $environment_uuid;
public int $project_id;
@@ -44,7 +44,7 @@ class CloneMe extends Component
{
$this->project_uuid = $project_uuid;
$this->project = Project::where('uuid', $project_uuid)->firstOrFail();
- $this->environment = $this->project->environments->where('name', $this->environment_name)->first();
+ $this->environment = $this->project->environments->where('uuid', $this->environment_uuid)->first();
$this->project_id = $this->project->id;
$this->servers = currentTeam()->servers;
$this->newName = str($this->project->name.'-clone-'.(string) new Cuid2)->slug();
@@ -89,6 +89,7 @@ class CloneMe extends Component
if ($this->environment->name !== 'production') {
$project->environments()->create([
'name' => $this->environment->name,
+ 'uuid' => (string) new Cuid2,
]);
}
$environment = $project->environments->where('name', $this->environment->name)->first();
@@ -100,6 +101,7 @@ class CloneMe extends Component
$project = $this->project;
$environment = $this->project->environments()->create([
'name' => $this->newName,
+ 'uuid' => (string) new Cuid2,
]);
}
$applications = $this->environment->applications;
@@ -183,7 +185,7 @@ class CloneMe extends Component
return redirect()->route('project.resource.index', [
'project_uuid' => $project->uuid,
- 'environment_name' => $environment->name,
+ 'environment_uuid' => $environment->uuid,
]);
} catch (\Exception $e) {
return handleError($e, $this);
diff --git a/app/Livewire/Project/Database/Backup/Execution.php b/app/Livewire/Project/Database/Backup/Execution.php
index 564091659..4ac3b2e2c 100644
--- a/app/Livewire/Project/Database/Backup/Execution.php
+++ b/app/Livewire/Project/Database/Backup/Execution.php
@@ -22,7 +22,7 @@ class Execution extends Component
if (! $project) {
return redirect()->route('dashboard');
}
- $environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
+ $environment = $project->load(['environments'])->environments->where('uuid', request()->route('environment_uuid'))->first()->load(['applications']);
if (! $environment) {
return redirect()->route('dashboard');
}
diff --git a/app/Livewire/Project/Database/Backup/Index.php b/app/Livewire/Project/Database/Backup/Index.php
index 9ff2f48d5..2df32ec7b 100644
--- a/app/Livewire/Project/Database/Backup/Index.php
+++ b/app/Livewire/Project/Database/Backup/Index.php
@@ -14,7 +14,7 @@ class Index extends Component
if (! $project) {
return redirect()->route('dashboard');
}
- $environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
+ $environment = $project->load(['environments'])->environments->where('uuid', request()->route('environment_uuid'))->first()->load(['applications']);
if (! $environment) {
return redirect()->route('dashboard');
}
@@ -31,7 +31,7 @@ class Index extends Component
) {
return redirect()->route('project.database.configuration', [
'project_uuid' => $project->uuid,
- 'environment_name' => $environment->name,
+ 'environment_uuid' => $environment->uuid,
'database_uuid' => $database->uuid,
]);
}
diff --git a/app/Livewire/Project/Database/Configuration.php b/app/Livewire/Project/Database/Configuration.php
index e14b27cf6..bbe8e81f6 100644
--- a/app/Livewire/Project/Database/Configuration.php
+++ b/app/Livewire/Project/Database/Configuration.php
@@ -14,7 +14,7 @@ class Configuration extends Component
if (! $project) {
return redirect()->route('dashboard');
}
- $environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
+ $environment = $project->load(['environments'])->environments->where('uuid', request()->route('environment_uuid'))->first()->load(['applications']);
if (! $environment) {
return redirect()->route('dashboard');
}
diff --git a/app/Livewire/Project/EnvironmentEdit.php b/app/Livewire/Project/EnvironmentEdit.php
index f48220b3d..e98b088ec 100644
--- a/app/Livewire/Project/EnvironmentEdit.php
+++ b/app/Livewire/Project/EnvironmentEdit.php
@@ -23,11 +23,11 @@ class EnvironmentEdit extends Component
#[Validate(['nullable', 'string', 'max:255'])]
public ?string $description = null;
- public function mount(string $project_uuid, string $environment_name)
+ public function mount(string $project_uuid, string $environment_uuid)
{
try {
$this->project = Project::ownedByCurrentTeam()->where('uuid', $project_uuid)->firstOrFail();
- $this->environment = $this->project->environments()->where('name', $environment_name)->firstOrFail();
+ $this->environment = $this->project->environments()->where('uuid', $environment_uuid)->firstOrFail();
$this->syncData();
} catch (\Throwable $e) {
return handleError($e, $this);
@@ -52,7 +52,10 @@ class EnvironmentEdit extends Component
{
try {
$this->syncData(true);
- $this->redirectRoute('project.environment.edit', ['environment_name' => $this->environment->name, 'project_uuid' => $this->project->uuid]);
+ $this->redirectRoute('project.environment.edit', [
+ 'environment_uuid' => $this->environment->uuid,
+ 'project_uuid' => $this->project->uuid,
+ ]);
} catch (\Throwable $e) {
return handleError($e, $this);
}
diff --git a/app/Livewire/Project/New/DockerCompose.php b/app/Livewire/Project/New/DockerCompose.php
index 199a20cf6..c1361c7ac 100644
--- a/app/Livewire/Project/New/DockerCompose.php
+++ b/app/Livewire/Project/New/DockerCompose.php
@@ -59,7 +59,7 @@ class DockerCompose extends Component
}
$project = Project::where('uuid', $this->parameters['project_uuid'])->first();
- $environment = $project->load(['environments'])->environments->where('name', $this->parameters['environment_name'])->first();
+ $environment = $project->load(['environments'])->environments->where('uuid', $this->parameters['environment_uuid'])->first();
$destination_uuid = $this->query['destination'];
$destination = StandaloneDocker::where('uuid', $destination_uuid)->first();
@@ -96,7 +96,7 @@ class DockerCompose extends Component
return redirect()->route('project.service.configuration', [
'service_uuid' => $service->uuid,
- 'environment_name' => $environment->name,
+ 'environment_uuid' => $environment->uuid,
'project_uuid' => $project->uuid,
]);
} catch (\Throwable $e) {
diff --git a/app/Livewire/Project/New/DockerImage.php b/app/Livewire/Project/New/DockerImage.php
index 417fb2ea0..942924437 100644
--- a/app/Livewire/Project/New/DockerImage.php
+++ b/app/Livewire/Project/New/DockerImage.php
@@ -45,7 +45,7 @@ class DockerImage extends Component
$destination_class = $destination->getMorphClass();
$project = Project::where('uuid', $this->parameters['project_uuid'])->first();
- $environment = $project->load(['environments'])->environments->where('name', $this->parameters['environment_name'])->first();
+ $environment = $project->load(['environments'])->environments->where('uuid', $this->parameters['environment_uuid'])->first();
$application = Application::create([
'name' => 'docker-image-'.new Cuid2,
'repository_project_id' => 0,
@@ -69,7 +69,7 @@ class DockerImage extends Component
return redirect()->route('project.application.configuration', [
'application_uuid' => $application->uuid,
- 'environment_name' => $environment->name,
+ 'environment_uuid' => $environment->uuid,
'project_uuid' => $project->uuid,
]);
}
diff --git a/app/Livewire/Project/New/EmptyProject.php b/app/Livewire/Project/New/EmptyProject.php
index 28249b442..54cfc4b4d 100644
--- a/app/Livewire/Project/New/EmptyProject.php
+++ b/app/Livewire/Project/New/EmptyProject.php
@@ -4,6 +4,7 @@ namespace App\Livewire\Project\New;
use App\Models\Project;
use Livewire\Component;
+use Visus\Cuid2\Cuid2;
class EmptyProject extends Component
{
@@ -12,8 +13,9 @@ class EmptyProject extends Component
$project = Project::create([
'name' => generate_random_name(),
'team_id' => currentTeam()->id,
+ 'uuid' => (string) new Cuid2,
]);
- return redirect()->route('project.show', ['project_uuid' => $project->uuid, 'environment_name' => 'production']);
+ return redirect()->route('project.show', ['project_uuid' => $project->uuid, 'environment_uuid' => $project->environments->first()->uuid]);
}
}
diff --git a/app/Livewire/Project/New/GithubPrivateRepository.php b/app/Livewire/Project/New/GithubPrivateRepository.php
index 2f4f5a25c..370d00555 100644
--- a/app/Livewire/Project/New/GithubPrivateRepository.php
+++ b/app/Livewire/Project/New/GithubPrivateRepository.php
@@ -177,7 +177,7 @@ class GithubPrivateRepository extends Component
$destination_class = $destination->getMorphClass();
$project = Project::where('uuid', $this->parameters['project_uuid'])->first();
- $environment = $project->load(['environments'])->environments->where('name', $this->parameters['environment_name'])->first();
+ $environment = $project->load(['environments'])->environments->where('uuid', $this->parameters['environment_uuid'])->first();
$application = Application::create([
'name' => generate_application_name($this->selected_repository_owner.'/'.$this->selected_repository_repo, $this->selected_branch_name),
@@ -211,7 +211,7 @@ class GithubPrivateRepository extends Component
return redirect()->route('project.application.configuration', [
'application_uuid' => $application->uuid,
- 'environment_name' => $environment->name,
+ 'environment_uuid' => $environment->uuid,
'project_uuid' => $project->uuid,
]);
} catch (\Throwable $e) {
diff --git a/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php b/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php
index b46c4a794..01b0c9ae8 100644
--- a/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php
+++ b/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php
@@ -136,7 +136,7 @@ class GithubPrivateRepositoryDeployKey extends Component
$this->get_git_source();
$project = Project::where('uuid', $this->parameters['project_uuid'])->first();
- $environment = $project->load(['environments'])->environments->where('name', $this->parameters['environment_name'])->first();
+ $environment = $project->load(['environments'])->environments->where('uuid', $this->parameters['environment_uuid'])->first();
if ($this->git_source === 'other') {
$application_init = [
'name' => generate_random_name(),
@@ -184,7 +184,7 @@ class GithubPrivateRepositoryDeployKey extends Component
return redirect()->route('project.application.configuration', [
'application_uuid' => $application->uuid,
- 'environment_name' => $environment->name,
+ 'environment_uuid' => $environment->uuid,
'project_uuid' => $project->uuid,
]);
} catch (\Throwable $e) {
diff --git a/app/Livewire/Project/New/PublicGitRepository.php b/app/Livewire/Project/New/PublicGitRepository.php
index bd35dccef..2f2331fc0 100644
--- a/app/Livewire/Project/New/PublicGitRepository.php
+++ b/app/Livewire/Project/New/PublicGitRepository.php
@@ -225,7 +225,7 @@ class PublicGitRepository extends Component
$this->validate();
$destination_uuid = $this->query['destination'];
$project_uuid = $this->parameters['project_uuid'];
- $environment_name = $this->parameters['environment_name'];
+ $environment_uuid = $this->parameters['environment_uuid'];
$destination = StandaloneDocker::where('uuid', $destination_uuid)->first();
if (! $destination) {
@@ -237,7 +237,7 @@ class PublicGitRepository extends Component
$destination_class = $destination->getMorphClass();
$project = Project::where('uuid', $project_uuid)->first();
- $environment = $project->load(['environments'])->environments->where('name', $environment_name)->first();
+ $environment = $project->load(['environments'])->environments->where('uuid', $environment_uuid)->first();
if ($this->build_pack === 'dockercompose' && isDev() && $this->new_compose_services) {
$server = $destination->server;
@@ -260,7 +260,7 @@ class PublicGitRepository extends Component
return redirect()->route('project.service.configuration', [
'service_uuid' => $service->uuid,
- 'environment_name' => $environment->name,
+ 'environment_uuid' => $environment->uuid,
'project_uuid' => $project->uuid,
]);
@@ -319,7 +319,7 @@ class PublicGitRepository extends Component
return redirect()->route('project.application.configuration', [
'application_uuid' => $application->uuid,
- 'environment_name' => $environment->name,
+ 'environment_uuid' => $environment->uuid,
'project_uuid' => $project->uuid,
]);
} catch (\Throwable $e) {
diff --git a/app/Livewire/Project/New/Select.php b/app/Livewire/Project/New/Select.php
index 3dedc11af..7ef688718 100644
--- a/app/Livewire/Project/New/Select.php
+++ b/app/Livewire/Project/New/Select.php
@@ -61,7 +61,7 @@ class Select extends Component
}
$projectUuid = data_get($this->parameters, 'project_uuid');
$this->environments = Project::whereUuid($projectUuid)->first()->environments;
- $this->selectedEnvironment = data_get($this->parameters, 'environment_name');
+ $this->selectedEnvironment = data_get($this->parameters, 'environment_uuid');
}
public function render()
@@ -73,20 +73,10 @@ class Select extends Component
{
return redirect()->route('project.resource.create', [
'project_uuid' => $this->parameters['project_uuid'],
- 'environment_name' => $this->selectedEnvironment,
+ 'environment_uuid' => $this->selectedEnvironment,
]);
}
- // public function addExistingPostgresql()
- // {
- // try {
- // instantCommand("psql {$this->existingPostgresqlUrl} -c 'SELECT 1'");
- // $this->dispatch('success', 'Successfully connected to the database.');
- // } catch (\Throwable $e) {
- // return handleError($e, $this);
- // }
- // }
-
public function loadServices()
{
$services = get_service_templates(true);
@@ -304,7 +294,7 @@ class Select extends Component
return redirect()->route('project.resource.create', [
'project_uuid' => $this->parameters['project_uuid'],
- 'environment_name' => $this->parameters['environment_name'],
+ 'environment_uuid' => $this->parameters['environment_uuid'],
'type' => $this->type,
'destination' => $this->destination_uuid,
'server_id' => $this->server_id,
@@ -319,7 +309,7 @@ class Select extends Component
} else {
return redirect()->route('project.resource.create', [
'project_uuid' => $this->parameters['project_uuid'],
- 'environment_name' => $this->parameters['environment_name'],
+ 'environment_uuid' => $this->parameters['environment_uuid'],
'type' => $this->type,
'destination' => $this->destination_uuid,
'server_id' => $this->server_id,
diff --git a/app/Livewire/Project/New/SimpleDockerfile.php b/app/Livewire/Project/New/SimpleDockerfile.php
index 3c7f42329..c3ed6039a 100644
--- a/app/Livewire/Project/New/SimpleDockerfile.php
+++ b/app/Livewire/Project/New/SimpleDockerfile.php
@@ -46,7 +46,7 @@ CMD ["nginx", "-g", "daemon off;"]
$destination_class = $destination->getMorphClass();
$project = Project::where('uuid', $this->parameters['project_uuid'])->first();
- $environment = $project->load(['environments'])->environments->where('name', $this->parameters['environment_name'])->first();
+ $environment = $project->load(['environments'])->environments->where('uuid', $this->parameters['environment_uuid'])->first();
$port = get_port_from_dockerfile($this->dockerfile);
if (! $port) {
@@ -78,7 +78,7 @@ CMD ["nginx", "-g", "daemon off;"]
return redirect()->route('project.application.configuration', [
'application_uuid' => $application->uuid,
- 'environment_name' => $environment->name,
+ 'environment_uuid' => $environment->uuid,
'project_uuid' => $project->uuid,
]);
}
diff --git a/app/Livewire/Project/Resource/Create.php b/app/Livewire/Project/Resource/Create.php
index 9266a57fc..48c396dc0 100644
--- a/app/Livewire/Project/Resource/Create.php
+++ b/app/Livewire/Project/Resource/Create.php
@@ -25,7 +25,7 @@ class Create extends Component
return redirect()->route('dashboard');
}
$this->project = $project;
- $environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first();
+ $environment = $project->load(['environments'])->environments->where('uuid', request()->route('environment_uuid'))->first();
if (! $environment) {
return redirect()->route('dashboard');
}
@@ -57,7 +57,7 @@ class Create extends Component
return redirect()->route('project.database.configuration', [
'project_uuid' => $project->uuid,
- 'environment_name' => $environment->name,
+ 'environment_uuid' => $environment->uuid,
'database_uuid' => $database->uuid,
]);
}
@@ -106,7 +106,7 @@ class Create extends Component
return redirect()->route('project.service.configuration', [
'service_uuid' => $service->uuid,
- 'environment_name' => $environment->name,
+ 'environment_uuid' => $environment->uuid,
'project_uuid' => $project->uuid,
]);
}
diff --git a/app/Livewire/Project/Resource/Index.php b/app/Livewire/Project/Resource/Index.php
index 283496887..fc394e88f 100644
--- a/app/Livewire/Project/Resource/Index.php
+++ b/app/Livewire/Project/Resource/Index.php
@@ -41,7 +41,7 @@ class Index extends Component
if (! $project) {
return redirect()->route('dashboard');
}
- $environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first();
+ $environment = $project->load(['environments'])->environments->where('uuid', request()->route('environment_uuid'))->first();
if (! $environment) {
return redirect()->route('dashboard');
}
@@ -52,7 +52,7 @@ class Index extends Component
if (data_get($application, 'environment.project.uuid')) {
$application->hrefLink = route('project.application.configuration', [
'project_uuid' => data_get($application, 'environment.project.uuid'),
- 'environment_name' => data_get($application, 'environment.name'),
+ 'environment_uuid' => data_get($application, 'environment.uuid'),
'application_uuid' => data_get($application, 'uuid'),
]);
}
@@ -64,7 +64,7 @@ class Index extends Component
if (data_get($postgresql, 'environment.project.uuid')) {
$postgresql->hrefLink = route('project.database.configuration', [
'project_uuid' => data_get($postgresql, 'environment.project.uuid'),
- 'environment_name' => data_get($postgresql, 'environment.name'),
+ 'environment_uuid' => data_get($postgresql, 'environment.uuid'),
'database_uuid' => data_get($postgresql, 'uuid'),
]);
}
@@ -76,7 +76,7 @@ class Index extends Component
if (data_get($redis, 'environment.project.uuid')) {
$redis->hrefLink = route('project.database.configuration', [
'project_uuid' => data_get($redis, 'environment.project.uuid'),
- 'environment_name' => data_get($redis, 'environment.name'),
+ 'environment_uuid' => data_get($redis, 'environment.uuid'),
'database_uuid' => data_get($redis, 'uuid'),
]);
}
@@ -88,7 +88,7 @@ class Index extends Component
if (data_get($mongodb, 'environment.project.uuid')) {
$mongodb->hrefLink = route('project.database.configuration', [
'project_uuid' => data_get($mongodb, 'environment.project.uuid'),
- 'environment_name' => data_get($mongodb, 'environment.name'),
+ 'environment_uuid' => data_get($mongodb, 'environment.uuid'),
'database_uuid' => data_get($mongodb, 'uuid'),
]);
}
@@ -100,7 +100,7 @@ class Index extends Component
if (data_get($mysql, 'environment.project.uuid')) {
$mysql->hrefLink = route('project.database.configuration', [
'project_uuid' => data_get($mysql, 'environment.project.uuid'),
- 'environment_name' => data_get($mysql, 'environment.name'),
+ 'environment_uuid' => data_get($mysql, 'environment.uuid'),
'database_uuid' => data_get($mysql, 'uuid'),
]);
}
@@ -112,7 +112,7 @@ class Index extends Component
if (data_get($mariadb, 'environment.project.uuid')) {
$mariadb->hrefLink = route('project.database.configuration', [
'project_uuid' => data_get($mariadb, 'environment.project.uuid'),
- 'environment_name' => data_get($mariadb, 'environment.name'),
+ 'environment_uuid' => data_get($mariadb, 'environment.uuid'),
'database_uuid' => data_get($mariadb, 'uuid'),
]);
}
@@ -124,7 +124,7 @@ class Index extends Component
if (data_get($keydb, 'environment.project.uuid')) {
$keydb->hrefLink = route('project.database.configuration', [
'project_uuid' => data_get($keydb, 'environment.project.uuid'),
- 'environment_name' => data_get($keydb, 'environment.name'),
+ 'environment_uuid' => data_get($keydb, 'environment.uuid'),
'database_uuid' => data_get($keydb, 'uuid'),
]);
}
@@ -136,7 +136,7 @@ class Index extends Component
if (data_get($dragonfly, 'environment.project.uuid')) {
$dragonfly->hrefLink = route('project.database.configuration', [
'project_uuid' => data_get($dragonfly, 'environment.project.uuid'),
- 'environment_name' => data_get($dragonfly, 'environment.name'),
+ 'environment_uuid' => data_get($dragonfly, 'environment.uuid'),
'database_uuid' => data_get($dragonfly, 'uuid'),
]);
}
@@ -148,7 +148,7 @@ class Index extends Component
if (data_get($clickhouse, 'environment.project.uuid')) {
$clickhouse->hrefLink = route('project.database.configuration', [
'project_uuid' => data_get($clickhouse, 'environment.project.uuid'),
- 'environment_name' => data_get($clickhouse, 'environment.name'),
+ 'environment_uuid' => data_get($clickhouse, 'environment.uuid'),
'database_uuid' => data_get($clickhouse, 'uuid'),
]);
}
@@ -160,7 +160,7 @@ class Index extends Component
if (data_get($service, 'environment.project.uuid')) {
$service->hrefLink = route('project.service.configuration', [
'project_uuid' => data_get($service, 'environment.project.uuid'),
- 'environment_name' => data_get($service, 'environment.name'),
+ 'environment_uuid' => data_get($service, 'environment.uuid'),
'service_uuid' => data_get($service, 'uuid'),
]);
$service->status = $service->status();
diff --git a/app/Livewire/Project/Shared/Danger.php b/app/Livewire/Project/Shared/Danger.php
index a0b4ac2c4..7da48f9fb 100644
--- a/app/Livewire/Project/Shared/Danger.php
+++ b/app/Livewire/Project/Shared/Danger.php
@@ -20,7 +20,7 @@ class Danger extends Component
public $projectUuid;
- public $environmentName;
+ public $environmentUuid;
public bool $delete_configurations = true;
@@ -39,7 +39,7 @@ class Danger extends Component
$parameters = get_route_parameters();
$this->modalId = new Cuid2;
$this->projectUuid = data_get($parameters, 'project_uuid');
- $this->environmentName = data_get($parameters, 'environment_name');
+ $this->environmentUuid = data_get($parameters, 'environment_uuid');
if ($this->resource === null) {
if (isset($parameters['service_uuid'])) {
@@ -107,7 +107,7 @@ class Danger extends Component
return redirect()->route('project.resource.index', [
'project_uuid' => $this->projectUuid,
- 'environment_name' => $this->environmentName,
+ 'environment_uuid' => $this->environmentUuid,
]);
} catch (\Throwable $e) {
return handleError($e, $this);
diff --git a/app/Livewire/Project/Shared/Destination.php b/app/Livewire/Project/Shared/Destination.php
index c305e817c..e28ff1d5b 100644
--- a/app/Livewire/Project/Shared/Destination.php
+++ b/app/Livewire/Project/Shared/Destination.php
@@ -85,7 +85,7 @@ class Destination extends Component
'project_uuid' => data_get($this->resource, 'environment.project.uuid'),
'application_uuid' => data_get($this->resource, 'uuid'),
'deployment_uuid' => $deployment_uuid,
- 'environment_name' => data_get($this->resource, 'environment.name'),
+ 'environment_uuid' => data_get($this->resource, 'environment.uuid'),
]);
}
diff --git a/app/Livewire/Project/Shared/ResourceOperations.php b/app/Livewire/Project/Shared/ResourceOperations.php
index e67df6aa9..81313c133 100644
--- a/app/Livewire/Project/Shared/ResourceOperations.php
+++ b/app/Livewire/Project/Shared/ResourceOperations.php
@@ -15,7 +15,7 @@ class ResourceOperations extends Component
public $projectUuid;
- public $environmentName;
+ public $environmentUuid;
public $projects;
@@ -25,7 +25,7 @@ class ResourceOperations extends Component
{
$parameters = get_route_parameters();
$this->projectUuid = data_get($parameters, 'project_uuid');
- $this->environmentName = data_get($parameters, 'environment_name');
+ $this->environmentUuid = data_get($parameters, 'environment_uuid');
$this->projects = Project::ownedByCurrentTeam()->get();
$this->servers = currentTeam()->servers;
}
@@ -72,7 +72,7 @@ class ResourceOperations extends Component
}
$route = route('project.application.configuration', [
'project_uuid' => $this->projectUuid,
- 'environment_name' => $this->environmentName,
+ 'environment_uuid' => $this->environmentUuid,
'application_uuid' => $new_resource->uuid,
]).'#resource-operations';
@@ -115,7 +115,7 @@ class ResourceOperations extends Component
}
$route = route('project.database.configuration', [
'project_uuid' => $this->projectUuid,
- 'environment_name' => $this->environmentName,
+ 'environment_uuid' => $this->environmentUuid,
'database_uuid' => $new_resource->uuid,
]).'#resource-operations';
@@ -141,7 +141,7 @@ class ResourceOperations extends Component
$new_resource->parse();
$route = route('project.service.configuration', [
'project_uuid' => $this->projectUuid,
- 'environment_name' => $this->environmentName,
+ 'environment_uuid' => $this->environmentUuid,
'service_uuid' => $new_resource->uuid,
]).'#resource-operations';
@@ -159,7 +159,7 @@ class ResourceOperations extends Component
if ($this->resource->type() === 'application') {
$route = route('project.application.configuration', [
'project_uuid' => $new_environment->project->uuid,
- 'environment_name' => $new_environment->name,
+ 'environment_uuid' => $new_environment->uuid,
'application_uuid' => $this->resource->uuid,
]).'#resource-operations';
@@ -167,7 +167,7 @@ class ResourceOperations extends Component
} elseif (str($this->resource->type())->startsWith('standalone-')) {
$route = route('project.database.configuration', [
'project_uuid' => $new_environment->project->uuid,
- 'environment_name' => $new_environment->name,
+ 'environment_uuid' => $new_environment->uuid,
'database_uuid' => $this->resource->uuid,
]).'#resource-operations';
@@ -175,7 +175,7 @@ class ResourceOperations extends Component
} elseif ($this->resource->type() === 'service') {
$route = route('project.service.configuration', [
'project_uuid' => $new_environment->project->uuid,
- 'environment_name' => $new_environment->name,
+ 'environment_uuid' => $new_environment->uuid,
'service_uuid' => $this->resource->uuid,
]).'#resource-operations';
diff --git a/app/Livewire/SharedVariables/Environment/Show.php b/app/Livewire/SharedVariables/Environment/Show.php
index daf1df212..68aa4f01b 100644
--- a/app/Livewire/SharedVariables/Environment/Show.php
+++ b/app/Livewire/SharedVariables/Environment/Show.php
@@ -42,8 +42,8 @@ class Show extends Component
public function mount()
{
$this->parameters = get_route_parameters();
- $this->project = Project::ownedByCurrentTeam()->where('uuid', request()->route('project_uuid'))->first();
- $this->environment = $this->project->environments()->where('name', request()->route('environment_name'))->first();
+ $this->project = Project::ownedByCurrentTeam()->where('uuid', request()->route('project_uuid'))->firstOrFail();
+ $this->environment = $this->project->environments()->where('uuid', request()->route('environment_uuid'))->firstOrFail();
}
public function render()
diff --git a/app/Livewire/Source/Github/Change.php b/app/Livewire/Source/Github/Change.php
index 07cef54f9..0e84756f8 100644
--- a/app/Livewire/Source/Github/Change.php
+++ b/app/Livewire/Source/Github/Change.php
@@ -116,14 +116,14 @@ class Change extends Component
} else {
$parameters = data_get(session('from'), 'parameters');
$back = data_get(session('from'), 'back');
- $environment_name = data_get($parameters, 'environment_name');
+ $environment_uuid = data_get($parameters, 'environment_uuid');
$project_uuid = data_get($parameters, 'project_uuid');
$type = data_get($parameters, 'type');
$destination = data_get($parameters, 'destination');
session()->forget('from');
return redirect()->route($back, [
- 'environment_name' => $environment_name,
+ 'environment_uuid' => $environment_uuid,
'project_uuid' => $project_uuid,
'type' => $type,
'destination' => $destination,
diff --git a/app/Models/Application.php b/app/Models/Application.php
index c284528f1..0e611931b 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -318,7 +318,7 @@ class Application extends BaseModel
if (data_get($this, 'environment.project.uuid')) {
return route('project.application.configuration', [
'project_uuid' => data_get($this, 'environment.project.uuid'),
- 'environment_name' => data_get($this, 'environment.name'),
+ 'environment_uuid' => data_get($this, 'environment.uuid'),
'application_uuid' => data_get($this, 'uuid'),
]);
}
@@ -331,7 +331,7 @@ class Application extends BaseModel
if (data_get($this, 'environment.project.uuid')) {
$route = route('project.application.scheduled-tasks', [
'project_uuid' => data_get($this, 'environment.project.uuid'),
- 'environment_name' => data_get($this, 'environment.name'),
+ 'environment_uuid' => data_get($this, 'environment.uuid'),
'application_uuid' => data_get($this, 'uuid'),
'task_uuid' => $task_uuid,
]);
diff --git a/app/Models/Project.php b/app/Models/Project.php
index f27e6c208..3b50b9b33 100644
--- a/app/Models/Project.php
+++ b/app/Models/Project.php
@@ -3,6 +3,7 @@
namespace App\Models;
use OpenApi\Attributes as OA;
+use Visus\Cuid2\Cuid2;
#[OA\Schema(
description: 'Project model',
@@ -24,8 +25,6 @@ class Project extends BaseModel
{
protected $guarded = [];
- protected $appends = ['default_environment'];
-
public static function ownedByCurrentTeam()
{
return Project::whereTeamId(currentTeam()->id)->orderByRaw('LOWER(name)');
@@ -40,6 +39,7 @@ class Project extends BaseModel
Environment::create([
'name' => 'production',
'project_id' => $project->id,
+ 'uuid' => (string) new Cuid2,
]);
});
static::deleting(function ($project) {
@@ -140,18 +140,4 @@ class Project extends BaseModel
{
return $this->postgresqls()->get()->merge($this->redis()->get())->merge($this->mongodbs()->get())->merge($this->mysqls()->get())->merge($this->mariadbs()->get())->merge($this->keydbs()->get())->merge($this->dragonflies()->get())->merge($this->clickhouses()->get());
}
-
- public function getDefaultEnvironmentAttribute()
- {
- $default = $this->environments()->where('name', 'production')->first();
- if ($default) {
- return $default->name;
- }
- $default = $this->environments()->get();
- if ($default->count() > 0) {
- return $default->sortBy('created_at')->first()->name;
- }
-
- return null;
- }
}
diff --git a/app/Models/Service.php b/app/Models/Service.php
index 6d3d2024b..1ba86a95f 100644
--- a/app/Models/Service.php
+++ b/app/Models/Service.php
@@ -1132,7 +1132,7 @@ class Service extends BaseModel
if (data_get($this, 'environment.project.uuid')) {
return route('project.service.configuration', [
'project_uuid' => data_get($this, 'environment.project.uuid'),
- 'environment_name' => data_get($this, 'environment.name'),
+ 'environment_uuid' => data_get($this, 'environment.uuid'),
'service_uuid' => data_get($this, 'uuid'),
]);
}
@@ -1145,7 +1145,7 @@ class Service extends BaseModel
if (data_get($this, 'environment.project.uuid')) {
$route = route('project.service.scheduled-tasks', [
'project_uuid' => data_get($this, 'environment.project.uuid'),
- 'environment_name' => data_get($this, 'environment.name'),
+ 'environment_uuid' => data_get($this, 'environment.uuid'),
'service_uuid' => data_get($this, 'uuid'),
'task_uuid' => $task_uuid,
]);
diff --git a/app/Models/StandaloneClickhouse.php b/app/Models/StandaloneClickhouse.php
index 6d66c6854..4776be4a8 100644
--- a/app/Models/StandaloneClickhouse.php
+++ b/app/Models/StandaloneClickhouse.php
@@ -169,7 +169,7 @@ class StandaloneClickhouse extends BaseModel
if (data_get($this, 'environment.project.uuid')) {
return route('project.database.configuration', [
'project_uuid' => data_get($this, 'environment.project.uuid'),
- 'environment_name' => data_get($this, 'environment.name'),
+ 'environment_uuid' => data_get($this, 'environment.uuid'),
'database_uuid' => data_get($this, 'uuid'),
]);
}
diff --git a/app/Models/StandaloneDragonfly.php b/app/Models/StandaloneDragonfly.php
index f7d83f0a3..6eaf81a14 100644
--- a/app/Models/StandaloneDragonfly.php
+++ b/app/Models/StandaloneDragonfly.php
@@ -174,7 +174,7 @@ class StandaloneDragonfly extends BaseModel
if (data_get($this, 'environment.project.uuid')) {
return route('project.database.configuration', [
'project_uuid' => data_get($this, 'environment.project.uuid'),
- 'environment_name' => data_get($this, 'environment.name'),
+ 'environment_uuid' => data_get($this, 'environment.uuid'),
'database_uuid' => data_get($this, 'uuid'),
]);
}
diff --git a/app/Models/StandaloneKeydb.php b/app/Models/StandaloneKeydb.php
index 083c743d9..b096d4bde 100644
--- a/app/Models/StandaloneKeydb.php
+++ b/app/Models/StandaloneKeydb.php
@@ -174,7 +174,7 @@ class StandaloneKeydb extends BaseModel
if (data_get($this, 'environment.project.uuid')) {
return route('project.database.configuration', [
'project_uuid' => data_get($this, 'environment.project.uuid'),
- 'environment_name' => data_get($this, 'environment.name'),
+ 'environment_uuid' => data_get($this, 'environment.uuid'),
'database_uuid' => data_get($this, 'uuid'),
]);
}
diff --git a/app/Models/StandaloneMariadb.php b/app/Models/StandaloneMariadb.php
index 833dad6c4..0b19d13c7 100644
--- a/app/Models/StandaloneMariadb.php
+++ b/app/Models/StandaloneMariadb.php
@@ -174,7 +174,7 @@ class StandaloneMariadb extends BaseModel
if (data_get($this, 'environment.project.uuid')) {
return route('project.database.configuration', [
'project_uuid' => data_get($this, 'environment.project.uuid'),
- 'environment_name' => data_get($this, 'environment.name'),
+ 'environment_uuid' => data_get($this, 'environment.uuid'),
'database_uuid' => data_get($this, 'uuid'),
]);
}
diff --git a/app/Models/StandaloneMongodb.php b/app/Models/StandaloneMongodb.php
index dd8893180..e4f400952 100644
--- a/app/Models/StandaloneMongodb.php
+++ b/app/Models/StandaloneMongodb.php
@@ -183,7 +183,7 @@ class StandaloneMongodb extends BaseModel
if (data_get($this, 'environment.project.uuid')) {
return route('project.database.configuration', [
'project_uuid' => data_get($this, 'environment.project.uuid'),
- 'environment_name' => data_get($this, 'environment.name'),
+ 'environment_uuid' => data_get($this, 'environment.uuid'),
'database_uuid' => data_get($this, 'uuid'),
]);
}
diff --git a/app/Models/StandaloneMysql.php b/app/Models/StandaloneMysql.php
index 710fea1bc..46556c04d 100644
--- a/app/Models/StandaloneMysql.php
+++ b/app/Models/StandaloneMysql.php
@@ -175,7 +175,7 @@ class StandaloneMysql extends BaseModel
if (data_get($this, 'environment.project.uuid')) {
return route('project.database.configuration', [
'project_uuid' => data_get($this, 'environment.project.uuid'),
- 'environment_name' => data_get($this, 'environment.name'),
+ 'environment_uuid' => data_get($this, 'environment.uuid'),
'database_uuid' => data_get($this, 'uuid'),
]);
}
diff --git a/app/Models/StandalonePostgresql.php b/app/Models/StandalonePostgresql.php
index 4a457a6cf..762afe884 100644
--- a/app/Models/StandalonePostgresql.php
+++ b/app/Models/StandalonePostgresql.php
@@ -170,7 +170,7 @@ class StandalonePostgresql extends BaseModel
if (data_get($this, 'environment.project.uuid')) {
return route('project.database.configuration', [
'project_uuid' => data_get($this, 'environment.project.uuid'),
- 'environment_name' => data_get($this, 'environment.name'),
+ 'environment_uuid' => data_get($this, 'environment.uuid'),
'database_uuid' => data_get($this, 'uuid'),
]);
}
diff --git a/app/Models/StandaloneRedis.php b/app/Models/StandaloneRedis.php
index 826bb951c..5aeb283a1 100644
--- a/app/Models/StandaloneRedis.php
+++ b/app/Models/StandaloneRedis.php
@@ -170,7 +170,7 @@ class StandaloneRedis extends BaseModel
if (data_get($this, 'environment.project.uuid')) {
return route('project.database.configuration', [
'project_uuid' => data_get($this, 'environment.project.uuid'),
- 'environment_name' => data_get($this, 'environment.name'),
+ 'environment_uuid' => data_get($this, 'environment.uuid'),
'database_uuid' => data_get($this, 'uuid'),
]);
}
diff --git a/resources/views/components/resources/breadcrumbs.blade.php b/resources/views/components/resources/breadcrumbs.blade.php
index f9733f63a..f1c1ca99e 100644
--- a/resources/views/components/resources/breadcrumbs.blade.php
+++ b/resources/views/components/resources/breadcrumbs.blade.php
@@ -21,7 +21,9 @@
{{ $this->parameters['environment_name'] }}
+ href="{{ route('project.resource.index', ['environment_uuid' => $this->parameters['environment_uuid'], 'project_uuid' => $this->parameters['project_uuid']]) }}">
+ {{ data_get($resource, 'environment.name', $this->parameters['environment_uuid']) }}
+
@if ($environment->isEmpty())
- + Add New Resource
@else
From 75491098a0bd3ba07d198c89d014af75e5b20899 Mon Sep 17 00:00:00 2001
From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Date: Fri, 22 Nov 2024 16:05:24 +0100
Subject: [PATCH 13/32] new notification links
---
app/Notifications/Application/DeploymentFailed.php | 5 ++++-
app/Notifications/Application/DeploymentSuccess.php | 5 ++++-
app/Notifications/Application/StatusChanged.php | 6 ++++--
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/app/Notifications/Application/DeploymentFailed.php b/app/Notifications/Application/DeploymentFailed.php
index fae8951fd..191f7bd2e 100644
--- a/app/Notifications/Application/DeploymentFailed.php
+++ b/app/Notifications/Application/DeploymentFailed.php
@@ -26,6 +26,8 @@ class DeploymentFailed extends Notification implements ShouldQueue
public string $project_uuid;
+ public string $environment_uuid;
+
public string $environment_name;
public ?string $deployment_url = null;
@@ -40,12 +42,13 @@ class DeploymentFailed extends Notification implements ShouldQueue
$this->preview = $preview;
$this->application_name = data_get($application, 'name');
$this->project_uuid = data_get($application, 'environment.project.uuid');
+ $this->environment_uuid = data_get($application, 'environment.uuid');
$this->environment_name = data_get($application, 'environment.name');
$this->fqdn = data_get($application, 'fqdn');
if (str($this->fqdn)->explode(',')->count() > 1) {
$this->fqdn = str($this->fqdn)->explode(',')->first();
}
- $this->deployment_url = base_url()."/project/{$this->project_uuid}/".urlencode($this->environment_name)."/application/{$this->application->uuid}/deployment/{$this->deployment_uuid}";
+ $this->deployment_url = base_url()."/project/{$this->project_uuid}/environments/{$this->environment_uuid}/application/{$this->application->uuid}/deployment/{$this->deployment_uuid}";
}
public function via(object $notifiable): array
diff --git a/app/Notifications/Application/DeploymentSuccess.php b/app/Notifications/Application/DeploymentSuccess.php
index bfdef9f25..05e3048c5 100644
--- a/app/Notifications/Application/DeploymentSuccess.php
+++ b/app/Notifications/Application/DeploymentSuccess.php
@@ -26,6 +26,8 @@ class DeploymentSuccess extends Notification implements ShouldQueue
public string $project_uuid;
+ public string $environment_uuid;
+
public string $environment_name;
public ?string $deployment_url = null;
@@ -40,12 +42,13 @@ class DeploymentSuccess extends Notification implements ShouldQueue
$this->preview = $preview;
$this->application_name = data_get($application, 'name');
$this->project_uuid = data_get($application, 'environment.project.uuid');
+ $this->environment_uuid = data_get($application, 'environment.uuid');
$this->environment_name = data_get($application, 'environment.name');
$this->fqdn = data_get($application, 'fqdn');
if (str($this->fqdn)->explode(',')->count() > 1) {
$this->fqdn = str($this->fqdn)->explode(',')->first();
}
- $this->deployment_url = base_url()."/project/{$this->project_uuid}/".urlencode($this->environment_name)."/application/{$this->application->uuid}/deployment/{$this->deployment_uuid}";
+ $this->deployment_url = base_url()."/project/{$this->project_uuid}/environments/{$this->environment_uuid}/application/{$this->application->uuid}/deployment/{$this->deployment_uuid}";
}
public function via(object $notifiable): array
diff --git a/app/Notifications/Application/StatusChanged.php b/app/Notifications/Application/StatusChanged.php
index 3b062effb..be18b800b 100644
--- a/app/Notifications/Application/StatusChanged.php
+++ b/app/Notifications/Application/StatusChanged.php
@@ -19,6 +19,8 @@ class StatusChanged extends Notification implements ShouldQueue
public string $project_uuid;
+ public string $environment_uuid;
+
public string $environment_name;
public ?string $resource_url = null;
@@ -30,12 +32,12 @@ class StatusChanged extends Notification implements ShouldQueue
$this->onQueue('high');
$this->resource_name = data_get($resource, 'name');
$this->project_uuid = data_get($resource, 'environment.project.uuid');
- $this->environment_name = data_get($resource, 'environment.name');
+ $this->environment_uuid = data_get($resource, 'environment.uuid');
$this->fqdn = data_get($resource, 'fqdn', null);
if (str($this->fqdn)->explode(',')->count() > 1) {
$this->fqdn = str($this->fqdn)->explode(',')->first();
}
- $this->resource_url = base_url()."/project/{$this->project_uuid}/".urlencode($this->environment_name)."/application/{$this->resource->uuid}";
+ $this->resource_url = base_url()."/project/{$this->project_uuid}/environments/{$this->environment_uuid}/application/{$this->resource->uuid}";
}
public function via(object $notifiable): array
From bde895b6cd76621a648d1939cdbcb52bc35b54e7 Mon Sep 17 00:00:00 2001
From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Date: Fri, 22 Nov 2024 16:08:27 +0100
Subject: [PATCH 14/32] fix scheduled task url
---
app/Livewire/Project/Shared/ScheduledTask/Show.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/Livewire/Project/Shared/ScheduledTask/Show.php b/app/Livewire/Project/Shared/ScheduledTask/Show.php
index 0900a1d70..0764ab3b9 100644
--- a/app/Livewire/Project/Shared/ScheduledTask/Show.php
+++ b/app/Livewire/Project/Shared/ScheduledTask/Show.php
@@ -46,7 +46,7 @@ class Show extends Component
#[Locked]
public string $task_uuid;
- public function mount(string $task_uuid, string $project_uuid, string $environment_name, ?string $application_uuid = null, ?string $service_uuid = null)
+ public function mount(string $task_uuid, string $project_uuid, string $environment_uuid, ?string $application_uuid = null, ?string $service_uuid = null)
{
try {
$this->task_uuid = $task_uuid;
@@ -60,7 +60,7 @@ class Show extends Component
$this->resource = Service::ownedByCurrentTeam()->where('uuid', $service_uuid)->firstOrFail();
}
$this->parameters = [
- 'environment_name' => $environment_name,
+ 'environment_uuid' => $environment_uuid,
'project_uuid' => $project_uuid,
'application_uuid' => $application_uuid,
'service_uuid' => $service_uuid,
From 371b4a3f83ca3e3e077f13a55be099e131343c10 Mon Sep 17 00:00:00 2001
From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Date: Fri, 22 Nov 2024 16:11:53 +0100
Subject: [PATCH 15/32] remove unused var
---
app/Notifications/Application/StatusChanged.php | 2 --
1 file changed, 2 deletions(-)
diff --git a/app/Notifications/Application/StatusChanged.php b/app/Notifications/Application/StatusChanged.php
index be18b800b..4d0b0b3db 100644
--- a/app/Notifications/Application/StatusChanged.php
+++ b/app/Notifications/Application/StatusChanged.php
@@ -21,8 +21,6 @@ class StatusChanged extends Notification implements ShouldQueue
public string $environment_uuid;
- public string $environment_name;
-
public ?string $resource_url = null;
public ?string $fqdn;
From c5f365e38442576d4b5e11bef580fd3362d68cb0 Mon Sep 17 00:00:00 2001
From: Zao Soula
Date: Thu, 12 Dec 2024 19:39:11 +0100
Subject: [PATCH 16/32] feat: add infomaniak oauth
---
app/Providers/EventServiceProvider.php | 2 +
bootstrap/helpers/socialite.php | 1 +
composer.json | 1 +
composer.lock | 53 ++++++++++++++++++++++++-
database/seeders/OauthSettingSeeder.php | 1 +
lang/ar.json | 1 +
lang/cs.json | 1 +
lang/de.json | 1 +
lang/en.json | 1 +
lang/es.json | 3 +-
lang/fa.json | 1 +
lang/fr.json | 1 +
lang/it.json | 1 +
lang/ja.json | 1 +
lang/pt.json | 1 +
lang/ro.json | 1 +
lang/tr.json | 1 +
lang/vi.json | 1 +
lang/zh-cn.json | 1 +
lang/zh-tw.json | 1 +
20 files changed, 73 insertions(+), 2 deletions(-)
diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php
index aa3579f8d..428f78cb5 100644
--- a/app/Providers/EventServiceProvider.php
+++ b/app/Providers/EventServiceProvider.php
@@ -11,6 +11,7 @@ use Illuminate\Foundation\Events\MaintenanceModeEnabled;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use SocialiteProviders\Authentik\AuthentikExtendSocialite;
use SocialiteProviders\Azure\AzureExtendSocialite;
+use SocialiteProviders\Infomaniak\InfomaniakExtendSocialite;
use SocialiteProviders\Manager\SocialiteWasCalled;
class EventServiceProvider extends ServiceProvider
@@ -25,6 +26,7 @@ class EventServiceProvider extends ServiceProvider
SocialiteWasCalled::class => [
AzureExtendSocialite::class.'@handle',
AuthentikExtendSocialite::class.'@handle',
+ InfomaniakExtendSocialite::class.'@handle',
],
ProxyStarted::class => [
ProxyStartedNotification::class,
diff --git a/bootstrap/helpers/socialite.php b/bootstrap/helpers/socialite.php
index 130227e81..09dffb78a 100644
--- a/bootstrap/helpers/socialite.php
+++ b/bootstrap/helpers/socialite.php
@@ -40,6 +40,7 @@ function get_socialite_provider(string $provider)
'github' => \Laravel\Socialite\Two\GithubProvider::class,
'gitlab' => \Laravel\Socialite\Two\GitlabProvider::class,
'google' => \Laravel\Socialite\Two\GoogleProvider::class,
+ 'infomaniak' => \SocialiteProviders\Infomaniak\Provider::class,
];
return Socialite::buildProvider(
diff --git a/composer.json b/composer.json
index b8dc354c3..8e8ad0a4b 100644
--- a/composer.json
+++ b/composer.json
@@ -40,6 +40,7 @@
"resend/resend-laravel": "^0.15.0",
"sentry/sentry-laravel": "^4.6",
"socialiteproviders/authentik": "^5.2",
+ "socialiteproviders/infomaniak": "^4.0",
"socialiteproviders/microsoft-azure": "^5.1",
"spatie/laravel-activitylog": "^4.7.3",
"spatie/laravel-data": "^4.11",
diff --git a/composer.lock b/composer.lock
index 3fbe72afb..50d64cba2 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "871067cb42e6347ca53ff36e81ac5079",
+ "content-hash": "5517a7becb5d31fa2ef3ecfaea06f7a7",
"packages": [
{
"name": "3sidedcube/laravel-redoc",
@@ -7467,6 +7467,57 @@
},
"time": "2023-11-07T22:21:16+00:00"
},
+ {
+ "name": "socialiteproviders/infomaniak",
+ "version": "4.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/SocialiteProviders/Infomaniak.git",
+ "reference": "9796ad686204443bfdf3ff19a6c409e8771667e1"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/SocialiteProviders/Infomaniak/zipball/9796ad686204443bfdf3ff19a6c409e8771667e1",
+ "reference": "9796ad686204443bfdf3ff19a6c409e8771667e1",
+ "shasum": ""
+ },
+ "require": {
+ "ext-json": "*",
+ "php": "^8.0",
+ "socialiteproviders/manager": "^4.4"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "SocialiteProviders\\Infomaniak\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Leopold Jacquot",
+ "email": "leopold.jacquot@infomaniak.com"
+ }
+ ],
+ "description": "Infomaniak OAuth2 Provider for Laravel Socialite",
+ "keywords": [
+ "infomaniak",
+ "laravel",
+ "oauth",
+ "oauth2",
+ "provider",
+ "socialite"
+ ],
+ "support": {
+ "docs": "https://socialiteproviders.com/qq",
+ "issues": "https://github.com/socialiteproviders/providers/issues",
+ "source": "https://github.com/socialiteproviders/providers"
+ },
+ "time": "2024-11-20T05:42:36+00:00"
+ },
{
"name": "socialiteproviders/manager",
"version": "v4.7.0",
diff --git a/database/seeders/OauthSettingSeeder.php b/database/seeders/OauthSettingSeeder.php
index bf902175f..f219aecc0 100644
--- a/database/seeders/OauthSettingSeeder.php
+++ b/database/seeders/OauthSettingSeeder.php
@@ -19,6 +19,7 @@ class OauthSettingSeeder extends Seeder
'gitlab',
'google',
'authentik',
+ 'infomaniak',
]);
$isOauthSeeded = OauthSetting::count() > 0;
diff --git a/lang/ar.json b/lang/ar.json
index 4b9afbe99..b473318d3 100644
--- a/lang/ar.json
+++ b/lang/ar.json
@@ -5,6 +5,7 @@
"auth.login.github": "تسجيل الدخول باستخدام GitHub",
"auth.login.gitlab": "تسجيل الدخول باستخدام Gitlab",
"auth.login.google": "تسجيل الدخول باستخدام Google",
+ "auth.login.infomaniak": "تسجيل الدخول باستخدام Infomaniak",
"auth.already_registered": "هل سبق لك التسجيل؟",
"auth.confirm_password": "تأكيد كلمة المرور",
"auth.forgot_password": "نسيت كلمة المرور",
diff --git a/lang/cs.json b/lang/cs.json
index 48b47b06a..270fd272b 100644
--- a/lang/cs.json
+++ b/lang/cs.json
@@ -5,6 +5,7 @@
"auth.login.github": "Přihlásit se pomocí GitHubu",
"auth.login.gitlab": "Přihlásit se pomocí Gitlabu",
"auth.login.google": "Přihlásit se pomocí Google",
+ "auth.login.infomaniak": "Přihlásit se pomocí Infomaniak",
"auth.already_registered": "Již jste registrováni?",
"auth.confirm_password": "Potvrďte heslo",
"auth.forgot_password": "Zapomněli jste heslo",
diff --git a/lang/de.json b/lang/de.json
index 29fec629f..c5644e3a7 100644
--- a/lang/de.json
+++ b/lang/de.json
@@ -5,6 +5,7 @@
"auth.login.github": "Mit GitHub anmelden",
"auth.login.gitlab": "Mit GitLab anmelden",
"auth.login.google": "Mit Google anmelden",
+ "auth.login.infomaniak": "Mit Infomaniak anmelden",
"auth.already_registered": "Bereits registriert?",
"auth.confirm_password": "Passwort bestätigen",
"auth.forgot_password": "Passwort vergessen",
diff --git a/lang/en.json b/lang/en.json
index 4e0749ece..cdca68601 100644
--- a/lang/en.json
+++ b/lang/en.json
@@ -6,6 +6,7 @@
"auth.login.github": "Login with GitHub",
"auth.login.gitlab": "Login with Gitlab",
"auth.login.google": "Login with Google",
+ "auth.login.infomaniak": "Login with Infomaniak",
"auth.already_registered": "Already registered?",
"auth.confirm_password": "Confirm password",
"auth.forgot_password": "Forgot password",
diff --git a/lang/es.json b/lang/es.json
index 0d8c0c940..aceacd462 100644
--- a/lang/es.json
+++ b/lang/es.json
@@ -5,6 +5,7 @@
"auth.login.github": "Acceder con GitHub",
"auth.login.gitlab": "Acceder con Gitlab",
"auth.login.google": "Acceder con Google",
+ "auth.login.infomaniak": "Acceder con Infomaniak",
"auth.already_registered": "¿Ya estás registrado?",
"auth.confirm_password": "Confirmar contraseña",
"auth.forgot_password": "¿Olvidaste tu contraseña?",
@@ -27,4 +28,4 @@
"input.recovery_code": "Código de recuperación",
"button.save": "Guardar",
"repository.url": "Examples
Para repositorios públicos, usar https://....
Para repositorios privados, usar git@....
https://github.com/coollabsio/coolify-examples main la rama 'main' será seleccionada.
https://github.com/coollabsio/coolify-examples/tree/nodejs-fastify nodejs-fastify la rama 'nodejs-fastify' será seleccionada.
https://gitea.com/sedlav/expressjs.git main la rama 'main' será seleccionada.
https://gitlab.com/andrasbacsai/nodejs-example.git main la rama 'main' será seleccionada."
-}
\ No newline at end of file
+}
diff --git a/lang/fa.json b/lang/fa.json
index d0ecc4a3b..7a714e626 100644
--- a/lang/fa.json
+++ b/lang/fa.json
@@ -5,6 +5,7 @@
"auth.login.github": "ورود با گیت هاب",
"auth.login.gitlab": "ورود با گیت لب",
"auth.login.google": "ورود با گوگل",
+ "auth.login.infomaniak": "ورود با Infomaniak",
"auth.already_registered": "قبلاً ثبت نام کردهاید؟",
"auth.confirm_password": "تایید رمز عبور",
"auth.forgot_password": "فراموشی رمز عبور",
diff --git a/lang/fr.json b/lang/fr.json
index dbd5a1bf7..a94d633d3 100644
--- a/lang/fr.json
+++ b/lang/fr.json
@@ -5,6 +5,7 @@
"auth.login.github": "Connexion avec GitHub",
"auth.login.gitlab": "Connexion avec Gitlab",
"auth.login.google": "Connexion avec Google",
+ "auth.login.infomaniak": "Connexion avec Infomaniak",
"auth.already_registered": "Déjà enregistré ?",
"auth.confirm_password": "Confirmer le mot de passe",
"auth.forgot_password": "Mot de passe oublié",
diff --git a/lang/it.json b/lang/it.json
index 6e4feb9cc..30b9f3902 100644
--- a/lang/it.json
+++ b/lang/it.json
@@ -5,6 +5,7 @@
"auth.login.github": "Accedi con GitHub",
"auth.login.gitlab": "Accedi con Gitlab",
"auth.login.google": "Accedi con Google",
+ "auth.login.infomaniak": "Accedi con Infomaniak",
"auth.already_registered": "Già registrato?",
"auth.confirm_password": "Conferma password",
"auth.forgot_password": "Password dimenticata",
diff --git a/lang/ja.json b/lang/ja.json
index 4652a3b17..4d4589900 100644
--- a/lang/ja.json
+++ b/lang/ja.json
@@ -5,6 +5,7 @@
"auth.login.github": "GitHubでログイン",
"auth.login.gitlab": "Gitlabでログイン",
"auth.login.google": "Googleでログイン",
+ "auth.login.infomaniak": "Infomaniakでログイン",
"auth.already_registered": "すでに登録済みですか?",
"auth.confirm_password": "パスワードを確認",
"auth.forgot_password": "パスワードを忘れた",
diff --git a/lang/pt.json b/lang/pt.json
index b5dd5c434..c5f393e65 100644
--- a/lang/pt.json
+++ b/lang/pt.json
@@ -5,6 +5,7 @@
"auth.login.github": "Entrar com GitHub",
"auth.login.gitlab": "Entrar com Gitlab",
"auth.login.google": "Entrar com Google",
+ "auth.login.infomaniak": "Entrar com Infomaniak",
"auth.already_registered": "Já tem uma conta?",
"auth.confirm_password": "Confirmar senha",
"auth.forgot_password": "Esqueceu a senha?",
diff --git a/lang/ro.json b/lang/ro.json
index db1aa85db..4c7968cfa 100644
--- a/lang/ro.json
+++ b/lang/ro.json
@@ -5,6 +5,7 @@
"auth.login.github": "Autentificare prin GitHub",
"auth.login.gitlab": "Autentificare prin Gitlab",
"auth.login.google": "Autentificare prin Google",
+ "auth.login.infomaniak": "Autentificare prin Infomaniak",
"auth.already_registered": "Sunteți deja înregistrat?",
"auth.confirm_password": "Confirmați parola",
"auth.forgot_password": "Ați uitat parola",
diff --git a/lang/tr.json b/lang/tr.json
index 255b0d15b..3cbcee409 100644
--- a/lang/tr.json
+++ b/lang/tr.json
@@ -5,6 +5,7 @@
"auth.login.github": "GitHub ile Giriş Yap",
"auth.login.gitlab": "GitLab ile Giriş Yap",
"auth.login.google": "Google ile Giriş Yap",
+ "auth.login.infomaniak": "Infomaniak ile Giriş Yap",
"auth.already_registered": "Zaten kayıtlı mısınız?",
"auth.confirm_password": "Şifreyi Onayla",
"auth.forgot_password": "Şifremi Unuttum",
diff --git a/lang/vi.json b/lang/vi.json
index 548dbe8b7..bb43fd34d 100644
--- a/lang/vi.json
+++ b/lang/vi.json
@@ -5,6 +5,7 @@
"auth.login.github": "Đăng Nhập Bằng GitHub",
"auth.login.gitlab": "Đăng Nhập Bằng Gitlab",
"auth.login.google": "Đăng Nhập Bằng Google",
+ "auth.login.infomaniak": "Đăng Nhập Bằng Infomaniak",
"auth.already_registered": "Đã đăng ký?",
"auth.confirm_password": "Nhập lại mật khẩu",
"auth.forgot_password": "Quên mật khẩu",
diff --git a/lang/zh-cn.json b/lang/zh-cn.json
index 70c457fa8..944887a5f 100644
--- a/lang/zh-cn.json
+++ b/lang/zh-cn.json
@@ -5,6 +5,7 @@
"auth.login.github": "使用 GitHub 登录",
"auth.login.gitlab": "使用 Gitlab 登录",
"auth.login.google": "使用 Google 登录",
+ "auth.login.infomaniak": "使用 Infomaniak 登录",
"auth.already_registered": "已经注册?",
"auth.confirm_password": "确认密码",
"auth.forgot_password": "忘记密码",
diff --git a/lang/zh-tw.json b/lang/zh-tw.json
index 63956f7a1..c42ebb33e 100644
--- a/lang/zh-tw.json
+++ b/lang/zh-tw.json
@@ -5,6 +5,7 @@
"auth.login.github": "使用 GitHub 登入",
"auth.login.gitlab": "使用 Gitlab 登入",
"auth.login.google": "使用 Google 登入",
+ "auth.login.infomaniak": "使用 Infomaniak 登入",
"auth.already_registered": "已經註冊?",
"auth.confirm_password": "確認密碼",
"auth.forgot_password": "忘記密碼",
From e76817d40183ac3ff574715cf8ea217a4ce0d98d Mon Sep 17 00:00:00 2001
From: Andras Bacsai
Date: Mon, 16 Dec 2024 14:11:45 +0100
Subject: [PATCH 17/32] improve application view
---
.../Project/Application/Configuration.php | 9 +
.../Shared/EnvironmentVariable/Show.php | 4 -
.../etc/nginx/site-opts.d/http.conf | 4 +-
.../etc/nginx/site-opts.d/http.conf | 4 +-
.../application/configuration.blade.php | 186 ++++++++----------
routes/web.php | 17 ++
6 files changed, 110 insertions(+), 114 deletions(-)
diff --git a/app/Livewire/Project/Application/Configuration.php b/app/Livewire/Project/Application/Configuration.php
index 5261a0800..bf2811075 100644
--- a/app/Livewire/Project/Application/Configuration.php
+++ b/app/Livewire/Project/Application/Configuration.php
@@ -8,14 +8,21 @@ use Livewire\Component;
class Configuration extends Component
{
+ public $currentRoute;
+
public Application $application;
+ public $project;
+
+ public $environment;
+
public $servers;
protected $listeners = ['buildPackUpdated' => '$refresh'];
public function mount()
{
+ $this->currentRoute = request()->route()->getName();
$project = currentTeam()
->projects()
->select('id', 'uuid', 'team_id')
@@ -30,6 +37,8 @@ class Configuration extends Component
->where('uuid', request()->route('application_uuid'))
->firstOrFail();
+ $this->project = $project;
+ $this->environment = $environment;
$this->application = $application;
if ($application->destination && $application->destination->server) {
$mainServer = $application->destination->server;
diff --git a/app/Livewire/Project/Shared/EnvironmentVariable/Show.php b/app/Livewire/Project/Shared/EnvironmentVariable/Show.php
index 6294d97c6..2bccde0e9 100644
--- a/app/Livewire/Project/Shared/EnvironmentVariable/Show.php
+++ b/app/Livewire/Project/Shared/EnvironmentVariable/Show.php
@@ -5,7 +5,6 @@ namespace App\Livewire\Project\Shared\EnvironmentVariable;
use App\Models\EnvironmentVariable as ModelsEnvironmentVariable;
use App\Models\SharedEnvironmentVariable;
use Livewire\Component;
-use Visus\Cuid2\Cuid2;
class Show extends Component
{
@@ -13,8 +12,6 @@ class Show extends Component
public ModelsEnvironmentVariable|SharedEnvironmentVariable $env;
- public ?string $modalId = null;
-
public bool $isDisabled = false;
public bool $isLocked = false;
@@ -61,7 +58,6 @@ class Show extends Component
if ($this->env->getMorphClass() === \App\Models\SharedEnvironmentVariable::class) {
$this->isSharedVariable = true;
}
- $this->modalId = new Cuid2;
$this->parameters = get_route_parameters();
$this->checkEnvs();
}
diff --git a/docker/development/etc/nginx/site-opts.d/http.conf b/docker/development/etc/nginx/site-opts.d/http.conf
index 41735cf06..9f7e49ee2 100644
--- a/docker/development/etc/nginx/site-opts.d/http.conf
+++ b/docker/development/etc/nginx/site-opts.d/http.conf
@@ -39,7 +39,7 @@ location ~ \.php$ {
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
- fastcgi_buffers 8 8k;
- fastcgi_buffer_size 8k;
+ fastcgi_buffers 16 16k;
+ fastcgi_buffer_size 32k;
fastcgi_read_timeout 99;
}
diff --git a/docker/production/etc/nginx/site-opts.d/http.conf b/docker/production/etc/nginx/site-opts.d/http.conf
index 41735cf06..9f7e49ee2 100644
--- a/docker/production/etc/nginx/site-opts.d/http.conf
+++ b/docker/production/etc/nginx/site-opts.d/http.conf
@@ -39,7 +39,7 @@ location ~ \.php$ {
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
- fastcgi_buffers 8 8k;
- fastcgi_buffer_size 8k;
+ fastcgi_buffers 16 16k;
+ fastcgi_buffer_size 32k;
fastcgi_read_timeout 99;
}
diff --git a/resources/views/livewire/project/application/configuration.blade.php b/resources/views/livewire/project/application/configuration.blade.php
index b5ba6c822..fc2b8c7c0 100644
--- a/resources/views/livewire/project/application/configuration.blade.php
+++ b/resources/views/livewire/project/application/configuration.blade.php
@@ -5,34 +5,36 @@
Configuration
-
+
+
-
+
+
@if ($application->destination->server->isSwarm())
-
@endif
-
- @if ($application->build_pack !== 'static')
-
- @endif
- @if ($application->build_pack !== 'static')
-
- @endif
+
+
@if ($application->git_based())
-
+
@endif
-
-
+
+
+
+
+
+
-
- @if ($application->git_based())
-
- @endif
- @if ($application->build_pack !== 'static' && $application->build_pack !== 'dockercompose')
-
- @endif
-
- @if ($application->build_pack !== 'dockercompose')
-
- @endif
-
-
-
-
+
+
+
+
-
+ @if (request()->route()->getName() === 'project.application.configuration')
-
-
+ @elseif (request()->route()->getName() === 'project.application.swarm' && $application->destination->server->isSwarm())
-
-
+ @elseif (request()->route()->getName() === 'project.application.advanced')
-
-
+ @elseif (request()->route()->getName() === 'project.application.environment-variables')
-
- @if ($application->git_based())
-
-
-
- @endif
-
+ @elseif (request()->route()->getName() === 'project.application.persistent-storage')
+
+ @elseif (request()->route()->getName() === 'project.application.source' && $application->git_based())
+
+ @elseif (request()->route()->getName() === 'project.application.servers')
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ @elseif (request()->route()->getName() === 'project.application.scheduled-tasks.show')
-
-
+ @elseif (request()->route()->getName() === 'project.application.webhooks')
+
+ @elseif (request()->route()->getName() === 'project.application.preview-deployments')
+
+ @elseif (request()->route()->getName() === 'project.application.healthcheck')
+
+ @elseif (request()->route()->getName() === 'project.application.rollback')
+
+ @elseif (request()->route()->getName() === 'project.application.resource-limits')
+
+ @elseif (request()->route()->getName() === 'project.application.resource-operations')
-
-
+ @elseif (request()->route()->getName() === 'project.application.metrics')
-
-
-
-
-
+ @elseif (request()->route()->getName() === 'project.application.tags')
+
+ @elseif (request()->route()->getName() === 'project.application.danger')
-
+ @endif
diff --git a/routes/web.php b/routes/web.php
index 3d12b9b46..18adc0467 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -183,6 +183,23 @@ Route::middleware(['auth', 'verified'])->group(function () {
});
Route::prefix('project/{project_uuid}/{environment_name}/application/{application_uuid}')->group(function () {
Route::get('/', ApplicationConfiguration::class)->name('project.application.configuration');
+ Route::get('/swarm', ApplicationConfiguration::class)->name('project.application.swarm');
+ Route::get('/advanced', ApplicationConfiguration::class)->name('project.application.advanced');
+ Route::get('/environment-variables', ApplicationConfiguration::class)->name('project.application.environment-variables');
+ Route::get('/persistent-storage', ApplicationConfiguration::class)->name('project.application.persistent-storage');
+ Route::get('/source', ApplicationConfiguration::class)->name('project.application.source');
+ Route::get('/servers', ApplicationConfiguration::class)->name('project.application.servers');
+ Route::get('/scheduled-tasks', ApplicationConfiguration::class)->name('project.application.scheduled-tasks.show');
+ Route::get('/webhooks', ApplicationConfiguration::class)->name('project.application.webhooks');
+ Route::get('/preview-deployments', ApplicationConfiguration::class)->name('project.application.preview-deployments');
+ Route::get('/healthcheck', ApplicationConfiguration::class)->name('project.application.healthcheck');
+ Route::get('/rollback', ApplicationConfiguration::class)->name('project.application.rollback');
+ Route::get('/resource-limits', ApplicationConfiguration::class)->name('project.application.resource-limits');
+ Route::get('/resource-operations', ApplicationConfiguration::class)->name('project.application.resource-operations');
+ Route::get('/metrics', ApplicationConfiguration::class)->name('project.application.metrics');
+ Route::get('/tags', ApplicationConfiguration::class)->name('project.application.tags');
+ Route::get('/danger', ApplicationConfiguration::class)->name('project.application.danger');
+
Route::get('/deployment', DeploymentIndex::class)->name('project.application.deployment.index');
Route::get('/deployment/{deployment_uuid}', DeploymentShow::class)->name('project.application.deployment.show');
Route::get('/logs', Logs::class)->name('project.application.logs');
From b0a57817283a9043045219044b3f3ffa41331029 Mon Sep 17 00:00:00 2001
From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Date: Mon, 16 Dec 2024 18:28:18 +0100
Subject: [PATCH 18/32] Update service-templates.json
---
templates/service-templates.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/templates/service-templates.json b/templates/service-templates.json
index 9f1f6a7cc..6e44c44d7 100644
--- a/templates/service-templates.json
+++ b/templates/service-templates.json
@@ -977,7 +977,7 @@
"getoutline": {
"documentation": "https://docs.getoutline.com/s/hosting/doc/hosting-outline-nipGaCRBDu?utm_source=coolify.io",
"slogan": "Your team\u2019s knowledge base",
- "compose": "c2VydmljZXM6CiAgb3V0bGluZToKICAgIGltYWdlOiAnZG9ja2VyLmdldG91dGxpbmUuY29tL291dGxpbmV3aWtpL291dGxpbmU6bGF0ZXN0JwogICAgdm9sdW1lczoKICAgICAgLSAnc3RvcmFnZS1kYXRhOi92YXIvbGliL291dGxpbmUvZGF0YScKICAgIGRlcGVuZHNfb246CiAgICAgIHBvc3RncmVzOgogICAgICAgIGNvbmRpdGlvbjogc2VydmljZV9oZWFsdGh5CiAgICAgIHJlZGlzOgogICAgICAgIGNvbmRpdGlvbjogc2VydmljZV9oZWFsdGh5CiAgICBlbnZpcm9ubWVudDoKICAgICAgLSBTRVJWSUNFX0ZRRE5fT1VUTElORV8zMDAwCiAgICAgIC0gTk9ERV9FTlY9cHJvZHVjdGlvbgogICAgICAtICdTRUNSRVRfS0VZPSR7U0VSVklDRV9CQVNFNjRfT1VUTElORX0nCiAgICAgIC0gJ1VUSUxTX1NFQ1JFVD0ke1NFUlZJQ0VfUEFTU1dPUkRfNjRfT1VUTElORX0nCiAgICAgIC0gJ0RBVEFCQVNFX1VSTD1wb3N0Z3JlczovLyR7U0VSVklDRV9VU0VSX1BPU1RHUkVTfToke1NFUlZJQ0VfUEFTU1dPUkRfNjRfUE9TVEdSRVN9QHBvc3RncmVzOjU0MzIvJHtQT1NUR1JFU19EQVRBQkFTRTotb3V0bGluZX0nCiAgICAgIC0gJ1JFRElTX1VSTD1yZWRpczovLzoke1NFUlZJQ0VfUEFTU1dPUkRfNjRfUkVESVN9QHJlZGlzOjYzNzknCiAgICAgIC0gJ1VSTD0ke1NFUlZJQ0VfRlFETl9PVVRMSU5FXzMwMDB9JwogICAgICAtICdQT1JUPSR7T1VUTElORV9QT1JUOi0zMDAwfScKICAgICAgLSAnRklMRV9TVE9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VEdSRVNfREFUQUJBU0U6LW91dGxpbmV9JwogICAgICBpbnRlcnZhbDogMzBzCiAgICAgIHRpbWVvdXQ6IDIwcwogICAgICByZXRyaWVzOiAzCg==",
"tags": [
"knowledge base",
"documentation"
From 7edd2285b516d89ef4d945d570b752a827eb87df Mon Sep 17 00:00:00 2001
From: Andras Bacsai
Date: Tue, 17 Dec 2024 09:57:31 +0100
Subject: [PATCH 19/32] Refactor PostgreSQL selection UI in project creation
form for improved layout and documentation links
---
.../livewire/project/new/select.blade.php | 121 +++++++++---------
1 file changed, 59 insertions(+), 62 deletions(-)
diff --git a/resources/views/livewire/project/new/select.blade.php b/resources/views/livewire/project/new/select.blade.php
index 54a2e953e..e6067817d 100644
--- a/resources/views/livewire/project/new/select.blade.php
+++ b/resources/views/livewire/project/new/select.blade.php
@@ -273,77 +273,74 @@
Select a Postgresql type
If you need extra extensions, you can select Supabase PostgreSQL (or others), otherwise select PostgreSQL
16 (default).
-
-
-
-
-
PostgreSQL 16 (default)
-
- PostgreSQL is a powerful, open-source object-relational database system (no extensions).
-
+
+
+
+
PostgreSQL 16 (default)
+
+ PostgreSQL is a powerful, open-source object-relational database system (no extensions).
-
+
+
-
+
+
+
Supabase PostgreSQL (with extensions)
+
+ Supabase is a modern, open-source alternative to PostgreSQL with lots of extensions.
-
-
-
Supabase PostgreSQL (with extensions)
-
- Supabase is a modern, open-source alternative to PostgreSQL with lots of extensions.
-
-
-
-
+
+
+
PostGIS
+
+ PostGIS is a PostgreSQL extension for geographic objects.
-
-
-
PostGIS
-
- PostGIS is a PostgreSQL extension for geographic objects.
-
-
-
-
+
+
+
PGVector (16)
+
+ PGVector is a PostgreSQL extension for vector data types.
-
-
-
PGVector (16)
-
- PGVector is a PostgreSQL extension for vector data types.
-
-
-
+
-
+
From 2a9d4992513d80b67fce23f819c12cea7796a9e7 Mon Sep 17 00:00:00 2001
From: Andras Bacsai
Date: Tue, 17 Dec 2024 10:38:32 +0100
Subject: [PATCH 20/32] feat: migrate env variables to polymorphic relationship
fix: proxy status query ui
---
.../Api/ApplicationsController.php | 36 +++-
.../Controllers/Api/ServicesController.php | 19 +-
.../Project/Application/DeploymentNavbar.php | 2 +-
app/Livewire/Project/CloneMe.php | 15 +-
app/Livewire/Project/New/DockerCompose.php | 3 +-
app/Livewire/Project/Resource/Create.php | 3 +-
.../Shared/EnvironmentVariable/All.php | 67 ++-----
.../Shared/EnvironmentVariable/Show.php | 102 +++++++----
.../Project/Shared/ResourceOperations.php | 3 +-
app/Models/Application.php | 52 ++++--
app/Models/EnvironmentVariable.php | 73 ++++----
app/Models/Service.php | 14 +-
app/Models/StandaloneClickhouse.php | 10 +-
app/Models/StandaloneDragonfly.php | 16 +-
app/Models/StandaloneKeydb.php | 16 +-
app/Models/StandaloneMariadb.php | 10 +-
app/Models/StandaloneMongodb.php | 16 +-
app/Models/StandaloneMysql.php | 16 +-
app/Models/StandalonePostgresql.php | 16 +-
app/Models/StandaloneRedis.php | 16 +-
app/View/Components/Forms/Button.php | 3 +-
bootstrap/helpers/services.php | 51 ++++--
bootstrap/helpers/shared.php | 85 +++++----
...columns_to_environment_variables_table.php | 165 ++++++++++++++++++
.../views/components/forms/button.blade.php | 14 +-
resources/views/components/loading.blade.php | 4 +-
.../views/components/server/navbar.blade.php | 1 +
.../views/components/status/running.blade.php | 54 +++---
.../project/database/heading.blade.php | 2 +-
.../shared/environment-variable/all.blade.php | 6 +-
.../environment-variable/show.blade.php | 61 +++----
.../livewire/server/proxy/deploy.blade.php | 35 ++--
.../livewire/server/proxy/status.blade.php | 13 +-
33 files changed, 625 insertions(+), 374 deletions(-)
create mode 100644 database/migrations/2024_12_16_134437_add_resourceable_columns_to_environment_variables_table.php
diff --git a/app/Http/Controllers/Api/ApplicationsController.php b/app/Http/Controllers/Api/ApplicationsController.php
index f02c4255d..6e7370bb3 100644
--- a/app/Http/Controllers/Api/ApplicationsController.php
+++ b/app/Http/Controllers/Api/ApplicationsController.php
@@ -27,6 +27,9 @@ class ApplicationsController extends Controller
{
$application->makeHidden([
'id',
+ 'resourceable',
+ 'resourceable_id',
+ 'resourceable_type',
]);
if (request()->attributes->get('can_read_sensitive', false) === false) {
$application->makeHidden([
@@ -1893,8 +1896,9 @@ class ApplicationsController extends Controller
$is_preview = $request->is_preview ?? false;
$is_build_time = $request->is_build_time ?? false;
$is_literal = $request->is_literal ?? false;
+ $key = str($request->key)->trim()->replace(' ', '_')->value;
if ($is_preview) {
- $env = $application->environment_variables_preview->where('key', $request->key)->first();
+ $env = $application->environment_variables_preview->where('key', $key)->first();
if ($env) {
$env->value = $request->value;
if ($env->is_build_time != $is_build_time) {
@@ -1921,7 +1925,7 @@ class ApplicationsController extends Controller
], 404);
}
} else {
- $env = $application->environment_variables->where('key', $request->key)->first();
+ $env = $application->environment_variables->where('key', $key)->first();
if ($env) {
$env->value = $request->value;
if ($env->is_build_time != $is_build_time) {
@@ -2064,6 +2068,7 @@ class ApplicationsController extends Controller
$bulk_data = collect($bulk_data)->map(function ($item) {
return collect($item)->only(['key', 'value', 'is_preview', 'is_build_time', 'is_literal']);
});
+ $returnedEnvs = collect();
foreach ($bulk_data as $item) {
$validator = customApiValidator($item, [
'key' => 'string|required',
@@ -2085,8 +2090,9 @@ class ApplicationsController extends Controller
$is_literal = $item->get('is_literal') ?? false;
$is_multi_line = $item->get('is_multiline') ?? false;
$is_shown_once = $item->get('is_shown_once') ?? false;
+ $key = str($item->get('key'))->trim()->replace(' ', '_')->value;
if ($is_preview) {
- $env = $application->environment_variables_preview->where('key', $item->get('key'))->first();
+ $env = $application->environment_variables_preview->where('key', $key)->first();
if ($env) {
$env->value = $item->get('value');
if ($env->is_build_time != $is_build_time) {
@@ -2111,10 +2117,12 @@ class ApplicationsController extends Controller
'is_literal' => $is_literal,
'is_multiline' => $is_multi_line,
'is_shown_once' => $is_shown_once,
+ 'resourceable_type' => get_class($application),
+ 'resourceable_id' => $application->id,
]);
}
} else {
- $env = $application->environment_variables->where('key', $item->get('key'))->first();
+ $env = $application->environment_variables->where('key', $key)->first();
if ($env) {
$env->value = $item->get('value');
if ($env->is_build_time != $is_build_time) {
@@ -2139,12 +2147,15 @@ class ApplicationsController extends Controller
'is_literal' => $is_literal,
'is_multiline' => $is_multi_line,
'is_shown_once' => $is_shown_once,
+ 'resourceable_type' => get_class($application),
+ 'resourceable_id' => $application->id,
]);
}
}
+ $returnedEnvs->push($this->removeSensitiveData($env));
}
- return response()->json($this->removeSensitiveData($env))->setStatusCode(201);
+ return response()->json($returnedEnvs)->setStatusCode(201);
}
#[OA\Post(
@@ -2257,8 +2268,10 @@ class ApplicationsController extends Controller
], 422);
}
$is_preview = $request->is_preview ?? false;
+ $key = str($request->key)->trim()->replace(' ', '_')->value;
+
if ($is_preview) {
- $env = $application->environment_variables_preview->where('key', $request->key)->first();
+ $env = $application->environment_variables_preview->where('key', $key)->first();
if ($env) {
return response()->json([
'message' => 'Environment variable already exists. Use PATCH request to update it.',
@@ -2272,6 +2285,8 @@ class ApplicationsController extends Controller
'is_literal' => $request->is_literal ?? false,
'is_multiline' => $request->is_multiline ?? false,
'is_shown_once' => $request->is_shown_once ?? false,
+ 'resourceable_type' => get_class($application),
+ 'resourceable_id' => $application->id,
]);
return response()->json([
@@ -2279,7 +2294,7 @@ class ApplicationsController extends Controller
])->setStatusCode(201);
}
} else {
- $env = $application->environment_variables->where('key', $request->key)->first();
+ $env = $application->environment_variables->where('key', $key)->first();
if ($env) {
return response()->json([
'message' => 'Environment variable already exists. Use PATCH request to update it.',
@@ -2293,6 +2308,8 @@ class ApplicationsController extends Controller
'is_literal' => $request->is_literal ?? false,
'is_multiline' => $request->is_multiline ?? false,
'is_shown_once' => $request->is_shown_once ?? false,
+ 'resourceable_type' => get_class($application),
+ 'resourceable_id' => $application->id,
]);
return response()->json([
@@ -2380,7 +2397,10 @@ class ApplicationsController extends Controller
'message' => 'Application not found.',
], 404);
}
- $found_env = EnvironmentVariable::where('uuid', $request->env_uuid)->where('application_id', $application->id)->first();
+ $found_env = EnvironmentVariable::where('uuid', $request->env_uuid)
+ ->where('resourceable_type', Application::class)
+ ->where('resourceable_id', $application->id)
+ ->first();
if (! $found_env) {
return response()->json([
'message' => 'Environment variable not found.',
diff --git a/app/Http/Controllers/Api/ServicesController.php b/app/Http/Controllers/Api/ServicesController.php
index bcaba7107..f5ecdcf28 100644
--- a/app/Http/Controllers/Api/ServicesController.php
+++ b/app/Http/Controllers/Api/ServicesController.php
@@ -20,6 +20,9 @@ class ServicesController extends Controller
{
$service->makeHidden([
'id',
+ 'resourceable',
+ 'resourceable_id',
+ 'resourceable_type',
]);
if (request()->attributes->get('can_read_sensitive', false) === false) {
$service->makeHidden([
@@ -333,7 +336,8 @@ class ServicesController extends Controller
EnvironmentVariable::create([
'key' => $key,
'value' => $generatedValue,
- 'service_id' => $service->id,
+ 'resourceable_id' => $service->id,
+ 'resourceable_type' => $service->getMorphClass(),
'is_build_time' => false,
'is_preview' => false,
]);
@@ -673,7 +677,8 @@ class ServicesController extends Controller
], 422);
}
- $env = $service->environment_variables()->where('key', $request->key)->first();
+ $key = str($request->key)->trim()->replace(' ', '_')->value;
+ $env = $service->environment_variables()->where('key', $key)->first();
if (! $env) {
return response()->json(['message' => 'Environment variable not found.'], 404);
}
@@ -799,9 +804,9 @@ class ServicesController extends Controller
'errors' => $validator->errors(),
], 422);
}
-
+ $key = str($item['key'])->trim()->replace(' ', '_')->value;
$env = $service->environment_variables()->updateOrCreate(
- ['key' => $item['key']],
+ ['key' => $key],
$item
);
@@ -909,7 +914,8 @@ class ServicesController extends Controller
], 422);
}
- $existingEnv = $service->environment_variables()->where('key', $request->key)->first();
+ $key = str($request->key)->trim()->replace(' ', '_')->value;
+ $existingEnv = $service->environment_variables()->where('key', $key)->first();
if ($existingEnv) {
return response()->json([
'message' => 'Environment variable already exists. Use PATCH request to update it.',
@@ -995,7 +1001,8 @@ class ServicesController extends Controller
}
$env = EnvironmentVariable::where('uuid', $request->env_uuid)
- ->where('service_id', $service->id)
+ ->where('resourceable_type', Service::class)
+ ->where('resourceable_id', $service->id)
->first();
if (! $env) {
diff --git a/app/Livewire/Project/Application/DeploymentNavbar.php b/app/Livewire/Project/Application/DeploymentNavbar.php
index 6a6fa2482..87b40d4dc 100644
--- a/app/Livewire/Project/Application/DeploymentNavbar.php
+++ b/app/Livewire/Project/Application/DeploymentNavbar.php
@@ -23,7 +23,7 @@ class DeploymentNavbar extends Component
public function mount()
{
- $this->application = Application::find($this->application_deployment_queue->application_id);
+ $this->application = Application::ownedByCurrentTeam()->find($this->application_deployment_queue->application_id);
$this->server = $this->application->destination->server;
$this->is_debug_enabled = $this->application->settings->is_debug_enabled;
}
diff --git a/app/Livewire/Project/CloneMe.php b/app/Livewire/Project/CloneMe.php
index 4d2bc6589..a8e3e6cab 100644
--- a/app/Livewire/Project/CloneMe.php
+++ b/app/Livewire/Project/CloneMe.php
@@ -119,7 +119,7 @@ class CloneMe extends Component
$environmentVaribles = $application->environment_variables()->get();
foreach ($environmentVaribles as $environmentVarible) {
$newEnvironmentVariable = $environmentVarible->replicate()->fill([
- 'application_id' => $newApplication->id,
+ 'resourceable_id' => $newApplication->id,
]);
$newEnvironmentVariable->save();
}
@@ -145,17 +145,8 @@ class CloneMe extends Component
$environmentVaribles = $database->environment_variables()->get();
foreach ($environmentVaribles as $environmentVarible) {
$payload = [];
- if ($database->type() === 'standalone-postgresql') {
- $payload['standalone_postgresql_id'] = $newDatabase->id;
- } elseif ($database->type() === 'standalone-redis') {
- $payload['standalone_redis_id'] = $newDatabase->id;
- } elseif ($database->type() === 'standalone-mongodb') {
- $payload['standalone_mongodb_id'] = $newDatabase->id;
- } elseif ($database->type() === 'standalone-mysql') {
- $payload['standalone_mysql_id'] = $newDatabase->id;
- } elseif ($database->type() === 'standalone-mariadb') {
- $payload['standalone_mariadb_id'] = $newDatabase->id;
- }
+ $payload['resourceable_id'] = $newDatabase->id;
+ $payload['resourceable_type'] = $newDatabase->getMorphClass();
$newEnvironmentVariable = $environmentVarible->replicate()->fill($payload);
$newEnvironmentVariable->save();
}
diff --git a/app/Livewire/Project/New/DockerCompose.php b/app/Livewire/Project/New/DockerCompose.php
index 199a20cf6..e6667e6f3 100644
--- a/app/Livewire/Project/New/DockerCompose.php
+++ b/app/Livewire/Project/New/DockerCompose.php
@@ -87,7 +87,8 @@ class DockerCompose extends Component
'value' => $variable,
'is_build_time' => false,
'is_preview' => false,
- 'service_id' => $service->id,
+ 'resourceable_id' => $service->id,
+ 'resourceable_type' => $service->getMorphClass(),
]);
}
$service->name = "service-$service->uuid";
diff --git a/app/Livewire/Project/Resource/Create.php b/app/Livewire/Project/Resource/Create.php
index 9266a57fc..4fbda2211 100644
--- a/app/Livewire/Project/Resource/Create.php
+++ b/app/Livewire/Project/Resource/Create.php
@@ -95,7 +95,8 @@ class Create extends Component
EnvironmentVariable::create([
'key' => $key,
'value' => $value,
- 'service_id' => $service->id,
+ 'resourceable_id' => $service->id,
+ 'resourceable_type' => $service->getMorphClass(),
'is_build_time' => false,
'is_preview' => false,
]);
diff --git a/app/Livewire/Project/Shared/EnvironmentVariable/All.php b/app/Livewire/Project/Shared/EnvironmentVariable/All.php
index 787d33a69..80156bf65 100644
--- a/app/Livewire/Project/Shared/EnvironmentVariable/All.php
+++ b/app/Livewire/Project/Shared/EnvironmentVariable/All.php
@@ -4,7 +4,6 @@ namespace App\Livewire\Project\Shared\EnvironmentVariable;
use App\Models\EnvironmentVariable;
use Livewire\Component;
-use Visus\Cuid2\Cuid2;
class All extends Component
{
@@ -14,38 +13,35 @@ class All extends Component
public bool $showPreview = false;
- public ?string $modalId = null;
-
public ?string $variables = null;
public ?string $variablesPreview = null;
public string $view = 'normal';
+ public bool $is_env_sorting_enabled = false;
+
protected $listeners = [
'saveKey' => 'submit',
'refreshEnvs',
'environmentVariableDeleted' => 'refreshEnvs',
];
- protected $rules = [
- 'resource.settings.is_env_sorting_enabled' => 'required|boolean',
- ];
-
public function mount()
{
+ $this->is_env_sorting_enabled = data_get($this->resource, 'settings.is_env_sorting_enabled', false);
$this->resourceClass = get_class($this->resource);
$resourceWithPreviews = [\App\Models\Application::class];
- $simpleDockerfile = ! is_null(data_get($this->resource, 'dockerfile'));
+ $simpleDockerfile = filled(data_get($this->resource, 'dockerfile'));
if (str($this->resourceClass)->contains($resourceWithPreviews) && ! $simpleDockerfile) {
$this->showPreview = true;
}
- $this->modalId = new Cuid2;
$this->sortEnvironmentVariables();
}
public function instantSave()
{
+ $this->resource->settings->is_env_sorting_enabled = $this->is_env_sorting_enabled;
$this->resource->settings->save();
$this->sortEnvironmentVariables();
$this->dispatch('success', 'Environment variable settings updated.');
@@ -53,7 +49,7 @@ class All extends Component
public function sortEnvironmentVariables()
{
- if (! data_get($this->resource, 'settings.is_env_sorting_enabled')) {
+ if ($this->is_env_sorting_enabled === false) {
if ($this->resource->environment_variables) {
$this->resource->environment_variables = $this->resource->environment_variables->sortBy('order')->values();
}
@@ -178,35 +174,12 @@ class All extends Component
$environment->is_multiline = $data['is_multiline'] ?? false;
$environment->is_literal = $data['is_literal'] ?? false;
$environment->is_preview = $data['is_preview'] ?? false;
-
- $resourceType = $this->resource->type();
- $resourceIdField = $this->getResourceIdField($resourceType);
-
- if ($resourceIdField) {
- $environment->$resourceIdField = $this->resource->id;
- }
+ $environment->resourceable_id = $this->resource->id;
+ $environment->resourceable_type = $this->resource->getMorphClass();
return $environment;
}
- private function getResourceIdField($resourceType)
- {
- $resourceTypes = [
- 'application' => 'application_id',
- 'standalone-postgresql' => 'standalone_postgresql_id',
- 'standalone-redis' => 'standalone_redis_id',
- 'standalone-mongodb' => 'standalone_mongodb_id',
- 'standalone-mysql' => 'standalone_mysql_id',
- 'standalone-mariadb' => 'standalone_mariadb_id',
- 'standalone-keydb' => 'standalone_keydb_id',
- 'standalone-dragonfly' => 'standalone_dragonfly_id',
- 'standalone-clickhouse' => 'standalone_clickhouse_id',
- 'service' => 'service_id',
- ];
-
- return $resourceTypes[$resourceType] ?? null;
- }
-
private function deleteRemovedVariables($isPreview, $variables)
{
$method = $isPreview ? 'environment_variables_preview' : 'environment_variables';
@@ -231,34 +204,14 @@ class All extends Component
$environment->is_build_time = false;
$environment->is_multiline = false;
$environment->is_preview = $isPreview;
+ $environment->resourceable_id = $this->resource->id;
+ $environment->resourceable_type = $this->resource->getMorphClass();
- $this->setEnvironmentResourceId($environment);
$environment->save();
}
}
}
- private function setEnvironmentResourceId($environment)
- {
- $resourceTypes = [
- 'application' => 'application_id',
- 'standalone-postgresql' => 'standalone_postgresql_id',
- 'standalone-redis' => 'standalone_redis_id',
- 'standalone-mongodb' => 'standalone_mongodb_id',
- 'standalone-mysql' => 'standalone_mysql_id',
- 'standalone-mariadb' => 'standalone_mariadb_id',
- 'standalone-keydb' => 'standalone_keydb_id',
- 'standalone-dragonfly' => 'standalone_dragonfly_id',
- 'standalone-clickhouse' => 'standalone_clickhouse_id',
- 'service' => 'service_id',
- ];
-
- $resourceType = $this->resource->type();
- if (isset($resourceTypes[$resourceType])) {
- $environment->{$resourceTypes[$resourceType]} = $this->resource->id;
- }
- }
-
public function refreshEnvs()
{
$this->resource->refresh();
diff --git a/app/Livewire/Project/Shared/EnvironmentVariable/Show.php b/app/Livewire/Project/Shared/EnvironmentVariable/Show.php
index 2bccde0e9..4b66bfdcb 100644
--- a/app/Livewire/Project/Shared/EnvironmentVariable/Show.php
+++ b/app/Livewire/Project/Shared/EnvironmentVariable/Show.php
@@ -20,6 +20,26 @@ class Show extends Component
public string $type;
+ public string $key;
+
+ public ?string $value = null;
+
+ public ?string $real_value = null;
+
+ public bool $is_shared = false;
+
+ public bool $is_build_time = false;
+
+ public bool $is_multiline = false;
+
+ public bool $is_literal = false;
+
+ public bool $is_shown_once = false;
+
+ public bool $is_required = false;
+
+ public bool $is_really_required = false;
+
protected $listeners = [
'refreshEnvs' => 'refresh',
'refresh',
@@ -27,39 +47,59 @@ class Show extends Component
];
protected $rules = [
- 'env.key' => 'required|string',
- 'env.value' => 'nullable',
- 'env.is_build_time' => 'required|boolean',
- 'env.is_multiline' => 'required|boolean',
- 'env.is_literal' => 'required|boolean',
- 'env.is_shown_once' => 'required|boolean',
- 'env.real_value' => 'nullable',
- 'env.is_required' => 'required|boolean',
+ 'key' => 'required|string',
+ 'value' => 'nullable',
+ 'is_build_time' => 'required|boolean',
+ 'is_multiline' => 'required|boolean',
+ 'is_literal' => 'required|boolean',
+ 'is_shown_once' => 'required|boolean',
+ 'real_value' => 'nullable',
+ 'is_required' => 'required|boolean',
];
- protected $validationAttributes = [
- 'env.key' => 'Key',
- 'env.value' => 'Value',
- 'env.is_build_time' => 'Build Time',
- 'env.is_multiline' => 'Multiline',
- 'env.is_literal' => 'Literal',
- 'env.is_shown_once' => 'Shown Once',
- 'env.is_required' => 'Required',
- ];
-
- public function refresh()
- {
- $this->env->refresh();
- $this->checkEnvs();
- }
-
public function mount()
{
+ $this->syncData();
if ($this->env->getMorphClass() === \App\Models\SharedEnvironmentVariable::class) {
$this->isSharedVariable = true;
}
$this->parameters = get_route_parameters();
$this->checkEnvs();
+
+ }
+
+ public function refresh()
+ {
+ $this->syncData();
+ $this->checkEnvs();
+ }
+
+ public function syncData(bool $toModel = false)
+ {
+ if ($toModel) {
+ $this->validate();
+ $this->env->key = $this->key;
+ $this->env->value = $this->value;
+ $this->env->is_build_time = $this->is_build_time;
+ $this->env->is_multiline = $this->is_multiline;
+ $this->env->is_literal = $this->is_literal;
+ $this->env->is_shown_once = $this->is_shown_once;
+ $this->env->is_required = $this->is_required;
+ $this->env->is_shared = $this->is_shared;
+ $this->env->save();
+ } else {
+
+ $this->key = $this->env->key;
+ $this->value = $this->env->value;
+ $this->is_build_time = $this->env->is_build_time ?? false;
+ $this->is_multiline = $this->env->is_multiline;
+ $this->is_literal = $this->env->is_literal;
+ $this->is_shown_once = $this->env->is_shown_once;
+ $this->is_required = $this->env->is_required ?? false;
+ $this->is_really_required = $this->env->is_really_required ?? false;
+ $this->is_shared = $this->env->is_shared ?? false;
+ $this->real_value = $this->env->real_value;
+ }
}
public function checkEnvs()
@@ -103,17 +143,17 @@ class Show extends Component
try {
if ($this->isSharedVariable) {
$this->validate([
- 'env.key' => 'required|string',
- 'env.value' => 'nullable',
- 'env.is_shown_once' => 'required|boolean',
+ 'key' => 'required|string',
+ 'value' => 'nullable',
+ 'is_shown_once' => 'required|boolean',
]);
} else {
$this->validate();
}
- if (! $this->isSharedVariable && $this->env->is_required && str($this->env->real_value)->isEmpty()) {
+ if (! $this->isSharedVariable && $this->is_required && str($this->value)->isEmpty()) {
$oldValue = $this->env->getOriginal('value');
- $this->env->value = $oldValue;
+ $this->value = $oldValue;
$this->dispatch('error', 'Required environment variable cannot be empty.');
return;
@@ -122,10 +162,10 @@ class Show extends Component
$this->serialize();
if ($this->isSharedVariable) {
- unset($this->env->is_required);
+ unset($this->is_required);
}
- $this->env->save();
+ $this->syncData(true);
$this->dispatch('success', 'Environment variable updated.');
$this->dispatch('envsUpdated');
} catch (\Exception $e) {
diff --git a/app/Livewire/Project/Shared/ResourceOperations.php b/app/Livewire/Project/Shared/ResourceOperations.php
index de7bb3c05..98b31641a 100644
--- a/app/Livewire/Project/Shared/ResourceOperations.php
+++ b/app/Livewire/Project/Shared/ResourceOperations.php
@@ -60,7 +60,8 @@ class ResourceOperations extends Component
$environmentVaribles = $this->resource->environment_variables()->get();
foreach ($environmentVaribles as $environmentVarible) {
$newEnvironmentVariable = $environmentVarible->replicate()->fill([
- 'application_id' => $new_resource->id,
+ 'resourceable_id' => $new_resource->id,
+ 'resourceable_type' => $new_resource->getMorphClass(),
]);
$newEnvironmentVariable->save();
}
diff --git a/app/Models/Application.php b/app/Models/Application.php
index bfb2a1041..6413c8fea 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -695,46 +695,62 @@ class Application extends BaseModel
return $this->settings->is_static ? [80] : $this->ports_exposes_array;
}
- public function environment_variables(): HasMany
+ public function environment_variables()
{
- return $this->hasMany(EnvironmentVariable::class)->where('is_preview', false)->orderBy('key', 'asc');
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable')
+ ->where('is_preview', false)
+ ->orderBy('key', 'asc');
}
- public function runtime_environment_variables(): HasMany
+ public function runtime_environment_variables()
{
- return $this->hasMany(EnvironmentVariable::class)->where('is_preview', false)->where('key', 'not like', 'NIXPACKS_%');
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable')
+ ->where('is_preview', false)
+ ->where('key', 'not like', 'NIXPACKS_%');
}
- // Preview Deployments
-
- public function build_environment_variables(): HasMany
+ public function build_environment_variables()
{
- return $this->hasMany(EnvironmentVariable::class)->where('is_preview', false)->where('is_build_time', true)->where('key', 'not like', 'NIXPACKS_%');
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable')
+ ->where('is_preview', false)
+ ->where('is_build_time', true)
+ ->where('key', 'not like', 'NIXPACKS_%');
}
- public function nixpacks_environment_variables(): HasMany
+ public function nixpacks_environment_variables()
{
- return $this->hasMany(EnvironmentVariable::class)->where('is_preview', false)->where('key', 'like', 'NIXPACKS_%');
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable')
+ ->where('is_preview', false)
+ ->where('key', 'like', 'NIXPACKS_%');
}
- public function environment_variables_preview(): HasMany
+ public function environment_variables_preview()
{
- return $this->hasMany(EnvironmentVariable::class)->where('is_preview', true)->orderBy('key', 'asc');
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable')
+ ->where('is_preview', true)
+ ->orderByRaw("LOWER(key) LIKE LOWER('SERVICE%') DESC, LOWER(key) ASC");
}
- public function runtime_environment_variables_preview(): HasMany
+ public function runtime_environment_variables_preview()
{
- return $this->hasMany(EnvironmentVariable::class)->where('is_preview', true)->where('key', 'not like', 'NIXPACKS_%');
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable')
+ ->where('is_preview', true)
+ ->where('key', 'not like', 'NIXPACKS_%');
}
- public function build_environment_variables_preview(): HasMany
+ public function build_environment_variables_preview()
{
- return $this->hasMany(EnvironmentVariable::class)->where('is_preview', true)->where('is_build_time', true)->where('key', 'not like', 'NIXPACKS_%');
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable')
+ ->where('is_preview', true)
+ ->where('is_build_time', true)
+ ->where('key', 'not like', 'NIXPACKS_%');
}
- public function nixpacks_environment_variables_preview(): HasMany
+ public function nixpacks_environment_variables_preview()
{
- return $this->hasMany(EnvironmentVariable::class)->where('is_preview', true)->where('key', 'like', 'NIXPACKS_%');
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable')
+ ->where('is_preview', true)
+ ->where('key', 'like', 'NIXPACKS_%');
}
public function scheduled_tasks(): HasMany
diff --git a/app/Models/EnvironmentVariable.php b/app/Models/EnvironmentVariable.php
index 96c57e63e..507ff0d7e 100644
--- a/app/Models/EnvironmentVariable.php
+++ b/app/Models/EnvironmentVariable.php
@@ -14,9 +14,8 @@ use Visus\Cuid2\Cuid2;
properties: [
'id' => ['type' => 'integer'],
'uuid' => ['type' => 'string'],
- 'application_id' => ['type' => 'integer'],
- 'service_id' => ['type' => 'integer'],
- 'database_id' => ['type' => 'integer'],
+ 'resourceable_type' => ['type' => 'string'],
+ 'resourceable_id' => ['type' => 'integer'],
'is_build_time' => ['type' => 'boolean'],
'is_literal' => ['type' => 'boolean'],
'is_multiline' => ['type' => 'boolean'],
@@ -42,6 +41,8 @@ class EnvironmentVariable extends Model
'is_multiline' => 'boolean',
'is_preview' => 'boolean',
'version' => 'string',
+ 'resourceable_type' => 'string',
+ 'resourceable_id' => 'integer',
];
protected $appends = ['real_value', 'is_shared', 'is_really_required'];
@@ -53,18 +54,25 @@ class EnvironmentVariable extends Model
$model->uuid = (string) new Cuid2;
}
});
+
static::created(function (EnvironmentVariable $environment_variable) {
- if ($environment_variable->application_id && ! $environment_variable->is_preview) {
- $found = ModelsEnvironmentVariable::where('key', $environment_variable->key)->where('application_id', $environment_variable->application_id)->where('is_preview', true)->first();
+ if ($environment_variable->resourceable_type === Application::class && ! $environment_variable->is_preview) {
+ $found = ModelsEnvironmentVariable::where('key', $environment_variable->key)
+ ->where('resourceable_type', Application::class)
+ ->where('resourceable_id', $environment_variable->resourceable_id)
+ ->where('is_preview', true)
+ ->first();
+
if (! $found) {
- $application = Application::find($environment_variable->application_id);
- if ($application->build_pack !== 'dockerfile') {
+ $application = Application::find($environment_variable->resourceable_id);
+ if ($application && $application->build_pack !== 'dockerfile') {
ModelsEnvironmentVariable::create([
'key' => $environment_variable->key,
'value' => $environment_variable->value,
'is_build_time' => $environment_variable->is_build_time,
'is_multiline' => $environment_variable->is_multiline ?? false,
- 'application_id' => $environment_variable->application_id,
+ 'resourceable_type' => Application::class,
+ 'resourceable_id' => $environment_variable->resourceable_id,
'is_preview' => true,
]);
}
@@ -74,6 +82,7 @@ class EnvironmentVariable extends Model
'version' => config('constants.coolify.version'),
]);
});
+
static::saving(function (EnvironmentVariable $environmentVariable) {
$environmentVariable->updateIsShared();
});
@@ -92,43 +101,32 @@ class EnvironmentVariable extends Model
);
}
+ /**
+ * Get the parent resourceable model.
+ */
+ public function resourceable()
+ {
+ return $this->morphTo();
+ }
+
public function resource()
{
- $resource = null;
- if ($this->application_id) {
- $resource = Application::find($this->application_id);
- } elseif ($this->service_id) {
- $resource = Service::find($this->service_id);
- } elseif ($this->standalone_postgresql_id) {
- $resource = StandalonePostgresql::find($this->standalone_postgresql_id);
- } elseif ($this->standalone_redis_id) {
- $resource = StandaloneRedis::find($this->standalone_redis_id);
- } elseif ($this->standalone_mongodb_id) {
- $resource = StandaloneMongodb::find($this->standalone_mongodb_id);
- } elseif ($this->standalone_mysql_id) {
- $resource = StandaloneMysql::find($this->standalone_mysql_id);
- } elseif ($this->standalone_mariadb_id) {
- $resource = StandaloneMariadb::find($this->standalone_mariadb_id);
- } elseif ($this->standalone_keydb_id) {
- $resource = StandaloneKeydb::find($this->standalone_keydb_id);
- } elseif ($this->standalone_dragonfly_id) {
- $resource = StandaloneDragonfly::find($this->standalone_dragonfly_id);
- } elseif ($this->standalone_clickhouse_id) {
- $resource = StandaloneClickhouse::find($this->standalone_clickhouse_id);
- }
-
- return $resource;
+ return $this->resourceable;
}
public function realValue(): Attribute
{
- $resource = $this->resource();
-
return Attribute::make(
- get: function () use ($resource) {
- $env = $this->get_real_environment_variables($this->value, $resource);
+ get: function () {
+ if (! $this->relationLoaded('resourceable')) {
+ $this->load('resourceable');
+ }
+ $resource = $this->resourceable;
+ if (! $resource) {
+ return null;
+ }
- return data_get($env, 'value', $env);
+ return $this->get_real_environment_variables($this->value, $resource);
}
);
}
@@ -164,7 +162,6 @@ class EnvironmentVariable extends Model
if ($sharedEnvsFound->isEmpty()) {
return $environment_variable;
}
-
foreach ($sharedEnvsFound as $sharedEnv) {
$type = str($sharedEnv)->match('/(.*?)\./');
if (! collect(SHARED_VARIABLE_TYPES)->contains($type)) {
diff --git a/app/Models/Service.php b/app/Models/Service.php
index 5a2690490..c605f189b 100644
--- a/app/Models/Service.php
+++ b/app/Models/Service.php
@@ -1120,7 +1120,8 @@ class Service extends BaseModel
'key' => $key,
'value' => $value,
'is_build_time' => false,
- 'service_id' => $this->id,
+ 'resourceable_id' => $this->id,
+ 'resourceable_type' => $this->getMorphClass(),
'is_preview' => false,
]);
}
@@ -1232,14 +1233,17 @@ class Service extends BaseModel
return $this->hasMany(ScheduledTask::class)->orderBy('name', 'asc');
}
- public function environment_variables(): HasMany
+ public function environment_variables()
{
- return $this->hasMany(EnvironmentVariable::class)->orderByRaw("LOWER(key) LIKE LOWER('SERVICE%') DESC, LOWER(key) ASC");
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable')
+ ->orderBy('key', 'asc');
}
- public function environment_variables_preview(): HasMany
+ public function environment_variables_preview()
{
- return $this->hasMany(EnvironmentVariable::class)->where('is_preview', true)->orderByRaw("LOWER(key) LIKE LOWER('SERVICE%') DESC, LOWER(key) ASC");
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable')
+ ->where('is_preview', true)
+ ->orderByRaw("LOWER(key) LIKE LOWER('SERVICE%') DESC, LOWER(key) ASC");
}
public function workdir()
diff --git a/app/Models/StandaloneClickhouse.php b/app/Models/StandaloneClickhouse.php
index 6d66c6854..ec56d0fdd 100644
--- a/app/Models/StandaloneClickhouse.php
+++ b/app/Models/StandaloneClickhouse.php
@@ -5,7 +5,6 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
-use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class StandaloneClickhouse extends BaseModel
@@ -251,14 +250,15 @@ class StandaloneClickhouse extends BaseModel
return $this->morphTo();
}
- public function environment_variables(): HasMany
+ public function environment_variables()
{
- return $this->hasMany(EnvironmentVariable::class);
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable')
+ ->orderBy('key', 'asc');
}
- public function runtime_environment_variables(): HasMany
+ public function runtime_environment_variables()
{
- return $this->hasMany(EnvironmentVariable::class);
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable');
}
public function persistentStorages()
diff --git a/app/Models/StandaloneDragonfly.php b/app/Models/StandaloneDragonfly.php
index f7d83f0a3..683c9acb4 100644
--- a/app/Models/StandaloneDragonfly.php
+++ b/app/Models/StandaloneDragonfly.php
@@ -5,7 +5,6 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
-use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class StandaloneDragonfly extends BaseModel
@@ -251,14 +250,9 @@ class StandaloneDragonfly extends BaseModel
return $this->morphTo();
}
- public function environment_variables(): HasMany
+ public function runtime_environment_variables()
{
- return $this->hasMany(EnvironmentVariable::class);
- }
-
- public function runtime_environment_variables(): HasMany
- {
- return $this->hasMany(EnvironmentVariable::class);
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable');
}
public function persistentStorages()
@@ -319,4 +313,10 @@ class StandaloneDragonfly extends BaseModel
{
return false;
}
+
+ public function environment_variables()
+ {
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable')
+ ->orderBy('key', 'asc');
+ }
}
diff --git a/app/Models/StandaloneKeydb.php b/app/Models/StandaloneKeydb.php
index 083c743d9..e239020ac 100644
--- a/app/Models/StandaloneKeydb.php
+++ b/app/Models/StandaloneKeydb.php
@@ -5,7 +5,6 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
-use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class StandaloneKeydb extends BaseModel
@@ -251,14 +250,9 @@ class StandaloneKeydb extends BaseModel
return $this->morphTo();
}
- public function environment_variables(): HasMany
+ public function runtime_environment_variables()
{
- return $this->hasMany(EnvironmentVariable::class);
- }
-
- public function runtime_environment_variables(): HasMany
- {
- return $this->hasMany(EnvironmentVariable::class);
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable');
}
public function persistentStorages()
@@ -319,4 +313,10 @@ class StandaloneKeydb extends BaseModel
{
return false;
}
+
+ public function environment_variables()
+ {
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable')
+ ->orderBy('key', 'asc');
+ }
}
diff --git a/app/Models/StandaloneMariadb.php b/app/Models/StandaloneMariadb.php
index 833dad6c4..c010cf441 100644
--- a/app/Models/StandaloneMariadb.php
+++ b/app/Models/StandaloneMariadb.php
@@ -5,7 +5,6 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
-use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class StandaloneMariadb extends BaseModel
@@ -251,14 +250,15 @@ class StandaloneMariadb extends BaseModel
return $this->morphTo();
}
- public function environment_variables(): HasMany
+ public function environment_variables()
{
- return $this->hasMany(EnvironmentVariable::class);
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable')
+ ->orderBy('key', 'asc');
}
- public function runtime_environment_variables(): HasMany
+ public function runtime_environment_variables()
{
- return $this->hasMany(EnvironmentVariable::class);
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable');
}
public function persistentStorages()
diff --git a/app/Models/StandaloneMongodb.php b/app/Models/StandaloneMongodb.php
index dd8893180..e18317088 100644
--- a/app/Models/StandaloneMongodb.php
+++ b/app/Models/StandaloneMongodb.php
@@ -5,7 +5,6 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
-use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class StandaloneMongodb extends BaseModel
@@ -271,14 +270,9 @@ class StandaloneMongodb extends BaseModel
return $this->morphTo();
}
- public function environment_variables(): HasMany
+ public function runtime_environment_variables()
{
- return $this->hasMany(EnvironmentVariable::class);
- }
-
- public function runtime_environment_variables(): HasMany
- {
- return $this->hasMany(EnvironmentVariable::class);
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable');
}
public function persistentStorages()
@@ -339,4 +333,10 @@ class StandaloneMongodb extends BaseModel
{
return true;
}
+
+ public function environment_variables()
+ {
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable')
+ ->orderBy('key', 'asc');
+ }
}
diff --git a/app/Models/StandaloneMysql.php b/app/Models/StandaloneMysql.php
index 710fea1bc..e6c976a8a 100644
--- a/app/Models/StandaloneMysql.php
+++ b/app/Models/StandaloneMysql.php
@@ -5,7 +5,6 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
-use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class StandaloneMysql extends BaseModel
@@ -252,14 +251,9 @@ class StandaloneMysql extends BaseModel
return $this->morphTo();
}
- public function environment_variables(): HasMany
+ public function runtime_environment_variables()
{
- return $this->hasMany(EnvironmentVariable::class);
- }
-
- public function runtime_environment_variables(): HasMany
- {
- return $this->hasMany(EnvironmentVariable::class);
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable');
}
public function persistentStorages()
@@ -320,4 +314,10 @@ class StandaloneMysql extends BaseModel
{
return true;
}
+
+ public function environment_variables()
+ {
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable')
+ ->orderBy('key', 'asc');
+ }
}
diff --git a/app/Models/StandalonePostgresql.php b/app/Models/StandalonePostgresql.php
index 4a457a6cf..141768a7c 100644
--- a/app/Models/StandalonePostgresql.php
+++ b/app/Models/StandalonePostgresql.php
@@ -5,7 +5,6 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
-use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class StandalonePostgresql extends BaseModel
@@ -252,14 +251,9 @@ class StandalonePostgresql extends BaseModel
return $this->morphTo();
}
- public function environment_variables(): HasMany
+ public function runtime_environment_variables()
{
- return $this->hasMany(EnvironmentVariable::class);
- }
-
- public function runtime_environment_variables(): HasMany
- {
- return $this->hasMany(EnvironmentVariable::class);
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable');
}
public function persistentStorages()
@@ -320,4 +314,10 @@ class StandalonePostgresql extends BaseModel
return $parsedCollection->toArray();
}
+
+ public function environment_variables()
+ {
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable')
+ ->orderBy('key', 'asc');
+ }
}
diff --git a/app/Models/StandaloneRedis.php b/app/Models/StandaloneRedis.php
index 826bb951c..df1681fc9 100644
--- a/app/Models/StandaloneRedis.php
+++ b/app/Models/StandaloneRedis.php
@@ -5,7 +5,6 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
-use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class StandaloneRedis extends BaseModel
@@ -262,14 +261,9 @@ class StandaloneRedis extends BaseModel
return $this->morphTo();
}
- public function environment_variables(): HasMany
+ public function runtime_environment_variables()
{
- return $this->hasMany(EnvironmentVariable::class);
- }
-
- public function runtime_environment_variables(): HasMany
- {
- return $this->hasMany(EnvironmentVariable::class);
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable');
}
public function persistentStorages()
@@ -359,4 +353,10 @@ class StandaloneRedis extends BaseModel
}
);
}
+
+ public function environment_variables()
+ {
+ return $this->morphMany(EnvironmentVariable::class, 'resourceable')
+ ->orderBy('key', 'asc');
+ }
}
diff --git a/app/View/Components/Forms/Button.php b/app/View/Components/Forms/Button.php
index da8b46dec..bf88d3f88 100644
--- a/app/View/Components/Forms/Button.php
+++ b/app/View/Components/Forms/Button.php
@@ -15,7 +15,8 @@ class Button extends Component
public bool $disabled = false,
public bool $noStyle = false,
public ?string $modalId = null,
- public string $defaultClass = 'button'
+ public string $defaultClass = 'button',
+ public bool $showLoadingIndicator = true,
) {
if ($this->noStyle) {
$this->defaultClass = '';
diff --git a/bootstrap/helpers/services.php b/bootstrap/helpers/services.php
index fd2e1231f..cd99713a2 100644
--- a/bootstrap/helpers/services.php
+++ b/bootstrap/helpers/services.php
@@ -2,6 +2,7 @@
use App\Models\Application;
use App\Models\EnvironmentVariable;
+use App\Models\Service;
use App\Models\ServiceApplication;
use App\Models\ServiceDatabase;
use Illuminate\Support\Stringable;
@@ -119,7 +120,10 @@ function updateCompose(ServiceApplication|ServiceDatabase $resource)
if ($resourceFqdns->count() === 1) {
$resourceFqdns = $resourceFqdns->first();
$variableName = 'SERVICE_FQDN_'.str($resource->name)->upper()->replace('-', '');
- $generatedEnv = EnvironmentVariable::where('service_id', $resource->service_id)->where('key', $variableName)->first();
+ $generatedEnv = EnvironmentVariable::where('resourceable_type', Service::class)
+ ->where('resourceable_id', $resource->service_id)
+ ->where('key', $variableName)
+ ->first();
$fqdn = Url::fromString($resourceFqdns);
$port = $fqdn->getPort();
$path = $fqdn->getPath();
@@ -134,7 +138,10 @@ function updateCompose(ServiceApplication|ServiceDatabase $resource)
}
if ($port) {
$variableName = $variableName."_$port";
- $generatedEnv = EnvironmentVariable::where('service_id', $resource->service_id)->where('key', $variableName)->first();
+ $generatedEnv = EnvironmentVariable::where('resourceable_type', Service::class)
+ ->where('resourceable_id', $resource->service_id)
+ ->where('key', $variableName)
+ ->first();
if ($generatedEnv) {
if ($path === '/') {
$generatedEnv->value = $fqdn;
@@ -145,7 +152,10 @@ function updateCompose(ServiceApplication|ServiceDatabase $resource)
}
}
$variableName = 'SERVICE_URL_'.str($resource->name)->upper()->replace('-', '');
- $generatedEnv = EnvironmentVariable::where('service_id', $resource->service_id)->where('key', $variableName)->first();
+ $generatedEnv = EnvironmentVariable::where('resourceable_type', Service::class)
+ ->where('resourceable_id', $resource->service_id)
+ ->where('key', $variableName)
+ ->first();
$url = Url::fromString($fqdn);
$port = $url->getPort();
$path = $url->getPath();
@@ -161,7 +171,10 @@ function updateCompose(ServiceApplication|ServiceDatabase $resource)
}
if ($port) {
$variableName = $variableName."_$port";
- $generatedEnv = EnvironmentVariable::where('service_id', $resource->service_id)->where('key', $variableName)->first();
+ $generatedEnv = EnvironmentVariable::where('resourceable_type', Service::class)
+ ->where('resourceable_id', $resource->service_id)
+ ->where('key', $variableName)
+ ->first();
if ($generatedEnv) {
if ($path === '/') {
$generatedEnv->value = $url;
@@ -179,10 +192,16 @@ function updateCompose(ServiceApplication|ServiceDatabase $resource)
$path = $host->getPath();
$host = $host->getScheme().'://'.$host->getHost();
if ($port) {
- $port_envs = EnvironmentVariable::where('service_id', $resource->service_id)->where('key', 'like', "SERVICE_FQDN_%_$port")->get();
+ $port_envs = EnvironmentVariable::where('resourceable_type', Service::class)
+ ->where('resourceable_id', $resource->service_id)
+ ->where('key', 'like', "SERVICE_FQDN_%_$port")
+ ->get();
foreach ($port_envs as $port_env) {
$service_fqdn = str($port_env->key)->beforeLast('_')->after('SERVICE_FQDN_');
- $env = EnvironmentVariable::where('service_id', $resource->service_id)->where('key', 'SERVICE_FQDN_'.$service_fqdn)->first();
+ $env = EnvironmentVariable::where('resourceable_type', Service::class)
+ ->where('resourceable_id', $resource->service_id)
+ ->where('key', 'SERVICE_FQDN_'.$service_fqdn)
+ ->first();
if ($env) {
if ($path === '/') {
$env->value = $host;
@@ -198,10 +217,16 @@ function updateCompose(ServiceApplication|ServiceDatabase $resource)
}
$port_env->save();
}
- $port_envs_url = EnvironmentVariable::where('service_id', $resource->service_id)->where('key', 'like', "SERVICE_URL_%_$port")->get();
+ $port_envs_url = EnvironmentVariable::where('resourceable_type', Service::class)
+ ->where('resourceable_id', $resource->service_id)
+ ->where('key', 'like', "SERVICE_URL_%_$port")
+ ->get();
foreach ($port_envs_url as $port_env_url) {
$service_url = str($port_env_url->key)->beforeLast('_')->after('SERVICE_URL_');
- $env = EnvironmentVariable::where('service_id', $resource->service_id)->where('key', 'SERVICE_URL_'.$service_url)->first();
+ $env = EnvironmentVariable::where('resourceable_type', Service::class)
+ ->where('resourceable_id', $resource->service_id)
+ ->where('key', 'SERVICE_URL_'.$service_url)
+ ->first();
if ($env) {
if ($path === '/') {
$env->value = $url;
@@ -219,7 +244,10 @@ function updateCompose(ServiceApplication|ServiceDatabase $resource)
}
} else {
$variableName = 'SERVICE_FQDN_'.str($resource->name)->upper()->replace('-', '');
- $generatedEnv = EnvironmentVariable::where('service_id', $resource->service_id)->where('key', $variableName)->first();
+ $generatedEnv = EnvironmentVariable::where('resourceable_type', Service::class)
+ ->where('resourceable_id', $resource->service_id)
+ ->where('key', $variableName)
+ ->first();
$fqdn = Url::fromString($fqdn);
$fqdn = $fqdn->getScheme().'://'.$fqdn->getHost().$fqdn->getPath();
if ($generatedEnv) {
@@ -227,7 +255,10 @@ function updateCompose(ServiceApplication|ServiceDatabase $resource)
$generatedEnv->save();
}
$variableName = 'SERVICE_URL_'.str($resource->name)->upper()->replace('-', '');
- $generatedEnv = EnvironmentVariable::where('service_id', $resource->service_id)->where('key', $variableName)->first();
+ $generatedEnv = EnvironmentVariable::where('resourceable_type', Service::class)
+ ->where('resourceable_id', $resource->service_id)
+ ->where('key', $variableName)
+ ->first();
$url = Url::fromString($fqdn);
$url = $url->getHost().$url->getPath();
if ($generatedEnv) {
diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php
index 7aa411cd1..b9fde2070 100644
--- a/bootstrap/helpers/shared.php
+++ b/bootstrap/helpers/shared.php
@@ -1819,7 +1819,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
'key' => $key,
'value' => $fqdn,
'is_build_time' => false,
- 'service_id' => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
'is_preview' => false,
]);
}
@@ -1831,7 +1832,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
}
$env = EnvironmentVariable::where([
'key' => $key,
- 'service_id' => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
])->first();
if ($env) {
$env_url = Url::fromString($savedService->fqdn);
@@ -1854,14 +1856,16 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
if ($value?->startsWith('$')) {
$foundEnv = EnvironmentVariable::where([
'key' => $key,
- 'service_id' => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
])->first();
$value = replaceVariables($value);
$key = $value;
if ($value->startsWith('SERVICE_')) {
$foundEnv = EnvironmentVariable::where([
'key' => $key,
- 'service_id' => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
])->first();
['command' => $command, 'forService' => $forService, 'generatedValue' => $generatedValue, 'port' => $port] = parseEnvVariable($value);
if (! is_null($command)) {
@@ -1895,7 +1899,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
'key' => $key,
'value' => $fqdn,
'is_build_time' => false,
- 'service_id' => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
'is_preview' => false,
]);
}
@@ -1912,7 +1917,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
}
$env = EnvironmentVariable::where([
'key' => $key,
- 'service_id' => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
])->first();
if ($env) {
$env_url = Url::fromString($env->value);
@@ -1932,7 +1938,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
'key' => $key,
'value' => $generatedValue,
'is_build_time' => false,
- 'service_id' => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
'is_preview' => false,
]);
}
@@ -1957,18 +1964,21 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
}
$foundEnv = EnvironmentVariable::where([
'key' => $key,
- 'service_id' => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
])->first();
if ($foundEnv) {
$defaultValue = data_get($foundEnv, 'value');
}
EnvironmentVariable::updateOrCreate([
'key' => $key,
- 'service_id' => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
], [
'value' => $defaultValue,
'is_build_time' => false,
- 'service_id' => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
'is_preview' => false,
]);
}
@@ -2831,6 +2841,10 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
data_set($service, 'container_name', $containerName);
data_forget($service, 'volumes.*.content');
data_forget($service, 'volumes.*.isDirectory');
+ data_forget($service, 'volumes.*.is_directory');
+ data_forget($service, 'exclude_from_hc');
+ data_set($service, 'environment', $serviceVariables->toArray());
+ updateCompose($savedService);
return $service;
});
@@ -2869,13 +2883,11 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
}
if ($isApplication) {
- $nameOfId = 'application_id';
$pullRequestId = $pull_request_id;
$isPullRequest = $pullRequestId == 0 ? false : true;
$server = data_get($resource, 'destination.server');
$fileStorages = $resource->fileStorages();
} elseif ($isService) {
- $nameOfId = 'service_id';
$server = data_get($resource, 'server');
$allServices = get_service_templates();
} else {
@@ -3042,9 +3054,10 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
}
if (substr_count(str($key)->value(), '_') === 2) {
- $resource->environment_variables()->where('key', $key->value())->where($nameOfId, $resource->id)->firstOrCreate([
+ $resource->environment_variables()->firstOrCreate([
'key' => $key->value(),
- $nameOfId => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
], [
'value' => $fqdn,
'is_build_time' => false,
@@ -3053,9 +3066,10 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
}
if (substr_count(str($key)->value(), '_') === 3) {
$newKey = str($key)->beforeLast('_');
- $resource->environment_variables()->where('key', $newKey->value())->where($nameOfId, $resource->id)->firstOrCreate([
+ $resource->environment_variables()->firstOrCreate([
'key' => $newKey->value(),
- $nameOfId => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
], [
'value' => $fqdn,
'is_build_time' => false,
@@ -3071,7 +3085,7 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
$key = str($key);
$value = replaceVariables($value);
$command = parseCommandFromMagicEnvVariable($key);
- $found = $resource->environment_variables()->where('key', $key->value())->where($nameOfId, $resource->id)->first();
+ $found = $resource->environment_variables()->where('key', $key->value())->where('resourceable_type', get_class($resource))->where('resourceable_id', $resource->id)->first();
if ($found) {
continue;
}
@@ -3085,9 +3099,10 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
} elseif ($isService) {
$fqdn = generateFqdn($server, "$fqdnFor-$uuid");
}
- $resource->environment_variables()->where('key', $key->value())->where($nameOfId, $resource->id)->firstOrCreate([
+ $resource->environment_variables()->firstOrCreate([
'key' => $key->value(),
- $nameOfId => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
], [
'value' => $fqdn,
'is_build_time' => false,
@@ -3104,9 +3119,10 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
$fqdn = generateFqdn($server, "$fqdnFor-$uuid");
}
$fqdn = str($fqdn)->replace('http://', '')->replace('https://', '');
- $resource->environment_variables()->where('key', $key->value())->where($nameOfId, $resource->id)->firstOrCreate([
+ $resource->environment_variables()->firstOrCreate([
'key' => $key->value(),
- $nameOfId => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
], [
'value' => $fqdn,
'is_build_time' => false,
@@ -3114,9 +3130,10 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
]);
} else {
$value = generateEnvValue($command, $resource);
- $resource->environment_variables()->where('key', $key->value())->where($nameOfId, $resource->id)->firstOrCreate([
+ $resource->environment_variables()->firstOrCreate([
'key' => $key->value(),
- $nameOfId => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
], [
'value' => $value,
'is_build_time' => false,
@@ -3464,9 +3481,10 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
$originalValue = $value;
$parsedValue = replaceVariables($value);
if ($value->startsWith('$SERVICE_')) {
- $resource->environment_variables()->where('key', $key)->where($nameOfId, $resource->id)->firstOrCreate([
+ $resource->environment_variables()->firstOrCreate([
'key' => $key,
- $nameOfId => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
], [
'value' => $value,
'is_build_time' => false,
@@ -3480,9 +3498,10 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
}
if ($key->value() === $parsedValue->value()) {
$value = null;
- $resource->environment_variables()->where('key', $key)->where($nameOfId, $resource->id)->firstOrCreate([
+ $resource->environment_variables()->firstOrCreate([
'key' => $key,
- $nameOfId => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
], [
'value' => $value,
'is_build_time' => false,
@@ -3516,22 +3535,24 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
if ($originalValue->value() === $value->value()) {
// This means the variable does not have a default value, so it needs to be created in Coolify
$parsedKeyValue = replaceVariables($value);
- $resource->environment_variables()->where('key', $parsedKeyValue)->where($nameOfId, $resource->id)->firstOrCreate([
+ $resource->environment_variables()->firstOrCreate([
'key' => $parsedKeyValue,
- $nameOfId => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
], [
'is_build_time' => false,
'is_preview' => false,
'is_required' => $isRequired,
]);
// Add the variable to the environment so it will be shown in the deployable compose file
- $environment[$parsedKeyValue->value()] = $resource->environment_variables()->where('key', $parsedKeyValue)->where($nameOfId, $resource->id)->first()->value;
+ $environment[$parsedKeyValue->value()] = $resource->environment_variables()->where('key', $parsedKeyValue)->where('resourceable_type', get_class($resource))->where('resourceable_id', $resource->id)->first()->value;
continue;
}
- $resource->environment_variables()->where('key', $key)->where($nameOfId, $resource->id)->firstOrCreate([
+ $resource->environment_variables()->firstOrCreate([
'key' => $key,
- $nameOfId => $resource->id,
+ 'resourceable_type' => get_class($resource),
+ 'resourceable_id' => $resource->id,
], [
'value' => $value,
'is_build_time' => false,
diff --git a/database/migrations/2024_12_16_134437_add_resourceable_columns_to_environment_variables_table.php b/database/migrations/2024_12_16_134437_add_resourceable_columns_to_environment_variables_table.php
new file mode 100644
index 000000000..c4b718638
--- /dev/null
+++ b/database/migrations/2024_12_16_134437_add_resourceable_columns_to_environment_variables_table.php
@@ -0,0 +1,165 @@
+string('resourceable_type')->nullable();
+ $table->unsignedBigInteger('resourceable_id')->nullable();
+ $table->index(['resourceable_type', 'resourceable_id']);
+ });
+
+ // Populate the new columns
+ DB::table('environment_variables')->whereNotNull('application_id')
+ ->update([
+ 'resourceable_type' => 'App\\Models\\Application',
+ 'resourceable_id' => DB::raw('application_id'),
+ ]);
+
+ DB::table('environment_variables')->whereNotNull('service_id')
+ ->update([
+ 'resourceable_type' => 'App\\Models\\Service',
+ 'resourceable_id' => DB::raw('service_id'),
+ ]);
+
+ DB::table('environment_variables')->whereNotNull('standalone_postgresql_id')
+ ->update([
+ 'resourceable_type' => 'App\\Models\\StandalonePostgresql',
+ 'resourceable_id' => DB::raw('standalone_postgresql_id'),
+ ]);
+
+ DB::table('environment_variables')->whereNotNull('standalone_redis_id')
+ ->update([
+ 'resourceable_type' => 'App\\Models\\StandaloneRedis',
+ 'resourceable_id' => DB::raw('standalone_redis_id'),
+ ]);
+
+ DB::table('environment_variables')->whereNotNull('standalone_mongodb_id')
+ ->update([
+ 'resourceable_type' => 'App\\Models\\StandaloneMongodb',
+ 'resourceable_id' => DB::raw('standalone_mongodb_id'),
+ ]);
+
+ DB::table('environment_variables')->whereNotNull('standalone_mysql_id')
+ ->update([
+ 'resourceable_type' => 'App\\Models\\StandaloneMysql',
+ 'resourceable_id' => DB::raw('standalone_mysql_id'),
+ ]);
+
+ DB::table('environment_variables')->whereNotNull('standalone_mariadb_id')
+ ->update([
+ 'resourceable_type' => 'App\\Models\\StandaloneMariadb',
+ 'resourceable_id' => DB::raw('standalone_mariadb_id'),
+ ]);
+
+ DB::table('environment_variables')->whereNotNull('standalone_keydb_id')
+ ->update([
+ 'resourceable_type' => 'App\\Models\\StandaloneKeydb',
+ 'resourceable_id' => DB::raw('standalone_keydb_id'),
+ ]);
+
+ DB::table('environment_variables')->whereNotNull('standalone_dragonfly_id')
+ ->update([
+ 'resourceable_type' => 'App\\Models\\StandaloneDragonfly',
+ 'resourceable_id' => DB::raw('standalone_dragonfly_id'),
+ ]);
+
+ DB::table('environment_variables')->whereNotNull('standalone_clickhouse_id')
+ ->update([
+ 'resourceable_type' => 'App\\Models\\StandaloneClickhouse',
+ 'resourceable_id' => DB::raw('standalone_clickhouse_id'),
+ ]);
+
+ // After successful migration, we can drop the old foreign key columns
+ Schema::table('environment_variables', function (Blueprint $table) {
+ $table->dropColumn([
+ 'application_id',
+ 'service_id',
+ 'standalone_postgresql_id',
+ 'standalone_redis_id',
+ 'standalone_mongodb_id',
+ 'standalone_mysql_id',
+ 'standalone_mariadb_id',
+ 'standalone_keydb_id',
+ 'standalone_dragonfly_id',
+ 'standalone_clickhouse_id',
+ ]);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('environment_variables', function (Blueprint $table) {
+ // Restore the old columns
+ $table->unsignedBigInteger('application_id')->nullable();
+ $table->unsignedBigInteger('service_id')->nullable();
+ $table->unsignedBigInteger('standalone_postgresql_id')->nullable();
+ $table->unsignedBigInteger('standalone_redis_id')->nullable();
+ $table->unsignedBigInteger('standalone_mongodb_id')->nullable();
+ $table->unsignedBigInteger('standalone_mysql_id')->nullable();
+ $table->unsignedBigInteger('standalone_mariadb_id')->nullable();
+ $table->unsignedBigInteger('standalone_keydb_id')->nullable();
+ $table->unsignedBigInteger('standalone_dragonfly_id')->nullable();
+ $table->unsignedBigInteger('standalone_clickhouse_id')->nullable();
+ });
+
+ Schema::table('environment_variables', function (Blueprint $table) {
+ // Restore data from polymorphic relationship
+ DB::table('environment_variables')
+ ->where('resourceable_type', 'App\\Models\\Application')
+ ->update(['application_id' => DB::raw('resourceable_id')]);
+
+ DB::table('environment_variables')
+ ->where('resourceable_type', 'App\\Models\\Service')
+ ->update(['service_id' => DB::raw('resourceable_id')]);
+
+ DB::table('environment_variables')
+ ->where('resourceable_type', 'App\\Models\\StandalonePostgresql')
+ ->update(['standalone_postgresql_id' => DB::raw('resourceable_id')]);
+
+ DB::table('environment_variables')
+ ->where('resourceable_type', 'App\\Models\\StandaloneRedis')
+ ->update(['standalone_redis_id' => DB::raw('resourceable_id')]);
+
+ DB::table('environment_variables')
+ ->where('resourceable_type', 'App\\Models\\StandaloneMongodb')
+ ->update(['standalone_mongodb_id' => DB::raw('resourceable_id')]);
+
+ DB::table('environment_variables')
+ ->where('resourceable_type', 'App\\Models\\StandaloneMysql')
+ ->update(['standalone_mysql_id' => DB::raw('resourceable_id')]);
+
+ DB::table('environment_variables')
+ ->where('resourceable_type', 'App\\Models\\StandaloneMariadb')
+ ->update(['standalone_mariadb_id' => DB::raw('resourceable_id')]);
+
+ DB::table('environment_variables')
+ ->where('resourceable_type', 'App\\Models\\StandaloneKeydb')
+ ->update(['standalone_keydb_id' => DB::raw('resourceable_id')]);
+
+ DB::table('environment_variables')
+ ->where('resourceable_type', 'App\\Models\\StandaloneDragonfly')
+ ->update(['standalone_dragonfly_id' => DB::raw('resourceable_id')]);
+
+ DB::table('environment_variables')
+ ->where('resourceable_type', 'App\\Models\\StandaloneClickhouse')
+ ->update(['standalone_clickhouse_id' => DB::raw('resourceable_id')]);
+
+ // Drop the polymorphic columns
+ $table->dropIndex(['resourceable_type', 'resourceable_id']);
+ $table->dropColumn(['resourceable_type', 'resourceable_id']);
+ });
+ }
+};
diff --git a/resources/views/components/forms/button.blade.php b/resources/views/components/forms/button.blade.php
index a109e84ac..96cdb4420 100644
--- a/resources/views/components/forms/button.blade.php
+++ b/resources/views/components/forms/button.blade.php
@@ -8,11 +8,13 @@
@endisset>
{{ $slot }}
- @if ($attributes->whereStartsWith('wire:click')->first())
-
- @elseif($attributes->whereStartsWith('wire:target')->first())
-
+ @if ($showLoadingIndicator)
+ @if ($attributes->whereStartsWith('wire:click')->first())
+
+ @elseif($attributes->whereStartsWith('wire:target')->first())
+
+ @endif
@endif
diff --git a/resources/views/components/loading.blade.php b/resources/views/components/loading.blade.php
index 7ee3b1d1a..80a47375e 100644
--- a/resources/views/components/loading.blade.php
+++ b/resources/views/components/loading.blade.php
@@ -3,8 +3,8 @@
@if (isset($text))
{{ $text }}
@endif
-
diff --git a/resources/views/components/status/running.blade.php b/resources/views/components/status/running.blade.php
index 0e0f08fa4..4e5f0c275 100644
--- a/resources/views/components/status/running.blade.php
+++ b/resources/views/components/status/running.blade.php
@@ -5,30 +5,42 @@
'noLoading' => false,
])
- @if (!$noLoading)
-
- @endif
-
-
-
- @if ($lastDeploymentLink)
-
- {{ str($status)->before(':')->headline() }}
-
- @else
- {{ str($status)->before(':')->headline() }}
- @endif
-
- @if (!str($status)->startsWith('Proxy') && !str($status)->contains('('))
- @if (str($status)->contains('unhealthy'))
-
+
+
+
+
+
+
+
+
+ @if ($lastDeploymentLink)
+
+ {{ str($status)->before(':')->headline() }}
+
+ @else
+ {{ str($status)->before(':')->headline() }}
+ @endif
+
+ @php
+ $showUnhealthyHelper =
+ !str($status)->startsWith('Proxy') &&
+ !str($status)->contains('(') &&
+ str($status)->contains('unhealthy');
+ @endphp
+ @if ($showUnhealthyHelper)
+
-
-
+
+
+
@endif
- @endif
-
+
+
diff --git a/resources/views/livewire/project/database/heading.blade.php b/resources/views/livewire/project/database/heading.blade.php
index e334b2ce9..237d679c6 100644
--- a/resources/views/livewire/project/database/heading.blade.php
+++ b/resources/views/livewire/project/database/heading.blade.php
@@ -3,7 +3,7 @@
Database Startup
-
+
diff --git a/resources/views/livewire/project/shared/environment-variable/all.blade.php b/resources/views/livewire/project/shared/environment-variable/all.blade.php
index 38ea192b5..3be31ba55 100644
--- a/resources/views/livewire/project/shared/environment-variable/all.blade.php
+++ b/resources/views/livewire/project/shared/environment-variable/all.blade.php
@@ -13,7 +13,7 @@
Environment variables (secrets) for this resource.
@if ($this->resourceClass === 'App\Models\Application' && data_get($this->resource, 'build_pack') !== 'dockercompose')
-
@@ -55,10 +55,10 @@
Preview Deployments Environment Variables
Environment (secrets) variables for Preview Deployments.
- @foreach ($resource->environment_variables_preview as $env)
+ {{-- @foreach ($resource->environment_variables_preview as $env)
- @endforeach
+ @endforeach --}}
@endif
@else