1414use Icinga \Web \Dashboard \Common \Sortable ;
1515use Icinga \Util \DBUtils ;
1616use Icinga \Web \Dashboard \Common \WidgetState ;
17+ use Icinga \Web \Navigation \NavigationItem ;
1718use ipl \Stdlib \Filter ;
1819
1920use function ipl \Stdlib \get_php_type ;
2021
22+ /**
23+ * A Dashboard Home groups various Dashboard Panes and provides the ability
24+ * to load Panes from different entry point of view. Dashboard Homes are
25+ * rendered as child of {@see NavigationItem}s of the main dashboard menu.
26+ */
2127class DashboardHome extends BaseDashboard implements DashboardEntry, Sortable
2228{
2329 use DashboardEntries;
@@ -108,15 +114,18 @@ public function getType(): string
108114 public function activatePane (Pane $ pane ): self
109115 {
110116 if (! $ this ->hasEntry ($ pane ->getName ())) {
111- throw new ProgrammingError ('Trying to activate Dashboard Pane "%s" that does not exist. ' , $ pane ->getName ());
117+ throw new ProgrammingError (
118+ 'Trying to activate Dashboard Pane "%s" that does not exist. ' ,
119+ $ pane ->getTitle ()
120+ );
112121 }
113122
114123 $ active = $ this ->getActivePane ();
115124 if ($ active && $ active ->getName () !== $ pane ->getName ()) {
116125 $ active ->setActive (false );
117126 }
118127
119- $ pane ->setActive (true );
128+ $ pane ->setActive ();
120129
121130 return $ this ;
122131 }
@@ -250,6 +259,8 @@ public function manageEntry($entryOrEntries, BaseDashboard $origin = null, bool
250259 'id = ? ' => $ origin ->getEntry ($ pane ->getName ())->getUuid (),
251260 'home_id = ? ' => $ origin ->getUuid ()
252261 ];
262+
263+ $ this ->addEntry ($ pane );
253264 }
254265
255266 $ conn ->update (Pane::TABLE , [
@@ -262,9 +273,10 @@ public function manageEntry($entryOrEntries, BaseDashboard $origin = null, bool
262273 // Failed to move the pane! Should have already been handled by the caller,
263274 // though I think it's better that we raise an exception here!!
264275 throw new AlreadyExistsException (
265- 'Dashboard Pane "%s" could not be managed. Dashboard Home "%s" has Pane with the same name! ' ,
266- $ pane ->getTitle (),
267- $ this ->getTitle ()
276+ 'Failed to successfully manage the Dashboard Pane. Dashboard Home "%s" has already ' .
277+ ' a Pane called "%s"! ' ,
278+ $ this ->getTitle (),
279+ $ pane ->getTitle ()
268280 );
269281 }
270282
0 commit comments