From f934dfef33837ea92c33ea39bc3c7b152e87e49d Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 7 Dec 2023 22:56:55 +0100 Subject: [PATCH] wip livewire migration --- app/Livewire/CheckLicense.php | 2 +- app/Livewire/Destination/Form.php | 2 +- .../Destination/New/StandaloneDocker.php | 2 +- app/Livewire/ForcePasswordReset.php | 2 +- app/Livewire/PrivateKey/Change.php | 2 +- app/Livewire/PrivateKey/Create.php | 4 +-- app/Livewire/Project/AddEmpty.php | 2 +- app/Livewire/Project/AddEnvironment.php | 4 +-- .../Project/Application/Configuration.php | 6 ++-- app/Livewire/Project/Application/Heading.php | 12 +++---- app/Livewire/Project/Application/Previews.php | 4 +-- app/Livewire/Project/Application/Rollback.php | 5 ++- app/Livewire/Project/CloneProject.php | 4 +-- app/Livewire/Project/Database/BackupEdit.php | 4 +-- app/Livewire/Project/DeleteEnvironment.php | 2 +- app/Livewire/Project/DeleteProject.php | 2 +- app/Livewire/Project/New/DockerCompose.php | 3 +- app/Livewire/Project/New/DockerImage.php | 5 ++- app/Livewire/Project/New/EmptyProject.php | 2 +- .../Project/New/GithubPrivateRepository.php | 4 +-- .../New/GithubPrivateRepositoryDeployKey.php | 8 ++--- .../Project/New/PublicGitRepository.php | 8 ++--- app/Livewire/Project/New/Select.php | 8 ++--- app/Livewire/Project/New/SimpleDockerfile.php | 4 +-- app/Livewire/Project/Service/Application.php | 2 +- app/Livewire/Project/Shared/Danger.php | 4 +-- app/Livewire/Project/Shared/GetLogs.php | 36 ++++++++++--------- app/Livewire/Server/Delete.php | 2 +- app/Livewire/Server/Destination/Show.php | 4 +-- app/Livewire/Server/Form.php | 4 ++- app/Livewire/Server/LogDrains.php | 4 +-- app/Livewire/Server/New/ByIp.php | 2 +- app/Livewire/Server/PrivateKey/Show.php | 2 +- app/Livewire/Server/Proxy/Logs.php | 4 +-- app/Livewire/Server/Proxy/Show.php | 4 +-- app/Livewire/Server/Show.php | 4 +-- app/Livewire/Source/Github/Change.php | 6 ++-- app/Livewire/Source/Github/Create.php | 2 +- app/Livewire/Subscription/Show.php | 2 +- app/Livewire/Team/Create.php | 2 +- app/Livewire/Team/Delete.php | 2 +- app/Livewire/Team/Storage/Create.php | 2 +- app/Livewire/Team/Storage/Form.php | 2 +- app/Livewire/Waitlist/Index.php | 2 +- bootstrap/helpers/remoteProcess.php | 1 + bootstrap/helpers/subscriptions.php | 23 ++++++------ database/seeders/PrivateKeySeeder.php | 2 ++ .../components/databases/navbar.blade.php | 8 ++--- .../resources/breadcrumbs.blade.php | 2 +- .../components/security/navbar.blade.php | 4 +-- .../views/components/server/navbar.blade.php | 10 +++--- .../components/services/navbar.blade.php | 2 +- .../views/components/team/navbar.blade.php | 10 +++--- .../application/configuration.blade.php | 22 ++++++------ .../livewire/project/service/index.blade.php | 10 +++--- .../livewire/project/service/show.blade.php | 4 +-- .../livewire/project/shared/logs.blade.php | 2 +- resources/views/livewire/server/all.blade.php | 4 +-- .../views/livewire/server/delete.blade.php | 8 ++--- .../views/livewire/switch-team.blade.php | 2 +- resources/views/project/resources.blade.php | 2 +- .../security/private-key/index.blade.php | 4 +-- resources/views/source/all.blade.php | 4 +-- resources/views/team/storages/all.blade.php | 2 +- 64 files changed, 164 insertions(+), 155 deletions(-) diff --git a/app/Livewire/CheckLicense.php b/app/Livewire/CheckLicense.php index 0b3677fc2..b77cc6afe 100644 --- a/app/Livewire/CheckLicense.php +++ b/app/Livewire/CheckLicense.php @@ -37,7 +37,7 @@ class CheckLicense extends Component } catch (\Throwable $e) { session()->flash('error', 'Something went wrong. Please contact support.
Error: ' . $e->getMessage()); ray($e->getMessage()); - return redirect()->to('/settings/license'); + return $this->redirect('/settings/license', navigate: true); } } } diff --git a/app/Livewire/Destination/Form.php b/app/Livewire/Destination/Form.php index b59708303..979546074 100644 --- a/app/Livewire/Destination/Form.php +++ b/app/Livewire/Destination/Form.php @@ -36,7 +36,7 @@ class Form extends Component instant_remote_process(['docker network rm -f ' . $this->destination->network], $this->destination->server); } $this->destination->delete(); - return redirect()->route('dashboard'); + return $this->redirectRoute('dashboard', navigate: true); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Destination/New/StandaloneDocker.php b/app/Livewire/Destination/New/StandaloneDocker.php index 6634214ab..72516752a 100644 --- a/app/Livewire/Destination/New/StandaloneDocker.php +++ b/app/Livewire/Destination/New/StandaloneDocker.php @@ -70,7 +70,7 @@ class StandaloneDocker extends Component ]); } $this->createNetworkAndAttachToProxy(); - return redirect()->route('destination.show', $docker->uuid); + return $this->redirectRoute('destination.show', $docker->uuid, navigate: true); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/ForcePasswordReset.php b/app/Livewire/ForcePasswordReset.php index e5a9a079a..31c4f3bac 100644 --- a/app/Livewire/ForcePasswordReset.php +++ b/app/Livewire/ForcePasswordReset.php @@ -35,7 +35,7 @@ class ForcePasswordReset extends Component if ($firstLogin) { send_internal_notification('First login for ' . auth()->user()->email); } - return redirect()->route('dashboard'); + return $this->redirectRoute('dashboard', navigate: true); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/PrivateKey/Change.php b/app/Livewire/PrivateKey/Change.php index 8177ea55b..6dc7f3e8c 100644 --- a/app/Livewire/PrivateKey/Change.php +++ b/app/Livewire/PrivateKey/Change.php @@ -35,7 +35,7 @@ class Change extends Component if ($this->private_key->isEmpty()) { $this->private_key->delete(); currentTeam()->privateKeys = PrivateKey::where('team_id', currentTeam()->id)->get(); - return redirect()->route('security.private-key.index'); + return $this->redirectRoute('security.private-key.index', navigate: true); } $this->dispatch('error', 'This private key is in use and cannot be deleted. Please delete all servers, applications, and GitHub/GitLab apps that use this private key before deleting it.'); } catch (\Throwable $e) { diff --git a/app/Livewire/PrivateKey/Create.php b/app/Livewire/PrivateKey/Create.php index a82b6fb48..430ea995e 100644 --- a/app/Livewire/PrivateKey/Create.php +++ b/app/Livewire/PrivateKey/Create.php @@ -67,9 +67,9 @@ class Create extends Component 'team_id' => currentTeam()->id ]); if ($this->from === 'server') { - return redirect()->route('server.create'); + return $this->redirectRoute('server.create', navigate: true); } - return redirect()->route('security.private-key.show', ['private_key_uuid' => $private_key->uuid]); + return $this->redirectRoute('security.private-key.show', ['private_key_uuid' => $private_key->uuid], navigate: true); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Project/AddEmpty.php b/app/Livewire/Project/AddEmpty.php index 5b358a61d..edaca35f0 100644 --- a/app/Livewire/Project/AddEmpty.php +++ b/app/Livewire/Project/AddEmpty.php @@ -27,7 +27,7 @@ class AddEmpty extends Component 'description' => $this->description, 'team_id' => currentTeam()->id, ]); - return redirect()->route('project.show', $project->uuid); + return $this->redirectRoute('project.show', $project->uuid, navigate: true); } catch (\Throwable $e) { return handleError($e, $this); } finally { diff --git a/app/Livewire/Project/AddEnvironment.php b/app/Livewire/Project/AddEnvironment.php index be80c21e1..5696bc53c 100644 --- a/app/Livewire/Project/AddEnvironment.php +++ b/app/Livewire/Project/AddEnvironment.php @@ -27,10 +27,10 @@ class AddEnvironment extends Component 'project_id' => $this->project->id, ]); - return redirect()->route('project.resources', [ + return $this->redirectRoute('project.resources', [ 'project_uuid' => $this->project->uuid, 'environment_name' => $environment->name, - ]); + ], navigate: true); } catch (\Throwable $e) { handleError($e, $this); } finally { diff --git a/app/Livewire/Project/Application/Configuration.php b/app/Livewire/Project/Application/Configuration.php index 691cbb7c4..0022d1693 100644 --- a/app/Livewire/Project/Application/Configuration.php +++ b/app/Livewire/Project/Application/Configuration.php @@ -15,15 +15,15 @@ class Configuration extends Component { $project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); if (!$project) { - return redirect()->route('dashboard'); + return $this->redirectRoute('dashboard', navigate: true); } $environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']); if (!$environment) { - return redirect()->route('dashboard'); + return $this->redirectRoute('dashboard', navigate: true); } $application = $environment->applications->where('uuid', request()->route('application_uuid'))->first(); if (!$application) { - return redirect()->route('dashboard'); + return $this->redirectRoute('dashboard', navigate: true); } $this->application = $application; $mainServer = $this->application->destination->server; diff --git a/app/Livewire/Project/Application/Heading.php b/app/Livewire/Project/Application/Heading.php index 0e4c4e458..0762c5105 100644 --- a/app/Livewire/Project/Application/Heading.php +++ b/app/Livewire/Project/Application/Heading.php @@ -52,12 +52,12 @@ class Heading extends Component force_rebuild: false, is_new_deployment: true, ); - return redirect()->route('project.application.deployment', [ + return $this->redirectRoute('project.application.deployment', [ 'project_uuid' => $this->parameters['project_uuid'], 'application_uuid' => $this->parameters['application_uuid'], 'deployment_uuid' => $this->deploymentUuid, 'environment_name' => $this->parameters['environment_name'], - ]); + ], navigate: true); } public function deploy(bool $force_rebuild = false) { @@ -101,12 +101,12 @@ class Heading extends Component restart_only: true, is_new_deployment: true, ); - return redirect()->route('project.application.deployment', [ + return $this->redirectRoute('project.application.deployment', [ 'project_uuid' => $this->parameters['project_uuid'], 'application_uuid' => $this->parameters['application_uuid'], 'deployment_uuid' => $this->deploymentUuid, 'environment_name' => $this->parameters['environment_name'], - ]); + ], navigate: true); } public function restart() { @@ -116,11 +116,11 @@ class Heading extends Component deployment_uuid: $this->deploymentUuid, restart_only: true, ); - return redirect()->route('project.application.deployment', [ + return $this->redirectRoute('project.application.deployment', [ 'project_uuid' => $this->parameters['project_uuid'], 'application_uuid' => $this->parameters['application_uuid'], 'deployment_uuid' => $this->deploymentUuid, 'environment_name' => $this->parameters['environment_name'], - ]); + ], navigate: true); } } diff --git a/app/Livewire/Project/Application/Previews.php b/app/Livewire/Project/Application/Previews.php index 6605123fa..0fc1acf5e 100644 --- a/app/Livewire/Project/Application/Previews.php +++ b/app/Livewire/Project/Application/Previews.php @@ -52,12 +52,12 @@ class Previews extends Component force_rebuild: true, pull_request_id: $pull_request_id, ); - return redirect()->route('project.application.deployment', [ + return $this->redirectRoute('project.application.deployment', [ 'project_uuid' => $this->parameters['project_uuid'], 'application_uuid' => $this->parameters['application_uuid'], 'deployment_uuid' => $this->deployment_uuid, 'environment_name' => $this->parameters['environment_name'], - ]); + ], navigate: true); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Project/Application/Rollback.php b/app/Livewire/Project/Application/Rollback.php index 9941bc281..4c3630877 100644 --- a/app/Livewire/Project/Application/Rollback.php +++ b/app/Livewire/Project/Application/Rollback.php @@ -29,13 +29,12 @@ class Rollback extends Component commit: $commit, force_rebuild: false, ); - - return redirect()->route('project.application.deployment', [ + return $this->redirectRoute('project.application.deployment', [ 'project_uuid' => $this->parameters['project_uuid'], 'application_uuid' => $this->parameters['application_uuid'], 'deployment_uuid' => $deployment_uuid, 'environment_name' => $this->parameters['environment_name'], - ]); + ], navigate: true); } public function loadImages($showToast = false) diff --git a/app/Livewire/Project/CloneProject.php b/app/Livewire/Project/CloneProject.php index 275c0999c..3a6a1db6f 100644 --- a/app/Livewire/Project/CloneProject.php +++ b/app/Livewire/Project/CloneProject.php @@ -148,10 +148,10 @@ class CloneProject extends Component } $newService->parse(); } - return redirect()->route('project.resources', [ + return $this->redirectRoute('project.resources', [ 'project_uuid' => $newProject->uuid, 'environment_name' => $newEnvironment->name, - ]); + ], navigate: true); } catch (\Exception $e) { return handleError($e, $this); } diff --git a/app/Livewire/Project/Database/BackupEdit.php b/app/Livewire/Project/Database/BackupEdit.php index 99892448d..3a9a83dc4 100644 --- a/app/Livewire/Project/Database/BackupEdit.php +++ b/app/Livewire/Project/Database/BackupEdit.php @@ -50,9 +50,9 @@ class BackupEdit extends Component $url = $url->withoutQueryParameter('selectedBackupId'); $url = $url->withFragment('backups'); $url = $url->getPath() . "#{$url->getFragment()}"; - return redirect()->to($url); + return $this->redirect($url,navigate: true); } else { - redirect()->route('project.database.backups.all', $this->parameters); + return $this->redirectRoute('project.database.backups.all', $this->parameters); } } diff --git a/app/Livewire/Project/DeleteEnvironment.php b/app/Livewire/Project/DeleteEnvironment.php index 0f2b59c93..3b64df0c0 100644 --- a/app/Livewire/Project/DeleteEnvironment.php +++ b/app/Livewire/Project/DeleteEnvironment.php @@ -23,7 +23,7 @@ class DeleteEnvironment extends Component $environment = Environment::findOrFail($this->environment_id); if ($environment->isEmpty()) { $environment->delete(); - return redirect()->route('project.show', ['project_uuid' => $this->parameters['project_uuid']]); + return $this->redirectRoute('project.show', ['project_uuid' => $this->parameters['project_uuid']], navigate: true); } return $this->dispatch('error', 'Environment has defined resources, please delete them first.'); } diff --git a/app/Livewire/Project/DeleteProject.php b/app/Livewire/Project/DeleteProject.php index 23ca8eb79..2c51509e1 100644 --- a/app/Livewire/Project/DeleteProject.php +++ b/app/Livewire/Project/DeleteProject.php @@ -25,6 +25,6 @@ class DeleteProject extends Component return $this->dispatch('error', 'Project has resources defined, please delete them first.'); } $project->delete(); - return redirect()->route('projects'); + return $this->redirectRoute('projects', navigate: true); } } diff --git a/app/Livewire/Project/New/DockerCompose.php b/app/Livewire/Project/New/DockerCompose.php index 088a53c48..70699a854 100644 --- a/app/Livewire/Project/New/DockerCompose.php +++ b/app/Livewire/Project/New/DockerCompose.php @@ -69,11 +69,12 @@ class DockerCompose extends Component $service->parse(isNew: true); - return redirect()->route('project.service.configuration', [ + return $this->redirectRoute('project.service.configuration', [ 'service_uuid' => $service->uuid, 'environment_name' => $environment->name, 'project_uuid' => $project->uuid, ]); + } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Project/New/DockerImage.php b/app/Livewire/Project/New/DockerImage.php index d54f35521..5479bca51 100644 --- a/app/Livewire/Project/New/DockerImage.php +++ b/app/Livewire/Project/New/DockerImage.php @@ -64,12 +64,11 @@ class DockerImage extends Component 'name' => 'docker-image-' . $application->uuid, 'fqdn' => $fqdn ]); - - redirect()->route('project.application.configuration', [ + return $this->redirectRoute('project.application.configuration', [ 'application_uuid' => $application->uuid, 'environment_name' => $environment->name, 'project_uuid' => $project->uuid, - ]); + ], navigate: true); } public function render() { diff --git a/app/Livewire/Project/New/EmptyProject.php b/app/Livewire/Project/New/EmptyProject.php index 52e9ce7dc..559f774b5 100644 --- a/app/Livewire/Project/New/EmptyProject.php +++ b/app/Livewire/Project/New/EmptyProject.php @@ -13,6 +13,6 @@ class EmptyProject extends Component 'name' => generate_random_name(), 'team_id' => currentTeam()->id, ]); - return redirect()->route('project.show', ['project_uuid' => $project->uuid, 'environment_name' => 'production']); + return $this->redirectRoute('project.show', ['project_uuid' => $project->uuid, 'environment_name' => 'production'], navigate: true); } } diff --git a/app/Livewire/Project/New/GithubPrivateRepository.php b/app/Livewire/Project/New/GithubPrivateRepository.php index 76461cab4..376f7d646 100644 --- a/app/Livewire/Project/New/GithubPrivateRepository.php +++ b/app/Livewire/Project/New/GithubPrivateRepository.php @@ -151,11 +151,11 @@ class GithubPrivateRepository extends Component $application->name = generate_application_name($this->selected_repository_owner . '/' . $this->selected_repository_repo, $this->selected_branch_name, $application->uuid); $application->save(); - redirect()->route('project.application.configuration', [ + return $this->redirectRoute('project.application.configuration', [ 'application_uuid' => $application->uuid, 'environment_name' => $environment->name, 'project_uuid' => $project->uuid, - ]); + ], navigate: true); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php b/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php index a843d3a52..6d270ef27 100644 --- a/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php +++ b/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php @@ -132,11 +132,11 @@ class GithubPrivateRepositoryDeployKey extends Component $application->name = generate_random_name($application->uuid); $application->save(); - return redirect()->route('project.application.configuration', [ - 'project_uuid' => $project->uuid, - 'environment_name' => $environment->name, + return $this->redirectRoute('project.application.configuration', [ 'application_uuid' => $application->uuid, - ]); + 'environment_name' => $environment->name, + 'project_uuid' => $project->uuid, + ], navigate: true); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Project/New/PublicGitRepository.php b/app/Livewire/Project/New/PublicGitRepository.php index 55b32dc54..f7390ceaa 100644 --- a/app/Livewire/Project/New/PublicGitRepository.php +++ b/app/Livewire/Project/New/PublicGitRepository.php @@ -184,11 +184,11 @@ class PublicGitRepository extends Component $application->fqdn = $fqdn; $application->save(); - return redirect()->route('project.application.configuration', [ - 'project_uuid' => $project->uuid, - 'environment_name' => $environment->name, + return $this->redirectRoute('project.application.configuration', [ 'application_uuid' => $application->uuid, - ]); + 'environment_name' => $environment->name, + 'project_uuid' => $project->uuid, + ], navigate: true); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Project/New/Select.php b/app/Livewire/Project/New/Select.php index da25e9c8c..90fa71914 100644 --- a/app/Livewire/Project/New/Select.php +++ b/app/Livewire/Project/New/Select.php @@ -53,10 +53,10 @@ class Select extends Component public function updatedSelectedEnvironment() { - return redirect()->route('project.resources.new', [ + return $this->redirectRoute('project.resources.new', [ 'project_uuid' => $this->parameters['project_uuid'], 'environment_name' => $this->selectedEnvironment, - ]); + ], navigate: true); } // public function addExistingPostgresql() @@ -133,13 +133,13 @@ class Select extends Component public function setDestination(string $destination_uuid) { $this->destination_uuid = $destination_uuid; - redirect()->route('project.resources.new', [ + return $this->redirectRoute('project.resources.new', [ 'project_uuid' => $this->parameters['project_uuid'], 'environment_name' => $this->parameters['environment_name'], 'type' => $this->type, 'destination' => $this->destination_uuid, 'server_id' => $this->server_id, - ]); + ], navigate: true); } public function loadServers() diff --git a/app/Livewire/Project/New/SimpleDockerfile.php b/app/Livewire/Project/New/SimpleDockerfile.php index b478c77d4..7015af6ed 100644 --- a/app/Livewire/Project/New/SimpleDockerfile.php +++ b/app/Livewire/Project/New/SimpleDockerfile.php @@ -70,10 +70,10 @@ CMD ["nginx", "-g", "daemon off;"] 'fqdn' => $fqdn ]); - redirect()->route('project.application.configuration', [ + return $this->redirectRoute('project.application.configuration', [ 'application_uuid' => $application->uuid, 'environment_name' => $environment->name, 'project_uuid' => $project->uuid, - ]); + ], navigate: true); } } diff --git a/app/Livewire/Project/Service/Application.php b/app/Livewire/Project/Service/Application.php index 3ff711400..1adacf555 100644 --- a/app/Livewire/Project/Service/Application.php +++ b/app/Livewire/Project/Service/Application.php @@ -41,7 +41,7 @@ class Application extends Component try { $this->application->delete(); $this->dispatch('success', 'Application deleted successfully.'); - return redirect()->route('project.service.configuration', $this->parameters); + return $this->redirectRoute('project.service.configuration', $this->parameters, navigate: true); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Project/Shared/Danger.php b/app/Livewire/Project/Shared/Danger.php index 58742feab..8cb55a405 100644 --- a/app/Livewire/Project/Shared/Danger.php +++ b/app/Livewire/Project/Shared/Danger.php @@ -22,10 +22,10 @@ class Danger extends Component { try { DeleteResourceJob::dispatchSync($this->resource); - return redirect()->route('project.resources', [ + return $this->redirectRoute('project.resources', [ 'project_uuid' => $this->parameters['project_uuid'], 'environment_name' => $this->parameters['environment_name'] - ]); + ], navigate: true); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Project/Shared/GetLogs.php b/app/Livewire/Project/Shared/GetLogs.php index 8d66c6f67..6f431b11e 100644 --- a/app/Livewire/Project/Shared/GetLogs.php +++ b/app/Livewire/Project/Shared/GetLogs.php @@ -19,7 +19,7 @@ class GetLogs extends Component { public string $outputs = ''; public string $errors = ''; - public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb $resource; + public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|null $resource = null; public ServiceApplication|ServiceDatabase|null $servicesubtype = null; public Server $server; public ?string $container = null; @@ -29,13 +29,15 @@ class GetLogs extends Component public function mount() { - if ($this->resource->getMorphClass() === 'App\Models\Application') { - $this->showTimeStamps = $this->resource->settings->is_include_timestamps; - } else { - if ($this->servicesubtype) { - $this->showTimeStamps = $this->servicesubtype->is_include_timestamps; + if (!is_null($this->resource)) { + if ($this->resource->getMorphClass() === 'App\Models\Application') { + $this->showTimeStamps = $this->resource->settings->is_include_timestamps; } else { - $this->showTimeStamps = $this->resource->is_include_timestamps; + if ($this->servicesubtype) { + $this->showTimeStamps = $this->servicesubtype->is_include_timestamps; + } else { + $this->showTimeStamps = $this->resource->is_include_timestamps; + } } } } @@ -45,16 +47,18 @@ class GetLogs extends Component } public function instantSave() { - if ($this->resource->getMorphClass() === 'App\Models\Application') { - $this->resource->settings->is_include_timestamps = $this->showTimeStamps; - $this->resource->settings->save(); - } else { - if ($this->servicesubtype) { - $this->servicesubtype->is_include_timestamps = $this->showTimeStamps; - $this->servicesubtype->save(); + if (!is_null($this->resource)) { + if ($this->resource->getMorphClass() === 'App\Models\Application') { + $this->resource->settings->is_include_timestamps = $this->showTimeStamps; + $this->resource->settings->save(); } else { - $this->resource->is_include_timestamps = $this->showTimeStamps; - $this->resource->save(); + if ($this->servicesubtype) { + $this->servicesubtype->is_include_timestamps = $this->showTimeStamps; + $this->servicesubtype->save(); + } else { + $this->resource->is_include_timestamps = $this->showTimeStamps; + $this->resource->save(); + } } } } diff --git a/app/Livewire/Server/Delete.php b/app/Livewire/Server/Delete.php index 73edf5ffe..4931e598c 100644 --- a/app/Livewire/Server/Delete.php +++ b/app/Livewire/Server/Delete.php @@ -19,7 +19,7 @@ class Delete extends Component return; } $this->server->delete(); - return redirect()->route('server.all'); + return $this->redirectRoute('server.all', navigate: true); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Server/Destination/Show.php b/app/Livewire/Server/Destination/Show.php index 059dde4fb..3df263f8b 100644 --- a/app/Livewire/Server/Destination/Show.php +++ b/app/Livewire/Server/Destination/Show.php @@ -13,9 +13,9 @@ class Show extends Component { $this->parameters = get_route_parameters(); try { - $this->server = Server::ownedByCurrentTeam(['name', 'proxy'])->whereUuid(request()->server_uuid)->first(); + $this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first(); if (is_null($this->server)) { - return redirect()->route('server.all'); + return $this->redirectRoute('server.all', navigate: true); } } catch (\Throwable $e) { return handleError($e, $this); diff --git a/app/Livewire/Server/Form.php b/app/Livewire/Server/Form.php index 336027471..480028ede 100644 --- a/app/Livewire/Server/Form.php +++ b/app/Livewire/Server/Form.php @@ -44,7 +44,9 @@ class Form extends Component { $this->wildcard_domain = $this->server->settings->wildcard_domain; $this->cleanup_after_percentage = $this->server->settings->cleanup_after_percentage; - $this->validateServer(); + if (!$this->server->isFunctional()) { + $this->validateServer(); + } } public function serverRefresh($install = true) { diff --git a/app/Livewire/Server/LogDrains.php b/app/Livewire/Server/LogDrains.php index c93f49222..bdaf152d7 100644 --- a/app/Livewire/Server/LogDrains.php +++ b/app/Livewire/Server/LogDrains.php @@ -41,9 +41,9 @@ class LogDrains extends Component { $this->parameters = get_route_parameters(); try { - $server = Server::ownedByCurrentTeam(['name', 'description', 'ip', 'port', 'user', 'proxy'])->whereUuid(request()->server_uuid)->first(); + $server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first(); if (is_null($server)) { - return redirect()->route('server.all'); + return $this->redirectRoute('server.all', navigate: true); } $this->server = $server; } catch (\Throwable $e) { diff --git a/app/Livewire/Server/New/ByIp.php b/app/Livewire/Server/New/ByIp.php index 657d65c88..3470e27f8 100644 --- a/app/Livewire/Server/New/ByIp.php +++ b/app/Livewire/Server/New/ByIp.php @@ -79,7 +79,7 @@ class ByIp extends Component $server->settings->is_swarm_manager = $this->is_swarm_manager; $server->settings->save(); $server->addInitialNetwork(); - return redirect()->route('server.show', $server->uuid); + return $this->redirectRoute('server.show', $server->uuid, navigate: true); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Server/PrivateKey/Show.php b/app/Livewire/Server/PrivateKey/Show.php index 9fa0acb75..97ee66729 100644 --- a/app/Livewire/Server/PrivateKey/Show.php +++ b/app/Livewire/Server/PrivateKey/Show.php @@ -17,7 +17,7 @@ class Show extends Component try { $this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first(); if (is_null($this->server)) { - return redirect()->route('server.all'); + return $this->redirectRoute('server.all', navigate: true); } $this->privateKeys = PrivateKey::ownedByCurrentTeam()->get()->where('is_git_related', false); } catch (\Throwable $e) { diff --git a/app/Livewire/Server/Proxy/Logs.php b/app/Livewire/Server/Proxy/Logs.php index 559de376a..e1ca0ca3f 100644 --- a/app/Livewire/Server/Proxy/Logs.php +++ b/app/Livewire/Server/Proxy/Logs.php @@ -13,9 +13,9 @@ class Logs extends Component { $this->parameters = get_route_parameters(); try { - $this->server = Server::ownedByCurrentTeam(['name', 'proxy'])->whereUuid(request()->server_uuid)->first(); + $this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first(); if (is_null($this->server)) { - return redirect()->route('server.all'); + return $this->redirectRoute('server.all', navigate: true); } } catch (\Throwable $e) { return handleError($e, $this); diff --git a/app/Livewire/Server/Proxy/Show.php b/app/Livewire/Server/Proxy/Show.php index dcfcc1015..4c515b926 100644 --- a/app/Livewire/Server/Proxy/Show.php +++ b/app/Livewire/Server/Proxy/Show.php @@ -18,9 +18,9 @@ class Show extends Component { $this->parameters = get_route_parameters(); try { - $this->server = Server::ownedByCurrentTeam(['name', 'proxy'])->whereUuid(request()->server_uuid)->first(); + $this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first(); if (is_null($this->server)) { - return redirect()->route('server.all'); + return $this->redirectRoute('server.all', navigate: true); } } catch (\Throwable $e) { return handleError($e, $this); diff --git a/app/Livewire/Server/Show.php b/app/Livewire/Server/Show.php index f7e475e11..2c0ec6e82 100644 --- a/app/Livewire/Server/Show.php +++ b/app/Livewire/Server/Show.php @@ -15,9 +15,9 @@ class Show extends Component { $this->parameters = get_route_parameters(); try { - $this->server = Server::ownedByCurrentTeam(['name', 'description', 'ip', 'port', 'user', 'proxy'])->whereUuid(request()->server_uuid)->first(); + $this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first(); if (is_null($this->server)) { - return redirect()->route('server.all'); + return $this->redirectRoute('server.all', navigate: true); } } catch (\Throwable $e) { diff --git a/app/Livewire/Source/Github/Change.php b/app/Livewire/Source/Github/Change.php index 489d54b8a..858562e2a 100644 --- a/app/Livewire/Source/Github/Change.php +++ b/app/Livewire/Source/Github/Change.php @@ -41,7 +41,7 @@ class Change extends Component $github_app_uuid = request()->github_app_uuid; $this->github_app = GithubApp::where('uuid', $github_app_uuid)->first(); if (!$this->github_app) { - return redirect()->route('source.all'); + return $this->redirectRoute('source.all', navigate: true); } $settings = InstanceSettings::get(); $this->github_app->makeVisible('client_secret')->makeVisible('webhook_secret'); @@ -67,7 +67,7 @@ class Change extends Component $type = data_get($parameters, 'type'); $destination = data_get($parameters, 'destination'); session()->forget('from'); - return redirect()->route($back, [ + return $this->redirectRoute($back, [ 'environment_name' => $environment_name, 'project_uuid' => $project_uuid, 'type' => $type, @@ -105,7 +105,7 @@ class Change extends Component { try { $this->github_app->delete(); - redirect()->route('source.all'); + return $this->redirectRoute('source.all', navigate: true); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Source/Github/Create.php b/app/Livewire/Source/Github/Create.php index 5af6616cf..543c7d2ac 100644 --- a/app/Livewire/Source/Github/Create.php +++ b/app/Livewire/Source/Github/Create.php @@ -48,7 +48,7 @@ class Create extends Component if (session('from')) { session(['from' => session('from') + ['source_id' => $github_app->id]]); } - redirect()->route('source.github.show', ['github_app_uuid' => $github_app->uuid]); + return $this->redirectRoute('source.github.show', ['github_app_uuid' => $github_app->uuid], navigate: true); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Subscription/Show.php b/app/Livewire/Subscription/Show.php index cde2f0455..ee12eef6d 100644 --- a/app/Livewire/Subscription/Show.php +++ b/app/Livewire/Subscription/Show.php @@ -11,7 +11,7 @@ class Show extends Component public bool $alreadySubscribed = false; public function mount() { if (!isCloud()) { - return redirect('/'); + return $this->redirect('/', navigate: true); } $this->settings = InstanceSettings::get(); $this->alreadySubscribed = currentTeam()->subscription()->exists(); diff --git a/app/Livewire/Team/Create.php b/app/Livewire/Team/Create.php index 2ca647092..1fb642582 100644 --- a/app/Livewire/Team/Create.php +++ b/app/Livewire/Team/Create.php @@ -30,7 +30,7 @@ class Create extends Component ]); auth()->user()->teams()->attach($team, ['role' => 'admin']); refreshSession(); - return redirect()->route('team.index'); + return $this->redirectRoute('team.index', navigate: true); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Team/Delete.php b/app/Livewire/Team/Delete.php index 097419c4c..14c7a8f82 100644 --- a/app/Livewire/Team/Delete.php +++ b/app/Livewire/Team/Delete.php @@ -24,6 +24,6 @@ class Delete extends Component }); refreshSession(); - return redirect()->route('team.index'); + return $this->redirectRoute('team.index', navigate: true); } } diff --git a/app/Livewire/Team/Storage/Create.php b/app/Livewire/Team/Storage/Create.php index cbbba398f..14c4cda9b 100644 --- a/app/Livewire/Team/Storage/Create.php +++ b/app/Livewire/Team/Storage/Create.php @@ -65,7 +65,7 @@ class Create extends Component $this->storage->team_id = currentTeam()->id; $this->storage->testConnection(); $this->storage->save(); - return redirect()->route('team.storages.show', $this->storage->uuid); + return $this->redirectRoute('team.storages.show', $this->storage->uuid, navigate: true); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Team/Storage/Form.php b/app/Livewire/Team/Storage/Form.php index 23b0fe34c..4c95c1e26 100644 --- a/app/Livewire/Team/Storage/Form.php +++ b/app/Livewire/Team/Storage/Form.php @@ -43,7 +43,7 @@ class Form extends Component { try { $this->storage->delete(); - return redirect()->route('team.storages.all'); + return $this->redirectRoute('team.storages.all', navigate: true); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Waitlist/Index.php b/app/Livewire/Waitlist/Index.php index a3829dec7..5df8ba0b7 100644 --- a/app/Livewire/Waitlist/Index.php +++ b/app/Livewire/Waitlist/Index.php @@ -24,7 +24,7 @@ class Index extends Component public function mount() { if (config('coolify.waitlist') == false) { - return redirect()->route('register'); + return $this->redirectRoute('register', navigate: true); } $this->waitingInLine = Waitlist::whereVerified(true)->count(); $this->users = User::count(); diff --git a/bootstrap/helpers/remoteProcess.php b/bootstrap/helpers/remoteProcess.php index 2fe90415e..56fcdbfec 100644 --- a/bootstrap/helpers/remoteProcess.php +++ b/bootstrap/helpers/remoteProcess.php @@ -61,6 +61,7 @@ function remote_process( // } function savePrivateKeyToFs(Server $server) { + ray(data_get($server, 'privateKey.private_key')); if (data_get($server, 'privateKey.private_key') === null) { throw new \Exception("Server {$server->name} does not have a private key"); } diff --git a/bootstrap/helpers/subscriptions.php b/bootstrap/helpers/subscriptions.php index 6707f8937..c994199f2 100644 --- a/bootstrap/helpers/subscriptions.php +++ b/bootstrap/helpers/subscriptions.php @@ -128,11 +128,12 @@ function allowedPathsForUnsubscribedAccounts() 'logout', 'waitlist', 'force-password-reset', - 'livewire/message/force-password-reset', - 'livewire/message/check-license', - 'livewire/message/switch-team', - 'livewire/message/subscription.pricing-plans', - 'livewire/message/help' + // 'livewire/message/force-password-reset', + // 'livewire/message/check-license', + // 'livewire/message/switch-team', + // 'livewire/message/subscription.pricing-plans', + // 'livewire/message/help', + 'livewire/update' ]; } function allowedPathsForBoardingAccounts() @@ -140,8 +141,9 @@ function allowedPathsForBoardingAccounts() return [ ...allowedPathsForUnsubscribedAccounts(), 'boarding', - 'livewire/message/boarding.index', - 'livewire/message/activity-monitor' + // 'livewire/message/boarding.index', + // 'livewire/message/activity-monitor', + 'livewire/update' ]; } function allowedPathsForInvalidAccounts() { @@ -149,8 +151,9 @@ function allowedPathsForInvalidAccounts() { 'logout', 'verify', 'force-password-reset', - 'livewire/message/force-password-reset', - 'livewire/message/verify-email', - 'livewire/message/help' + // 'livewire/message/force-password-reset', + // 'livewire/message/verify-email', + // 'livewire/message/help', + 'livewire/update' ]; } diff --git a/database/seeders/PrivateKeySeeder.php b/database/seeders/PrivateKeySeeder.php index d0c9a4570..76ddce8e0 100644 --- a/database/seeders/PrivateKeySeeder.php +++ b/database/seeders/PrivateKeySeeder.php @@ -28,6 +28,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== ]); PrivateKey::create([ + "id" => 1, "team_id" => 0, "name" => "development-github-app", "description" => "This is the key for using the development GitHub app", @@ -61,6 +62,7 @@ a1C8EDKapCw5hAhizEFOUQKOygL8Ipn+tmEUkORYdZ8Q8cWFCv9nIw== "is_git_related" => true ]); PrivateKey::create([ + "id" => 2, "team_id" => 0, "name" => "development-gitlab-app", "description" => "This is the key for using the development Gitlab app", diff --git a/resources/views/components/databases/navbar.blade.php b/resources/views/components/databases/navbar.blade.php index ca6c09f8b..bce3026c6 100644 --- a/resources/views/components/databases/navbar.blade.php +++ b/resources/views/components/databases/navbar.blade.php @@ -1,13 +1,13 @@ diff --git a/resources/views/components/security/navbar.blade.php b/resources/views/components/security/navbar.blade.php index 084ed4d82..43eb252b2 100644 --- a/resources/views/components/security/navbar.blade.php +++ b/resources/views/components/security/navbar.blade.php @@ -10,10 +10,10 @@