Skip to content

Commit

Permalink
ui: Change visualization of redundancy group states
Browse files Browse the repository at this point in the history
They can now be unreachable, thus get the same icon as others.
The state then isn't about reachability anymore, so it's just
critical or ok.
  • Loading branch information
nilmerg committed Nov 28, 2024
1 parent e35544c commit 1532fe5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
24 changes: 22 additions & 2 deletions library/Icingadb/Model/RedundancyGroupState.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
namespace Icinga\Module\Icingadb\Model;

use DateTime;
use Icinga\Module\Icingadb\Common\Icons;
use ipl\Orm\Behavior\Binary;
use ipl\Orm\Behavior\BoolCast;
use ipl\Orm\Behavior\MillisecondTimestamp;
use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Query;
use ipl\Orm\Relations;
use ipl\Web\Widget\Icon;

/**
* Redundancy group state model.
Expand Down Expand Up @@ -66,9 +68,27 @@ public function createRelations(Relations $relations): void
$relations->belongsTo('redundancy_group', RedundancyGroup::class);
}

/**
* Get the state text for the redundancy group state
*
* Do not use this method to label the state of a redundancy group.
*
* @return string
*/
public function getStateText(): string
{
// The method should only be called to fake state balls and not to show the group's state
return $this->failed ? 'unreachable' : 'reachable';
return $this->failed ? 'critical' : 'ok';
}

/**
* Get the state icon
*
* @return ?Icon
*/
public function getIcon(): ?Icon
{
if (! $this->is_reachable) {
return new Icon(Icons::UNREACHABLE);
}
}
}
5 changes: 4 additions & 1 deletion library/Icingadb/Widget/Detail/RedundancyGroupHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public function __construct(RedundancyGroup $object, RedundancyGroupSummary $sum

protected function assembleVisual(BaseHtmlElement $visual): void
{
$visual->addHtml(new StateBall($this->object->state->getStateText(), $this->getStateBallSize()));
$stateBall = new StateBall($this->object->state->getStateText(), $this->getStateBallSize());
$stateBall->add($this->object->state->getIcon());

$visual->addHtml($stateBall);
}

protected function assembleTitle(BaseHtmlElement $title): void
Expand Down
5 changes: 4 additions & 1 deletion library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ protected function createSubject(): Link

protected function assembleVisual(BaseHtmlElement $visual): void
{
$visual->addHtml(new StateBall($this->state->getStateText(), $this->getStateBallSize()));
$stateBall = new StateBall($this->state->getStateText(), $this->getStateBallSize());
$stateBall->add($this->state->getIcon());

$visual->addHtml($stateBall);
}

protected function assembleCaption(BaseHtmlElement $caption): void
Expand Down
10 changes: 0 additions & 10 deletions public/css/common.less
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,3 @@ form[name="form_confirm_removal"] {
padding: 0 0.25em;
.rounded-corners();
}

.state-ball {
&.state-unreachable {
background-color: @color-critical;
}

&.state-reachable {
background-color: @color-ok;
}
}

0 comments on commit 1532fe5

Please sign in to comment.