Skip to content

Commit 1532fe5

Browse files
committed
ui: Change visualization of redundancy group states
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.
1 parent e35544c commit 1532fe5

File tree

4 files changed

+30
-14
lines changed

4 files changed

+30
-14
lines changed

Diff for: library/Icingadb/Model/RedundancyGroupState.php

+22-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
namespace Icinga\Module\Icingadb\Model;
66

77
use DateTime;
8+
use Icinga\Module\Icingadb\Common\Icons;
89
use ipl\Orm\Behavior\Binary;
910
use ipl\Orm\Behavior\BoolCast;
1011
use ipl\Orm\Behavior\MillisecondTimestamp;
1112
use ipl\Orm\Behaviors;
1213
use ipl\Orm\Model;
1314
use ipl\Orm\Query;
1415
use ipl\Orm\Relations;
16+
use ipl\Web\Widget\Icon;
1517

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

71+
/**
72+
* Get the state text for the redundancy group state
73+
*
74+
* Do not use this method to label the state of a redundancy group.
75+
*
76+
* @return string
77+
*/
6978
public function getStateText(): string
7079
{
71-
// The method should only be called to fake state balls and not to show the group's state
72-
return $this->failed ? 'unreachable' : 'reachable';
80+
return $this->failed ? 'critical' : 'ok';
81+
}
82+
83+
/**
84+
* Get the state icon
85+
*
86+
* @return ?Icon
87+
*/
88+
public function getIcon(): ?Icon
89+
{
90+
if (! $this->is_reachable) {
91+
return new Icon(Icons::UNREACHABLE);
92+
}
7393
}
7494
}

Diff for: library/Icingadb/Widget/Detail/RedundancyGroupHeader.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ public function __construct(RedundancyGroup $object, RedundancyGroupSummary $sum
2929

3030
protected function assembleVisual(BaseHtmlElement $visual): void
3131
{
32-
$visual->addHtml(new StateBall($this->object->state->getStateText(), $this->getStateBallSize()));
32+
$stateBall = new StateBall($this->object->state->getStateText(), $this->getStateBallSize());
33+
$stateBall->add($this->object->state->getIcon());
34+
35+
$visual->addHtml($stateBall);
3336
}
3437

3538
protected function assembleTitle(BaseHtmlElement $title): void

Diff for: library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ protected function createSubject(): Link
6262

6363
protected function assembleVisual(BaseHtmlElement $visual): void
6464
{
65-
$visual->addHtml(new StateBall($this->state->getStateText(), $this->getStateBallSize()));
65+
$stateBall = new StateBall($this->state->getStateText(), $this->getStateBallSize());
66+
$stateBall->add($this->state->getIcon());
67+
68+
$visual->addHtml($stateBall);
6669
}
6770

6871
protected function assembleCaption(BaseHtmlElement $caption): void

Diff for: public/css/common.less

-10
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,3 @@ form[name="form_confirm_removal"] {
412412
padding: 0 0.25em;
413413
.rounded-corners();
414414
}
415-
416-
.state-ball {
417-
&.state-unreachable {
418-
background-color: @color-critical;
419-
}
420-
421-
&.state-reachable {
422-
background-color: @color-ok;
423-
}
424-
}

0 commit comments

Comments
 (0)