From e274d394703e6cac69e5b9f09ab1381957626e37 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 21 Mar 2024 17:19:57 +0100 Subject: [PATCH] ui: Do not show okay states as handled if the object is unreachable fixes #993 --- library/Icingadb/Widget/ItemList/HostDetailHeader.php | 4 +++- .../Icingadb/Widget/ItemList/ServiceDetailHeader.php | 4 +++- library/Icingadb/Widget/ItemList/StateListItem.php | 2 +- library/Icingadb/Widget/ItemTable/StateRowItem.php | 2 +- phpstan-baseline-standard.neon | 10 ++++++++++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/library/Icingadb/Widget/ItemList/HostDetailHeader.php b/library/Icingadb/Widget/ItemList/HostDetailHeader.php index 97176dac9..b7afb2327 100644 --- a/library/Icingadb/Widget/ItemList/HostDetailHeader.php +++ b/library/Icingadb/Widget/ItemList/HostDetailHeader.php @@ -50,7 +50,9 @@ protected function assembleVisual(BaseHtmlElement $visual): void } $stateChange->setIcon($this->state->getIcon()); - $stateChange->setHandled($this->state->is_handled || ! $this->state->is_reachable); + $stateChange->setHandled( + $this->state->is_problem && ($this->state->is_handled || ! $this->state->is_reachable) + ); $visual->addHtml($stateChange); } diff --git a/library/Icingadb/Widget/ItemList/ServiceDetailHeader.php b/library/Icingadb/Widget/ItemList/ServiceDetailHeader.php index 2f0dbbd8c..8c5094d73 100644 --- a/library/Icingadb/Widget/ItemList/ServiceDetailHeader.php +++ b/library/Icingadb/Widget/ItemList/ServiceDetailHeader.php @@ -50,7 +50,9 @@ protected function assembleVisual(BaseHtmlElement $visual): void } $stateChange->setIcon($this->state->getIcon()); - $stateChange->setHandled($this->state->is_handled || ! $this->state->is_reachable); + $stateChange->setHandled( + $this->state->is_problem && ($this->state->is_handled || ! $this->state->is_reachable) + ); $visual->addHtml($stateChange); } diff --git a/library/Icingadb/Widget/ItemList/StateListItem.php b/library/Icingadb/Widget/ItemList/StateListItem.php index d0b336341..cd8ff163e 100644 --- a/library/Icingadb/Widget/ItemList/StateListItem.php +++ b/library/Icingadb/Widget/ItemList/StateListItem.php @@ -99,7 +99,7 @@ protected function assembleVisual(BaseHtmlElement $visual): void { $stateBall = new StateBall($this->state->getStateText(), $this->getStateBallSize()); $stateBall->add($this->state->getIcon()); - if ($this->state->is_handled || ! $this->state->is_reachable) { + if ($this->state->is_problem && ($this->state->is_handled || ! $this->state->is_reachable)) { $stateBall->getAttributes()->add('class', 'handled'); } diff --git a/library/Icingadb/Widget/ItemTable/StateRowItem.php b/library/Icingadb/Widget/ItemTable/StateRowItem.php index f62286b74..7ca93921c 100644 --- a/library/Icingadb/Widget/ItemTable/StateRowItem.php +++ b/library/Icingadb/Widget/ItemTable/StateRowItem.php @@ -33,7 +33,7 @@ protected function assembleVisual(BaseHtmlElement $visual) $stateBall = new StateBall($this->item->state->getStateText(), StateBall::SIZE_LARGE); $stateBall->add($this->item->state->getIcon()); - if ($this->item->state->is_handled) { + if ($this->item->state->is_problem && ($this->item->state->is_handled || ! $this->item->state->is_reachable)) { $stateBall->getAttributes()->add('class', 'handled'); } diff --git a/phpstan-baseline-standard.neon b/phpstan-baseline-standard.neon index a2b761a0d..644347155 100644 --- a/phpstan-baseline-standard.neon +++ b/phpstan-baseline-standard.neon @@ -7635,6 +7635,16 @@ parameters: count: 1 path: library/Icingadb/Widget/ItemTable/StateRowItem.php + - + message: "#^Cannot access property \\$is_problem on mixed\\.$#" + count: 1 + path: library/Icingadb/Widget/ItemTable/StateRowItem.php + + - + message: "#^Cannot access property \\$is_reachable on mixed\\.$#" + count: 1 + path: library/Icingadb/Widget/ItemTable/StateRowItem.php + - message: "#^Cannot access property \\$last_state_change on mixed\\.$#" count: 1