Skip to content

Commit c649892

Browse files
sukhwinder33445nilmerg
authored andcommitted
ContactGroupController: Render group name with ObjectHeader class
1 parent a9cb565 commit c649892

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

application/controllers/ContactGroupController.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
use Icinga\Module\Notifications\Model\Contact;
1111
use Icinga\Module\Notifications\Model\Contactgroup;
1212
use Icinga\Module\Notifications\View\ContactRenderer;
13+
use Icinga\Module\Notifications\Widget\Detail\ObjectHeader;
1314
use Icinga\Module\Notifications\Widget\ItemList\ObjectList;
1415
use Icinga\Web\Notification;
15-
use ipl\Html\Attributes;
1616
use ipl\Html\Form;
17-
use ipl\Html\HtmlElement;
1817
use ipl\Html\Text;
1918
use ipl\Stdlib\Filter;
2019
use ipl\Web\Compat\CompatController;
@@ -43,7 +42,7 @@ public function indexAction(): void
4342

4443
$this->controls->addAttributes(['class' => 'contactgroup-detail']);
4544

46-
$this->addControl(new HtmlElement('div', new Attributes(['class' => 'header']), Text::create($group->name)));
45+
$this->addControl(new ObjectHeader($group));
4746

4847
$contacts = Contact::on(Database::get())
4948
->filter(Filter::all(

library/Notifications/View/ContactgroupRenderer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ public function assembleVisual($item, HtmlDocument $visual, string $layout): voi
3232

3333
public function assembleTitle($item, HtmlDocument $title, string $layout): void
3434
{
35-
$title->addHtml(new Link($item->name, Links::contactGroup($item->id), ['class' => 'subject']));
35+
if ($layout === 'header') {
36+
$title->addHtml(new HtmlElement('span', new Attributes(['class' => 'subject']), Text::create($item->name)));
37+
} else {
38+
$title->addHtml(new Link($item->name, Links::contactGroup($item->id), ['class' => 'subject']));
39+
}
3640
}
3741

3842
public function assembleCaption($item, HtmlDocument $caption, string $layout): void

library/Notifications/Widget/Detail/ObjectHeader.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
namespace Icinga\Module\Notifications\Widget\Detail;
66

77
use Icinga\Exception\NotImplementedError;
8+
use Icinga\Module\Notifications\Model\Contactgroup;
89
use Icinga\Module\Notifications\Model\Event;
910
use Icinga\Module\Notifications\Model\Incident;
11+
use Icinga\Module\Notifications\View\ContactgroupRenderer;
1012
use Icinga\Module\Notifications\View\EventRenderer;
1113
use Icinga\Module\Notifications\View\IncidentRenderer;
1214
use ipl\Html\BaseHtmlElement;
@@ -50,6 +52,10 @@ protected function assemble(): void
5052
case $this->object instanceof Incident:
5153
$renderer = new IncidentRenderer();
5254

55+
break;
56+
case $this->object instanceof Contactgroup:
57+
$renderer = new ContactgroupRenderer();
58+
5359
break;
5460
default:
5561
throw new NotImplementedError('Not implemented');

0 commit comments

Comments
 (0)