refactor(redirect): replace redirect calls with redirectRoute helper for consistency

This commit is contained in:
Andras Bacsai
2025-12-26 13:29:53 +01:00
parent 5d98847e49
commit ef1abe17b8
20 changed files with 25 additions and 25 deletions

View File

@@ -95,7 +95,7 @@ class Docker extends Component
]); ]);
} }
} }
$this->redirect(route('destination.show', $docker->uuid)); redirectRoute($this, 'destination.show', [$docker->uuid]);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@@ -1314,10 +1314,10 @@ class GlobalSearch extends Component
'server_id' => $this->selectedServerId, 'server_id' => $this->selectedServerId,
]; ];
$this->redirect(route('project.resource.create', [ redirectRoute($this, 'project.resource.create', [
'project_uuid' => $this->selectedProjectUuid, 'project_uuid' => $this->selectedProjectUuid,
'environment_uuid' => $this->selectedEnvironmentUuid, 'environment_uuid' => $this->selectedEnvironmentUuid,
] + $queryParams)); ] + $queryParams);
} }
} }

View File

@@ -37,7 +37,7 @@ class NavbarDeleteTeam extends Component
refreshSession(); refreshSession();
return redirect()->route('team.index'); return redirectRoute($this, 'team.index');
} }
public function render() public function render()

View File

@@ -66,7 +66,7 @@ class Rollback extends Component
return; return;
} }
return redirect()->route('project.application.deployment.show', [ return redirectRoute($this, 'project.application.deployment.show', [
'project_uuid' => $this->parameters['project_uuid'], 'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'], 'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $deployment_uuid, 'deployment_uuid' => $deployment_uuid,

View File

@@ -39,7 +39,7 @@ class DeleteEnvironment extends Component
if ($environment->isEmpty()) { if ($environment->isEmpty()) {
$environment->delete(); $environment->delete();
return redirect()->route('project.show', parameters: ['project_uuid' => $this->parameters['project_uuid']]); return redirectRoute($this, 'project.show', ['project_uuid' => $this->parameters['project_uuid']]);
} }
return $this->dispatch('error', "<strong>Environment {$environment->name}</strong> has defined resources, please delete them first."); return $this->dispatch('error', "<strong>Environment {$environment->name}</strong> has defined resources, please delete them first.");

View File

@@ -35,7 +35,7 @@ class DeleteProject extends Component
if ($project->isEmpty()) { if ($project->isEmpty()) {
$project->delete(); $project->delete();
return redirect()->route('project.index'); return redirectRoute($this, 'project.index');
} }
return $this->dispatch('error', "<strong>Project {$project->name}</strong> has resources defined, please delete them first."); return $this->dispatch('error', "<strong>Project {$project->name}</strong> has resources defined, please delete them first.");

View File

@@ -63,7 +63,7 @@ class EnvironmentEdit extends Component
{ {
try { try {
$this->syncData(true); $this->syncData(true);
$this->redirectRoute('project.environment.edit', [ redirectRoute($this, 'project.environment.edit', [
'environment_uuid' => $this->environment->uuid, 'environment_uuid' => $this->environment->uuid,
'project_uuid' => $this->project->uuid, 'project_uuid' => $this->project->uuid,
]); ]);

View File

@@ -154,7 +154,7 @@ class DockerImage extends Component
'fqdn' => $fqdn, 'fqdn' => $fqdn,
]); ]);
return redirect()->route('project.application.configuration', [ return redirectRoute($this, 'project.application.configuration', [
'application_uuid' => $application->uuid, 'application_uuid' => $application->uuid,
'environment_uuid' => $environment->uuid, 'environment_uuid' => $environment->uuid,
'project_uuid' => $project->uuid, 'project_uuid' => $project->uuid,

View File

@@ -16,6 +16,6 @@ class EmptyProject extends Component
'uuid' => (string) new Cuid2, 'uuid' => (string) new Cuid2,
]); ]);
return redirect()->route('project.show', ['project_uuid' => $project->uuid, 'environment_uuid' => $project->environments->first()->uuid]); return redirectRoute($this, 'project.show', ['project_uuid' => $project->uuid, 'environment_uuid' => $project->environments->first()->uuid]);
} }
} }

View File

@@ -100,7 +100,7 @@ class Database extends Component
$this->database->delete(); $this->database->delete();
$this->dispatch('success', 'Database deleted.'); $this->dispatch('success', 'Database deleted.');
return redirect()->route('project.service.configuration', $this->parameters); return redirectRoute($this, 'project.service.configuration', $this->parameters);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }
@@ -164,7 +164,7 @@ class Database extends Component
$serviceDatabase->delete(); $serviceDatabase->delete();
}); });
return redirect()->route('project.service.configuration', $redirectParams); return redirectRoute($this, 'project.service.configuration', $redirectParams);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@@ -97,7 +97,7 @@ class Destination extends Component
return; return;
} }
return redirect()->route('project.application.deployment.show', [ return redirectRoute($this, 'project.application.deployment.show', [
'project_uuid' => data_get($this->resource, 'environment.project.uuid'), 'project_uuid' => data_get($this->resource, 'environment.project.uuid'),
'application_uuid' => data_get($this->resource, 'uuid'), 'application_uuid' => data_get($this->resource, 'uuid'),
'deployment_uuid' => $deployment_uuid, 'deployment_uuid' => $deployment_uuid,

View File

@@ -48,7 +48,7 @@ class Show extends Component
'uuid' => (string) new Cuid2, 'uuid' => (string) new Cuid2,
]); ]);
return redirect()->route('project.resource.index', [ return redirectRoute($this, 'project.resource.index', [
'project_uuid' => $this->project->uuid, 'project_uuid' => $this->project->uuid,
'environment_uuid' => $environment->uuid, 'environment_uuid' => $environment->uuid,
]); ]);
@@ -59,7 +59,7 @@ class Show extends Component
public function navigateToEnvironment($projectUuid, $environmentUuid) public function navigateToEnvironment($projectUuid, $environmentUuid)
{ {
return redirect()->route('project.resource.index', [ return redirectRoute($this, 'project.resource.index', [
'project_uuid' => $projectUuid, 'project_uuid' => $projectUuid,
'environment_uuid' => $environmentUuid, 'environment_uuid' => $environmentUuid,
]); ]);

View File

@@ -114,7 +114,7 @@ class Create extends Component
private function redirectAfterCreation(PrivateKey $privateKey) private function redirectAfterCreation(PrivateKey $privateKey)
{ {
return $this->from === 'server' return $this->from === 'server'
? redirect()->route('dashboard') ? redirectRoute($this, 'dashboard')
: redirect()->route('security.private-key.show', ['private_key_uuid' => $privateKey->uuid]); : redirectRoute($this, 'security.private-key.show', ['private_key_uuid' => $privateKey->uuid]);
} }
} }

View File

@@ -107,7 +107,7 @@ class Show extends Component
$this->private_key->safeDelete(); $this->private_key->safeDelete();
currentTeam()->privateKeys = PrivateKey::where('team_id', currentTeam()->id)->get(); currentTeam()->privateKeys = PrivateKey::where('team_id', currentTeam()->id)->get();
return redirect()->route('security.private-key.index'); return redirectRoute($this, 'security.private-key.index');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->dispatch('error', $e->getMessage()); $this->dispatch('error', $e->getMessage());
} catch (\Throwable $e) { } catch (\Throwable $e) {

View File

@@ -46,7 +46,7 @@ class Delete extends Component
$this->server->team_id $this->server->team_id
); );
return redirect()->route('server.index'); return redirectRoute($this, 'server.index');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@@ -567,10 +567,10 @@ class ByHetzner extends Component
]); ]);
refreshSession(); refreshSession();
return $this->redirect(route('server.show', $server->uuid)); return redirectRoute($this, 'server.show', [$server->uuid]);
} }
return redirect()->route('server.show', $server->uuid); return redirectRoute($this, 'server.show', [$server->uuid]);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@@ -128,7 +128,7 @@ class ByIp extends Component
$server->settings->is_build_server = $this->is_build_server; $server->settings->is_build_server = $this->is_build_server;
$server->settings->save(); $server->settings->save();
return redirect()->route('server.show', $server->uuid); return redirectRoute($this, 'server.show', [$server->uuid]);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@@ -58,7 +58,7 @@ class Create extends Component
session(['from' => session('from') + ['source_id' => $github_app->id]]); session(['from' => session('from') + ['source_id' => $github_app->id]]);
} }
return redirect()->route('source.github.show', ['github_app_uuid' => $github_app->uuid]); return redirectRoute($this, 'source.github.show', ['github_app_uuid' => $github_app->uuid]);
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@@ -116,7 +116,7 @@ class Create extends Component
$this->storage->testConnection(); $this->storage->testConnection();
$this->storage->save(); $this->storage->save();
return redirect()->route('storage.show', $this->storage->uuid); return redirectRoute($this, 'storage.show', [$this->storage->uuid]);
} catch (\Throwable $e) { } catch (\Throwable $e) {
$this->dispatch('error', 'Failed to create storage.', $e->getMessage()); $this->dispatch('error', 'Failed to create storage.', $e->getMessage());
// return handleError($e, $this); // return handleError($e, $this);

View File

@@ -37,7 +37,7 @@ class Create extends Component
auth()->user()->teams()->attach($team, ['role' => 'admin']); auth()->user()->teams()->attach($team, ['role' => 'admin']);
refreshSession($team); refreshSession($team);
return redirect()->route('team.index'); return redirectRoute($this, 'team.index');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }