Skip to content

Commit 5bd7b85

Browse files
committed
fix(widgets): only use HighlightDelta if a parent exists
IcingaStateReasonRow can only use the HighlightDelta widget to render if a parent exists. If there is no parent, it should just render the name normally.
1 parent 78e2086 commit 5bd7b85

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

library/Kubernetes/Web/Widget/IcingaStateReason/IcingaStateReasonRow.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ public function __construct(
3030

3131
public function assemble(): void
3232
{
33+
$isValidDelta = !empty($this->parentName) && str_contains($this->name, $this->parentName);
34+
$nameElement = $isValidDelta
35+
? new HighlightDelta($this->name, $this->parentName, new Attributes(['class' => 'tooltip-holder', 'title' => $this->tooltip]))
36+
: new HtmlElement('span', new Attributes(['class' => 'tooltip-holder', 'title' => $this->tooltip]), new Text($this->name));
37+
3338
$this->addHtml(
3439
new HtmlElement(
3540
'span',
@@ -40,11 +45,7 @@ public function assemble(): void
4045
new HtmlElement(
4146
'span',
4247
new Attributes(['class' => 'reason']),
43-
new HighlightDelta(
44-
$this->name,
45-
$this->parentName ?? '',
46-
new Attributes(['class' => 'tooltip-holder', 'title' => $this->tooltip])
47-
),
48+
$nameElement,
4849
new Text(' ' . $this->reason)
4950
)
5051
);

0 commit comments

Comments
 (0)