dashboards/settings: Show tabs depending on where the user comes from

This commit is contained in:
Johannes Meyer 2022-04-29 16:18:24 +02:00 committed by Yonas Habteab
parent 2f09dbe68a
commit 84b462f57c
4 changed files with 37 additions and 2 deletions

View File

@ -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;

View File

@ -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());

View File

@ -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';

View File

@ -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';