Fix exception if all dashboards are disabled

This commit is contained in:
Eric Lippmann 2016-04-13 12:55:01 +02:00
parent 7e15f68a7a
commit 9ec5a46fae
1 changed files with 28 additions and 13 deletions

View File

@ -244,20 +244,35 @@ class DashboardController extends ActionController
if (! $this->dashboard->hasPanes()) {
$this->view->title = 'Dashboard';
} else {
if ($this->_getParam('pane')) {
$pane = $this->_getParam('pane');
$this->dashboard->activate($pane);
}
if ($this->dashboard === null) {
$this->view->title = 'Dashboard';
} else {
$this->view->title = $this->dashboard->getActivePane()->getTitle() . ' :: Dashboard';
if ($this->hasParam('remove')) {
$this->dashboard->getActivePane()->removeDashlet($this->getParam('remove'));
$this->dashboard->getConfig()->saveIni();
$this->redirectNow(URL::fromRequest()->remove('remove'));
$panes = array_filter(
$this->dashboard->getPanes(),
function ($pane) {
return ! $pane->getDisabled();
}
);
if (empty($panes)) {
$this->view->title = 'Dashboard';
$this->getTabs()->add('dashboard', array(
'active' => true,
'title' => $this->translate('Dashboard'),
'url' => Url::fromRequest()
));
} else {
if ($this->_getParam('pane')) {
$pane = $this->_getParam('pane');
$this->dashboard->activate($pane);
}
if ($this->dashboard === null) {
$this->view->title = 'Dashboard';
} else {
$this->view->title = $this->dashboard->getActivePane()->getTitle() . ' :: Dashboard';
if ($this->hasParam('remove')) {
$this->dashboard->getActivePane()->removeDashlet($this->getParam('remove'));
$this->dashboard->getConfig()->saveIni();
$this->redirectNow(URL::fromRequest()->remove('remove'));
}
$this->view->dashboard = $this->dashboard;
}
$this->view->dashboard = $this->dashboard;
}
}
}