mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-25 10:57:40 +02:00
Force to refresh the menu container when removing a home & unset moved entry from the original widget
This commit is contained in:
parent
d27b654208
commit
3058983011
@ -93,6 +93,8 @@ class DashboardsController extends CompatController
|
||||
|
||||
$homeForm = new HomeForm($this->dashboard);
|
||||
$homeForm->on(HomeForm::ON_SUCCESS, function () use ($homeForm) {
|
||||
$this->getResponse()->setHeader('X-Icinga-Extra-Updates', '#menu');
|
||||
|
||||
$params = ['home' => $homeForm->getPopulatedValue('title')];
|
||||
|
||||
$this->redirectNow(Url::fromPath(Dashboard::BASE_ROUTE . '/settings')->setParams($params));
|
||||
@ -129,6 +131,8 @@ class DashboardsController extends CompatController
|
||||
|
||||
$homeForm = (new RemoveHomeForm($this->dashboard))
|
||||
->on(RemoveHomeForm::ON_SUCCESS, function () {
|
||||
$this->getResponse()->setHeader('X-Icinga-Extra-Updates', '#menu');
|
||||
|
||||
$this->redirectNow(Url::fromPath(Dashboard::BASE_ROUTE . '/settings'));
|
||||
})
|
||||
->handleRequest($this->getServerRequest());
|
||||
|
@ -297,4 +297,8 @@ abstract class BaseDashboard implements DashboardEntry
|
||||
public function rewindEntries()
|
||||
{
|
||||
}
|
||||
|
||||
public function unsetEntry(BaseDashboard $dashboard)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -98,6 +98,17 @@ trait DashboardEntries
|
||||
return reset($dashboards);
|
||||
}
|
||||
|
||||
public function unsetEntry(BaseDashboard $dashboard)
|
||||
{
|
||||
if (! $this->hasEntry($dashboard->getName())) {
|
||||
throw new ProgrammingError('Trying to unset an invalid Dashboard entry: "%s"', $dashboard->getName());
|
||||
}
|
||||
|
||||
unset($this->dashboards[$dashboard->getName()]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function reorderWidget(BaseDashboard $dashboard, int $position, Sortable $origin = null)
|
||||
{
|
||||
if ($origin && ! $origin instanceof $this) {
|
||||
@ -125,6 +136,10 @@ trait DashboardEntries
|
||||
|
||||
$entries[$item->getName()] = $item;
|
||||
$this->manageEntry($item, $dashboard->getName() === $item->getName() ? $origin : null);
|
||||
|
||||
if ($dashboard->getName() === $item->getName() && $origin) {
|
||||
$origin->unsetEntry($dashboard);
|
||||
}
|
||||
}
|
||||
|
||||
$this->setEntries($entries);
|
||||
|
@ -129,4 +129,13 @@ interface DashboardEntry
|
||||
* @return false|BaseDashboard
|
||||
*/
|
||||
public function rewindEntries();
|
||||
|
||||
/**
|
||||
* Unset the given dashboard entry from this widget dashboard entries
|
||||
*
|
||||
* @param BaseDashboard $dashboard
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function unsetEntry(BaseDashboard $dashboard);
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ class Pane extends BaseDashboard implements Sortable
|
||||
// The module from which this dashlet originates doesn't exist anymore
|
||||
$this->removeEntry($newDashlet);
|
||||
|
||||
unset($this->dashboards[$newDashlet->getName()]);
|
||||
$this->unsetEntry($newDashlet);
|
||||
} elseif (! $newDashlet->isDisabled() && ! Modules\DashletManager::isUsable($newDashlet)) {
|
||||
// The module from which this dashlet originates is probably disabled,
|
||||
// so don't load this dashlet anymore and disable it
|
||||
@ -144,7 +144,7 @@ class Pane extends BaseDashboard implements Sortable
|
||||
}
|
||||
|
||||
if ($newDashlet->isDisabled()) {
|
||||
unset($this->dashboards[$newDashlet->getName()]);
|
||||
$this->unsetEntry($newDashlet);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user