fix(server): list the active private key first

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2026-10-21 11:28:48 +02:00
co-authored by Claude Opus 5.5
parent ef27d1a94d
commit 64b748008e
2 changed files with 14 additions and 1 deletions
+5 -1
View File
@@ -30,7 +30,10 @@ class Show extends Component
private function loadPrivateKeys(): void
{
$this->privateKeys = PrivateKey::where('team_id', $this->server->team_id)->get()->where('is_git_related', false);
$this->privateKeys = PrivateKey::where('team_id', $this->server->team_id)->get()
->where('is_git_related', false)
->sortBy(fn (PrivateKey $privateKey) => $privateKey->id !== $this->server->private_key_id)
->values();
}
public function setPrivateKey($privateKeyId)
@@ -51,6 +54,7 @@ class Show extends Component
throw new \Exception($error);
}
});
$this->loadPrivateKeys();
$this->dispatch('success', 'Private key updated successfully.');
$this->dispatch('refreshServerShow');
} catch (\Exception $e) {
@@ -135,4 +135,13 @@ describe('after the user switches the session team', function () {
expect($this->server->fresh()->private_key_id)->toBe($this->sameTeamKey->id);
});
test('lists the active key first', function () {
expect($this->component->get('privateKeys')->first()->id)->toBe($this->currentPrivateKey->id);
$keys = $this->component->call('setPrivateKey', $this->sameTeamKey->id)->get('privateKeys');
expect($keys->first()->id)->toBe($this->sameTeamKey->id)
->and($keys->pluck('id'))->toContain($this->currentPrivateKey->id);
});
});