Skip to content

Commit fb6b06c

Browse files
IncidentDetail: Don't render Object Tags section if no tags are available (#286)
resolves #270
2 parents 590a1c3 + 43d81c6 commit fb6b06c

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

library/Notifications/Widget/Detail/IncidentDetail.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,22 @@ protected function createSource()
9292
];
9393
}
9494

95-
protected function createObjectTag()
95+
protected function createObjectTag(): array
9696
{
97-
$objectTags = (new Table())->addAttributes(['class' => 'object-tags-table']);
98-
97+
$tags = [];
9998
foreach ($this->incident->object->object_extra_tag as $extraTag) {
100-
$objectTags->addHtml(Table::row([$extraTag->tag, $extraTag->value]));
99+
$tags[] = Table::row([$extraTag->tag, $extraTag->value]);
100+
}
101+
102+
if (! $tags) {
103+
return $tags;
101104
}
102105

103106
return [
104-
Html::tag('h2', t('Object Tags')),
105-
$objectTags
107+
new HtmlElement('h2', null, new Text(t('Object Tags'))),
108+
(new Table())
109+
->addHtml(...$tags)
110+
->addAttributes(['class' => 'object-tags-table'])
106111
];
107112
}
108113

0 commit comments

Comments
 (0)