Skip to content

Commit 2653a53

Browse files
committed
Fix active list item handling
1 parent ba627b4 commit 2653a53

13 files changed

+93
-10
lines changed

library/Notifications/Common/Links.php

+30-6
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
*/
1212
abstract class Links
1313
{
14-
public static function event(int $id): Url
14+
public static function event(?int $id = null): Url
1515
{
16+
if ($id === null) {
17+
return Url::fromPath('notifications/event');
18+
}
19+
1620
return Url::fromPath('notifications/event', ['id' => $id]);
1721
}
1822

@@ -26,8 +30,12 @@ public static function incidents(): Url
2630
return Url::fromPath('notifications/incidents');
2731
}
2832

29-
public static function incident(int $id): Url
33+
public static function incident(?int $id = null): Url
3034
{
35+
if ($id === null) {
36+
return Url::fromPath('notifications/incident');
37+
}
38+
3139
return Url::fromPath('notifications/incident', ['id' => $id]);
3240
}
3341

@@ -36,8 +44,12 @@ public static function contacts(): Url
3644
return Url::fromPath('notifications/contacts');
3745
}
3846

39-
public static function contact(int $id): Url
47+
public static function contact(?int $id = null): Url
4048
{
49+
if ($id === null) {
50+
return Url::fromPath('notifications/contact');
51+
}
52+
4153
return Url::fromPath('notifications/contact', ['id' => $id]);
4254
}
4355

@@ -46,8 +58,12 @@ public static function eventRules(): Url
4658
return Url::fromPath('notifications/event-rules');
4759
}
4860

49-
public static function eventRule(int $id): Url
61+
public static function eventRule(?int $id = null): Url
5062
{
63+
if ($id === null) {
64+
return Url::fromPath('notifications/event-rule');
65+
}
66+
5167
return Url::fromPath('notifications/event-rule', ['id' => $id]);
5268
}
5369

@@ -56,8 +72,12 @@ public static function schedules(): Url
5672
return Url::fromPath('notifications/schedules');
5773
}
5874

59-
public static function schedule(int $id): Url
75+
public static function schedule(?int $id = null): Url
6076
{
77+
if ($id === null) {
78+
return Url::fromPath('notifications/schedule');
79+
}
80+
6181
return Url::fromPath('notifications/schedule', ['id' => $id]);
6282
}
6383

@@ -86,8 +106,12 @@ public static function contactGroupsSuggestMember(): Url
86106
return Url::fromPath('notifications/contact-groups/suggest-member');
87107
}
88108

89-
public static function contactGroup(int $id): Url
109+
public static function contactGroup(?int $id = null): Url
90110
{
111+
if ($id === null) {
112+
return Url::fromPath('notifications/contact-group');
113+
}
114+
91115
return Url::fromPath('notifications/contact-group', ['id' => $id]);
92116
}
93117

library/Notifications/Widget/ItemList/ContactGroupList.php

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Icinga\Module\Notifications\Widget\ItemList;
66

7+
use Icinga\Module\Notifications\Common\Links;
78
use ipl\Web\Common\BaseItemList;
89

910
class ContactGroupList extends BaseItemList
@@ -14,4 +15,10 @@ protected function getItemClass(): string
1415
{
1516
return ContactGroupListItem::class;
1617
}
18+
19+
protected function init(): void
20+
{
21+
$this->getAttributes()
22+
->set('data-icinga-detail-url', (string) Links::contactGroup());
23+
}
1724
}

library/Notifications/Widget/ItemList/ContactGroupListItem.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
use ipl\Html\BaseHtmlElement;
1111
use ipl\Html\HtmlElement;
1212
use ipl\Html\Text;
13+
use ipl\Stdlib\Filter;
1314
use ipl\Web\Common\BaseListItem;
15+
use ipl\Web\Filter\QueryString;
1416
use ipl\Web\Widget\Link;
1517

1618
class ContactGroupListItem extends BaseListItem
@@ -23,7 +25,9 @@ class ContactGroupListItem extends BaseListItem
2325

2426
protected function init(): void
2527
{
26-
$this->getAttributes()->set('data-action-item', true);
28+
$this->getAttributes()
29+
->set('data-action-item', true)
30+
->set('data-icinga-detail-filter', QueryString::render(Filter::equal('id', $this->item->id)));
2731
}
2832

2933
protected function assembleVisual(BaseHtmlElement $visual): void

library/Notifications/Widget/ItemList/ContactList.php

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Icinga\Module\Notifications\Widget\ItemList;
66

7+
use Icinga\Module\Notifications\Common\Links;
78
use ipl\Web\Common\BaseItemList;
89

910
class ContactList extends BaseItemList
@@ -14,4 +15,10 @@ protected function getItemClass(): string
1415
{
1516
return ContactListItem::class;
1617
}
18+
19+
protected function init(): void
20+
{
21+
$this->getAttributes()
22+
->set('data-icinga-detail-url', (string) Links::contact());
23+
}
1724
}

library/Notifications/Widget/ItemList/ContactListItem.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
use ipl\Html\BaseHtmlElement;
1010
use ipl\Html\HtmlElement;
1111
use ipl\Html\Text;
12+
use ipl\Stdlib\Filter;
1213
use ipl\Web\Common\BaseListItem;
14+
use ipl\Web\Filter\QueryString;
1315
use ipl\Web\Url;
1416
use ipl\Web\Widget\Icon;
1517
use ipl\Web\Widget\Link;
@@ -28,7 +30,8 @@ class ContactListItem extends BaseListItem
2830
protected function init(): void
2931
{
3032
$this->getAttributes()
31-
->set('data-action-item', true);
33+
->set('data-action-item', true)
34+
->set('data-icinga-detail-filter', QueryString::render(Filter::equal('id', $this->item->id)));
3235
}
3336

3437
protected function assembleVisual(BaseHtmlElement $visual): void

library/Notifications/Widget/ItemList/EventList.php

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Icinga\Module\Notifications\Widget\ItemList;
66

7+
use Icinga\Module\Notifications\Common\Links;
78
use Icinga\Module\Notifications\Common\LoadMore;
89
use Icinga\Module\Notifications\Common\NoSubjectLink;
910
use Icinga\Module\Notifications\Hook\ObjectsRendererHook;
@@ -37,6 +38,9 @@ protected function init(): void
3738
$this->on(self::ON_ASSEMBLED, function () {
3839
ObjectsRendererHook::load();
3940
});
41+
42+
$this->getAttributes()
43+
->set('data-icinga-detail-url', (string) Links::event());
4044
}
4145

4246
protected function getItemClass(): string

library/Notifications/Widget/ItemList/EventListItem.php

+5
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
use ipl\Html\BaseHtmlElement;
1616
use ipl\Html\Html;
1717
use ipl\Html\HtmlElement;
18+
use ipl\Stdlib\Filter;
1819
use ipl\Stdlib\Str;
1920
use ipl\Web\Common\BaseListItem;
21+
use ipl\Web\Filter\QueryString;
2022
use ipl\Web\Widget\Icon;
2123
use ipl\Web\Widget\Link;
2224
use ipl\Web\Widget\TimeAgo;
@@ -47,6 +49,9 @@ protected function init(): void
4749
$this->getAttributes()
4850
->set('data-action-item', true);
4951
}
52+
53+
$this->getAttributes()
54+
->set('data-icinga-detail-filter', QueryString::render(Filter::equal('id', $this->item->id)));
5055
}
5156

5257
protected function assembleVisual(BaseHtmlElement $visual): void

library/Notifications/Widget/ItemList/EventRuleList.php

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Icinga\Module\Notifications\Widget\ItemList;
66

7+
use Icinga\Module\Notifications\Common\Links;
78
use Icinga\Module\Notifications\Common\LoadMore;
89
use ipl\Web\Common\BaseItemList;
910

@@ -17,4 +18,10 @@ protected function getItemClass(): string
1718
{
1819
return EventRuleListItem::class;
1920
}
21+
22+
protected function init(): void
23+
{
24+
$this->getAttributes()
25+
->set('data-icinga-detail-url', (string) Links::eventRule());
26+
}
2027
}

library/Notifications/Widget/ItemList/EventRuleListItem.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
use Icinga\Module\Notifications\Widget\RuleEscalationRecipientBadge;
1111
use ipl\Html\BaseHtmlElement;
1212
use ipl\Html\Html;
13+
use ipl\Stdlib\Filter;
1314
use ipl\Web\Common\BaseListItem;
15+
use ipl\Web\Filter\QueryString;
1416
use ipl\Web\Widget\Icon;
1517
use ipl\Web\Widget\Link;
1618

@@ -28,7 +30,8 @@ class EventRuleListItem extends BaseListItem
2830
protected function init(): void
2931
{
3032
$this->getAttributes()
31-
->set('data-action-item', true);
33+
->set('data-action-item', true)
34+
->set('data-icinga-detail-filter', QueryString::render(Filter::equal('id', $this->item->id)));
3235
}
3336

3437
protected function assembleVisual(BaseHtmlElement $visual): void

library/Notifications/Widget/ItemList/IncidentList.php

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Icinga\Module\Notifications\Widget\ItemList;
66

7+
use Icinga\Module\Notifications\Common\Links;
78
use Icinga\Module\Notifications\Hook\ObjectsRendererHook;
89
use Icinga\Module\Notifications\Model\Incident;
910
use ipl\Web\Common\BaseItemList;
@@ -24,6 +25,9 @@ protected function init(): void
2425
$this->on(self::ON_ASSEMBLED, function () {
2526
ObjectsRendererHook::load();
2627
});
28+
29+
$this->getAttributes()
30+
->set('data-icinga-detail-url', (string) Links::incident());
2731
}
2832

2933
protected function getItemClass(): string

library/Notifications/Widget/ItemList/IncidentListItem.php

+5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
use ipl\Html\Html;
1717
use ipl\Html\HtmlElement;
1818
use ipl\I18n\Translation;
19+
use ipl\Stdlib\Filter;
1920
use ipl\Web\Common\BaseListItem;
21+
use ipl\Web\Filter\QueryString;
2022
use ipl\Web\Widget\Icon;
2123
use ipl\Web\Widget\Link;
2224
use ipl\Web\Widget\TimeAgo;
@@ -41,6 +43,9 @@ protected function init(): void
4143
$this->getAttributes()
4244
->set('data-action-item', true);
4345
}
46+
47+
$this->getAttributes()
48+
->set('data-icinga-detail-filter', QueryString::render(Filter::equal('id', $this->item->id)));
4449
}
4550

4651
protected function assembleVisual(BaseHtmlElement $visual): void

library/Notifications/Widget/ItemList/ScheduleList.php

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Icinga\Module\Notifications\Widget\ItemList;
66

7+
use Icinga\Module\Notifications\Common\Links;
78
use ipl\Web\Common\BaseItemList;
89

910
class ScheduleList extends BaseItemList
@@ -14,4 +15,10 @@ protected function getItemClass(): string
1415
{
1516
return ScheduleListItem::class;
1617
}
18+
19+
protected function init(): void
20+
{
21+
$this->getAttributes()
22+
->set('data-icinga-detail-url', (string) Links::schedule());
23+
}
1724
}

library/Notifications/Widget/ItemList/ScheduleListItem.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
use Icinga\Module\Notifications\Common\Links;
88
use Icinga\Module\Notifications\Model\Schedule;
99
use ipl\Html\BaseHtmlElement;
10+
use ipl\Stdlib\Filter;
1011
use ipl\Web\Common\BaseListItem;
12+
use ipl\Web\Filter\QueryString;
1113
use ipl\Web\Widget\Link;
1214

1315
/**
@@ -24,7 +26,8 @@ class ScheduleListItem extends BaseListItem
2426
protected function init(): void
2527
{
2628
$this->getAttributes()
27-
->set('data-action-item', true);
29+
->set('data-action-item', true)
30+
->set('data-icinga-detail-filter', QueryString::render(Filter::equal('id', $this->item->id)));
2831
}
2932

3033
protected function assembleTitle(BaseHtmlElement $title): void

0 commit comments

Comments
 (0)