mirror of
https://github.com/coollabsio/coolify.git
synced 2026-09-24 23:40:16 -05:00
fix(teams): redirect team switches to the dashboard
This commit is contained in:
@@ -19,7 +19,7 @@ class SwitchTeam extends Component
|
||||
$this->switch_to($this->selectedTeamId);
|
||||
}
|
||||
|
||||
public function switch_to($team_id, ?string $currentUrl = null)
|
||||
public function switch_to($team_id)
|
||||
{
|
||||
if (! auth()->user()->teams->contains($team_id)) {
|
||||
return;
|
||||
@@ -30,12 +30,6 @@ class SwitchTeam extends Component
|
||||
}
|
||||
refreshSession($team_to_switch_to);
|
||||
|
||||
$parsedUrl = parse_url($currentUrl ?? '/dashboard');
|
||||
$redirectUrl = data_get($parsedUrl, 'path', '/dashboard');
|
||||
if ($query = data_get($parsedUrl, 'query')) {
|
||||
$redirectUrl .= '?'.$query;
|
||||
}
|
||||
|
||||
return redirect($redirectUrl);
|
||||
return redirect()->route('dashboard');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
Teams
|
||||
</div>
|
||||
@foreach (auth()->user()->teams as $team)
|
||||
<button type="button" wire:click="switch_to({{ $team->id }}, window.location.href)" @click="open = false"
|
||||
<button type="button" wire:click="switch_to({{ $team->id }})" @click="open = false"
|
||||
class="listbox-option {{ $team->id === $currentTeam->id ? 'bg-neutral-100 font-medium dark:bg-white/[0.06]' : '' }}">
|
||||
<span class="min-w-0 flex-1 truncate">{{ $team->name }}</span>
|
||||
</button>
|
||||
@@ -66,7 +66,7 @@
|
||||
Teams
|
||||
</div>
|
||||
@foreach (auth()->user()->teams as $team)
|
||||
<button type="button" wire:click="switch_to({{ $team->id }}, window.location.href)" @click="teamOpen = false"
|
||||
<button type="button" wire:click="switch_to({{ $team->id }})" @click="teamOpen = false"
|
||||
class="listbox-option {{ $team->id === $currentTeam->id ? 'bg-neutral-100 font-medium dark:bg-white/[0.06]' : '' }}">
|
||||
<span class="min-w-0 flex-1 truncate">{{ $team->name }}</span>
|
||||
</button>
|
||||
|
||||
@@ -21,12 +21,13 @@ beforeEach(function () {
|
||||
session(['currentTeam' => $this->currentTeam]);
|
||||
});
|
||||
|
||||
test('switching teams keeps the current page URL', function () {
|
||||
test('switching teams always redirects to the dashboard', function () {
|
||||
$currentUrl = route('security.api-tokens', ['page' => 2]);
|
||||
|
||||
Livewire::test(SwitchTeam::class)
|
||||
->assertDontSee('window.location.href', false)
|
||||
->call('switch_to', $this->otherTeam->id, $currentUrl)
|
||||
->assertRedirect($currentUrl);
|
||||
->assertRedirect(route('dashboard'));
|
||||
|
||||
expect(session('currentTeam')->is($this->otherTeam))->toBeTrue();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user