Skip to content

Commit

Permalink
ItemCountIndicator: Sort by severity
Browse files Browse the repository at this point in the history
  • Loading branch information
lippserd committed Sep 26, 2024
1 parent b2ebca4 commit a6251d3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions library/Kubernetes/Web/ItemCountIndicator.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ public function count(): int

protected function assemble(): void
{
$priorities = [
'ok' => 0,
'pending' => 1,
'unknown' => 2,
'warning' => 3,
'critical' => 4
];


array_multisort(
array_map(fn($item) => $priorities[$item], array_keys($this->indicators)),
SORT_DESC,
array_keys($this->indicators),
$this->indicators
);

if (count($this) === 0) {
$this->addAttributes(['class' => 'empty-state']);
$this->addHtml(new Text($this->translate('None')));
Expand Down

0 comments on commit a6251d3

Please sign in to comment.