Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions library/Icingadb/Common/Icons.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class Icons

const NOTIFICATION = 'bell';

const NO_NOTIFICATIONS = 'bell-slash';

const NO_ACTIVE_CHECKS = 'eye-slash';
Comment on lines +25 to +27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest using NOTIFICATIONS_DISABLED | ACTIVE_CHECKS_DISABLED, as it fits better and describes the variable more clearly.


const REMOVE = 'trash';

const USER = 'user';
Expand Down
23 changes: 19 additions & 4 deletions library/Icingadb/View/BaseHostAndServiceRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function assembleVisual($item, HtmlDocument $visual, string $layout): voi
}
}

$stateChange->setIcon($item->state->getIcon());
$stateChange->setIcon($this->getStateBallIcon($item));
$stateChange->setHandled(
$item->state->is_problem && ($item->state->is_handled || ! $item->state->is_reachable)
);
Expand All @@ -109,7 +109,7 @@ public function assembleVisual($item, HtmlDocument $visual, string $layout): voi
$ballSize = $layout === 'minimal' ? StateBall::SIZE_BIG : StateBall::SIZE_LARGE;

$stateBall = new StateBall($item->state->getStateText(), $ballSize);
$stateBall->add($item->state->getIcon());
$stateBall->add($this->getStateBallIcon($item));
if ($item->state->is_problem && ($item->state->is_handled || ! $item->state->is_reachable)) {
$stateBall->getAttributes()->add('class', 'handled');
}
Expand Down Expand Up @@ -274,13 +274,13 @@ public function assembleFooter($item, HtmlDocument $footer, string $layout): voi

if (! $item->notifications_enabled) {
$statusIcons->addHtml(
new Icon('bell-slash', ['title' => $this->translate('Notifications disabled')])
new Icon(Icons::NO_NOTIFICATIONS, ['title' => $this->translate('Notifications disabled')])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent with other icons in the footer and improve accessibility, please add Host/service '%s' has notifications disabled.

);
}

if (! $item->active_checks_enabled) {
$statusIcons->addHtml(
new Icon('eye-slash', ['title' => $this->translate('Active checks disabled')])
new Icon(Icons::NO_ACTIVE_CHECKS, ['title' => $this->translate('Active checks disabled')])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent with other icons in the footer and improve accessibility, please add Host/service '%s' has active checks disabled.

);
}

Expand Down Expand Up @@ -336,4 +336,19 @@ public function assemble($item, string $name, HtmlDocument $element, string $lay

return false;
}

protected function getStateBallIcon($item): ?Icon
{
$icon = $item->state->getIcon();

if ($icon === null) {
if (! $item->notifications_enabled) {
$icon = new Icon(Icons::NO_NOTIFICATIONS, ['title' => $this->translate('Notifications disabled')]);
} elseif (! $item->active_checks_enabled) {
$icon = new Icon(Icons::NO_ACTIVE_CHECKS, ['title' => $this->translate('Active checks disabled')]);
}
}
Comment on lines +344 to +350
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These icons are still missing in the specific column view list (e.g., URL: icingadb/hosts?columns=name). These should be added to the State::getIcon() method to cover all use cases.


return $icon;
}
}
Loading