From 423c9a88e4218081039e505b6a63d171d3544f49 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Mon, 7 Aug 2023 12:15:02 +0200 Subject: [PATCH] Deprecate `StateBadge` class again --- library/Icingadb/Common/StateBadges.php | 2 +- .../Web/Navigation/Renderer/ProblemsBadge.php | 2 +- library/Icingadb/Widget/StateBadge.php | 43 +-------------- public/css/widget/state-badge.less | 52 ------------------- 4 files changed, 4 insertions(+), 95 deletions(-) delete mode 100644 public/css/widget/state-badge.less diff --git a/library/Icingadb/Common/StateBadges.php b/library/Icingadb/Common/StateBadges.php index 799239327..2659d890d 100644 --- a/library/Icingadb/Common/StateBadges.php +++ b/library/Icingadb/Common/StateBadges.php @@ -4,7 +4,6 @@ namespace Icinga\Module\Icingadb\Common; -use Icinga\Module\Icingadb\Widget\StateBadge; use ipl\Html\BaseHtmlElement; use ipl\Html\Html; use ipl\Stdlib\BaseFilter; @@ -12,6 +11,7 @@ use ipl\Web\Filter\QueryString; use ipl\Web\Url; use ipl\Web\Widget\Link; +use ipl\Web\Widget\StateBadge; abstract class StateBadges extends BaseHtmlElement { diff --git a/library/Icingadb/Web/Navigation/Renderer/ProblemsBadge.php b/library/Icingadb/Web/Navigation/Renderer/ProblemsBadge.php index bebc6be80..658fa1c15 100644 --- a/library/Icingadb/Web/Navigation/Renderer/ProblemsBadge.php +++ b/library/Icingadb/Web/Navigation/Renderer/ProblemsBadge.php @@ -7,12 +7,12 @@ use Exception; use Icinga\Application\Logger; use Icinga\Module\Icingadb\Common\Database; -use Icinga\Module\Icingadb\Widget\StateBadge; use Icinga\Web\Navigation\NavigationItem; use Icinga\Web\Navigation\Renderer\NavigationItemRenderer; use ipl\Html\HtmlDocument; use ipl\Html\HtmlString; use ipl\Web\Widget\Link; +use ipl\Web\Widget\StateBadge; abstract class ProblemsBadge extends NavigationItemRenderer { diff --git a/library/Icingadb/Widget/StateBadge.php b/library/Icingadb/Widget/StateBadge.php index 7cc81a913..d9475906c 100644 --- a/library/Icingadb/Widget/StateBadge.php +++ b/library/Icingadb/Widget/StateBadge.php @@ -4,46 +4,7 @@ namespace Icinga\Module\Icingadb\Widget; -use ipl\Html\BaseHtmlElement; - -class StateBadge extends BaseHtmlElement +/** @deprecated Use {@see \ipl\Web\Widget\StateBadge} instead */ +class StateBadge extends \ipl\Web\Widget\StateBadge { - protected $defaultAttributes = ['class' => 'state-badge']; - - /** @var mixed Badge content */ - protected $content; - - /** @var bool Whether the state is handled */ - protected $isHandled; - - /** @var string Textual representation of a state */ - protected $state; - - /** - * Create a new state badge - * - * @param mixed $content Content of the badge - * @param string $state Textual representation of a state - * @param bool $isHandled True if state is handled - */ - public function __construct($content, string $state, bool $isHandled = false) - { - $this->content = $content; - $this->isHandled = $isHandled; - $this->state = $state; - } - - protected function assemble() - { - $this->setTag('span'); - - $class = "state-{$this->state}"; - if ($this->isHandled) { - $class .= ' handled'; - } - - $this->addAttributes(['class' => $class]); - - $this->add($this->content); - } } diff --git a/public/css/widget/state-badge.less b/public/css/widget/state-badge.less deleted file mode 100644 index e4098cceb..000000000 --- a/public/css/widget/state-badge.less +++ /dev/null @@ -1,52 +0,0 @@ -.state-badge { - .rounded-corners(); - color: @text-color-on-icinga-blue; - display: inline-block; - font-size: 1em; - min-width: 2em; - padding: .25em; - text-align: center; - - &.handled { - opacity: .8; - } - - &.state-critical { - background-color: @color-critical; - } - - &.state-down { - background-color: @color-down; - } - - &.state-ok { - background-color: @color-ok; - } - - &.state-pending { - background-color: @color-pending; - } - - &.state-unknown { - background-color: @color-unknown; - } - - &.state-up { - background-color: @color-up; - } - - &.state-warning { - background-color: @color-warning; - } - - &.state-none { - background-color: @state-none; - color: @text-color-light; - } -} - -a .state-badge { - &:not(.disabled):hover { - filter: brightness(80%); - } -}