mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-25 18:59:04 +02:00
dashboards/settings: Show tabs depending on where the user comes from
This commit is contained in:
parent
2f09dbe68a
commit
84b462f57c
@ -410,6 +410,18 @@ class DashboardsController extends CompatController
|
||||
public function settingsAction()
|
||||
{
|
||||
$this->dashboard->load();
|
||||
|
||||
$highlightHome = $this->params->get('home');
|
||||
if ($highlightHome) {
|
||||
if (! $this->dashboard->hasEntry($highlightHome)) {
|
||||
$this->httpNotFound(t('Home "%s" not found'), $highlightHome);
|
||||
}
|
||||
|
||||
$home = $this->dashboard->getEntry($highlightHome);
|
||||
$this->dashboard->activateHome($home);
|
||||
$home->loadDashboardEntries(); // createTabs() won't get the panes otherwise
|
||||
}
|
||||
|
||||
$this->createTabs();
|
||||
|
||||
$activeHome = $this->dashboard->getActiveHome();
|
||||
@ -444,7 +456,12 @@ class DashboardsController extends CompatController
|
||||
$tabs = $this->dashboard->getTabs();
|
||||
$activeHome = $this->dashboard->getActiveHome();
|
||||
if ($activeHome && ($activeHome->getName() !== DashboardHome::DEFAULT_HOME || $activeHome->hasEntries())) {
|
||||
$tabs->extend(new DashboardSettings());
|
||||
$params = [];
|
||||
if ($activeHome->getName() !== DashboardHome::DEFAULT_HOME) {
|
||||
$params['home'] = $activeHome->getName();
|
||||
}
|
||||
|
||||
$tabs->extend(new DashboardSettings($params));
|
||||
}
|
||||
|
||||
return $tabs;
|
||||
|
@ -23,6 +23,13 @@ abstract class ItemListControl extends BaseHtmlElement
|
||||
*/
|
||||
abstract protected function getHtmlId(): string;
|
||||
|
||||
/**
|
||||
* Get whether the item should be expanded by default
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function shouldExpandByDefault(): bool;
|
||||
|
||||
/**
|
||||
* Get a class name for the collapsible control
|
||||
*
|
||||
@ -84,7 +91,8 @@ abstract class ItemListControl extends BaseHtmlElement
|
||||
{
|
||||
$this->getAttributes()->add([
|
||||
'id' => $this->getHtmlId(),
|
||||
'class' => 'collapsible'
|
||||
'class' => 'collapsible',
|
||||
'open' => $this->shouldExpandByDefault()
|
||||
]);
|
||||
|
||||
$this->addHtml($this->createItemList());
|
||||
|
@ -53,6 +53,11 @@ class DashboardHomeList extends ItemListControl
|
||||
return $this->home->getUuid();
|
||||
}
|
||||
|
||||
protected function shouldExpandByDefault(): bool
|
||||
{
|
||||
return $this->home->getActive();
|
||||
}
|
||||
|
||||
protected function getCollapsibleControlClass(): string
|
||||
{
|
||||
return 'dashboard-list-info';
|
||||
|
@ -35,6 +35,11 @@ class DashboardList extends ItemListControl
|
||||
return bin2hex($this->pane->getUuid());
|
||||
}
|
||||
|
||||
protected function shouldExpandByDefault(): bool
|
||||
{
|
||||
return $this->pane->getHome()->getActive();
|
||||
}
|
||||
|
||||
protected function getCollapsibleControlClass(): string
|
||||
{
|
||||
return 'dashlets-list-info';
|
||||
|
Loading…
x
Reference in New Issue
Block a user