-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIcingaStateReasonRow.php
More file actions
53 lines (45 loc) · 1.68 KB
/
IcingaStateReasonRow.php
File metadata and controls
53 lines (45 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/* Icinga for Kubernetes Web | (c) 2025 Icinga GmbH | AGPLv3 */
namespace Icinga\Module\Kubernetes\Web\Widget\IcingaStateReason;
use Icinga\Module\Kubernetes\Common\Factory;
use Icinga\Module\Kubernetes\Web\Widget\HighlightDelta;
use ipl\Html\Attributes;
use ipl\Html\BaseHtmlElement;
use ipl\Html\HtmlElement;
use ipl\Html\Text;
use ipl\Web\Widget\StateBall;
class IcingaStateReasonRow extends BaseHtmlElement
{
protected $tag = 'div';
protected $defaultAttributes = ['class' => 'row'];
public function __construct(
protected string $state,
protected string $kind,
protected string $name,
protected string $reason,
protected string $tooltip,
protected ?string $parentName = null
) {
}
public function assemble(): void
{
$isValidDelta = !empty($this->parentName) && str_contains($this->name, $this->parentName);
$nameElement = $isValidDelta
? new HighlightDelta($this->name, $this->parentName, new Attributes(['class' => 'tooltip-holder', 'title' => $this->tooltip]))
: new HtmlElement('span', new Attributes(['class' => 'tooltip-holder', 'title' => $this->tooltip]), new Text($this->name));
$this->addHtml(
new HtmlElement(
'span',
new Attributes(['class' => 'icon-container']),
new StateBall(strtolower($this->state), StateBall::SIZE_MEDIUM),
Factory::createIcon($this->kind)
),
new HtmlElement(
'span',
new Attributes(['class' => 'reason']),
$nameElement,
new Text(' ' . $this->reason)
)
);
}
}