1111use Icinga \Module \Notifications \View \IncidentRenderer ;
1212use Icinga \Module \Notifications \Web \Control \SearchBar \ObjectSuggestions ;
1313use Icinga \Module \Notifications \Widget \ItemList \ObjectList ;
14+ use ipl \Web \Common \Controls ;
1415use ipl \Web \Compat \CompatController ;
1516use ipl \Web \Compat \SearchControls ;
1617use ipl \Web \Control \LimitControl ;
1718use ipl \Web \Control \SortControl ;
1819use ipl \Web \Filter \QueryString ;
20+ use ipl \Web \Layout \DetailedItemLayout ;
21+ use ipl \Web \Layout \ItemLayout ;
1922use ipl \Web \Layout \MinimalItemLayout ;
2023
2124class IncidentsController extends CompatController
2225{
2326 use Auth;
2427 use SearchControls;
28+ use Controls;
2529
2630 public function indexAction (): void
2731 {
@@ -42,11 +46,15 @@ public function indexAction(): void
4246 );
4347
4448 $ paginationControl = $ this ->createPaginationControl ($ incidents );
49+ $ viewModeSwitcher = $ this ->createViewModeSwitcher ($ this ->params );
4550 $ searchBar = $ this ->createSearchBar ($ incidents , [
4651 $ limitControl ->getLimitParam (),
4752 $ sortControl ->getSortParam (),
4853 ]);
4954
55+ $ this ->applyViewModeLimit ($ limitControl , $ paginationControl );
56+ $ this ->handleControls ($ this ->getServerRequest ());
57+
5058 if ($ searchBar ->hasBeenSent () && ! $ searchBar ->isValid ()) {
5159 if ($ searchBar ->hasBeenSubmitted ()) {
5260 $ filter = QueryString::parse ((string ) $ this ->params );
@@ -65,12 +73,17 @@ public function indexAction(): void
6573 $ this ->addControl ($ paginationControl );
6674 $ this ->addControl ($ sortControl );
6775 $ this ->addControl ($ limitControl );
76+ $ this ->addControl ($ viewModeSwitcher );
6877 $ this ->addControl ($ searchBar );
6978
70- $ incidentList = (new ObjectList ($ incidents , new IncidentRenderer ()))
71- ->setItemLayoutClass (MinimalItemLayout::class);
72-
73- $ this ->addContent ($ incidentList );
79+ $ this ->addContent (
80+ (new ObjectList ($ incidents , new IncidentRenderer ()))
81+ ->setItemLayoutClass (match ($ viewModeSwitcher ->getViewMode ()) {
82+ 'minimal ' => MinimalItemLayout::class,
83+ 'detailed ' => DetailedItemLayout::class,
84+ 'common ' => ItemLayout::class
85+ })
86+ );
7487
7588 if (! $ searchBar ->hasBeenSubmitted () && $ searchBar ->hasBeenSent ()) {
7689 $ this ->sendMultipartUpdate ();
0 commit comments