Skip to content

Commit d1fafdf

Browse files
committed
incident-detail-style
1 parent 0be65e1 commit d1fafdf

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

library/Notifications/Widget/Detail/IncidentDetail.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace Icinga\Module\Notifications\Widget\Detail;
77

8+
use Icinga\Application\ClassLoader;
89
use Icinga\Application\Config;
910
use Icinga\Module\Notifications\Common\Auth;
1011
use Icinga\Module\Notifications\Common\SourceHookLocator;
@@ -77,21 +78,24 @@ protected function createContacts(): array
7778
protected function createRelatedObject(): array
7879
{
7980
$object = $this->incident->object;
80-
$objectUrl = SourceHookLocator::forType($object->source->type)
81-
?->createObjectLink($object->id_tags);
81+
$hook = SourceHookLocator::forType($object->source->type);
8282

83-
if (! $objectUrl) {
84-
if (! $object->url) {
83+
$objectUrl = $hook?->createObjectLink($object->id_tags);
84+
if ($objectUrl === null) {
85+
if (! isset($object->url)) {
8586
return [];
8687
}
8788

88-
$objUrl = Url::fromPath($object->url);
89-
9089
$objectUrl = new Link(
9190
$object->name,
92-
$objUrl->isExternal() ? $objUrl->getAbsoluteUrl() : $objUrl->getRelativeUrl(),
93-
['class' => 'subject', 'data-base-target' => '_next']
91+
Url::fromPath($object->url),
92+
['data-base-target' => '_next']
9493
);
94+
} else {
95+
$objectUrl = new HtmlElement('div', Attributes::create([
96+
'data-base-target' => '_next',
97+
'class' => ['icinga-module', 'module-' . ClassLoader::extractModuleName($hook::class)]
98+
]), $objectUrl);
9599
}
96100

97101
return [
@@ -102,7 +106,7 @@ protected function createRelatedObject(): array
102106

103107
protected function createMessage(): array
104108
{
105-
$isEmpty = $this->incident->message === null || $this->incident->message === '';
109+
$isEmpty = empty($this->incident->message);
106110
$message = new HtmlElement(
107111
'div',
108112
Attributes::create([

public/css/detail/incident-detail.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
&:not(.empty) {
4747
background-color: @gray-lighter;
4848
.rounded-corners();
49+
.monospace-font();
4950
}
5051
}
5152
}

0 commit comments

Comments
 (0)