mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-25 18:59:04 +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 = new HomeForm($this->dashboard);
|
||||||
$homeForm->on(HomeForm::ON_SUCCESS, function () use ($homeForm) {
|
$homeForm->on(HomeForm::ON_SUCCESS, function () use ($homeForm) {
|
||||||
|
$this->getResponse()->setHeader('X-Icinga-Extra-Updates', '#menu');
|
||||||
|
|
||||||
$params = ['home' => $homeForm->getPopulatedValue('title')];
|
$params = ['home' => $homeForm->getPopulatedValue('title')];
|
||||||
|
|
||||||
$this->redirectNow(Url::fromPath(Dashboard::BASE_ROUTE . '/settings')->setParams($params));
|
$this->redirectNow(Url::fromPath(Dashboard::BASE_ROUTE . '/settings')->setParams($params));
|
||||||
@ -129,6 +131,8 @@ class DashboardsController extends CompatController
|
|||||||
|
|
||||||
$homeForm = (new RemoveHomeForm($this->dashboard))
|
$homeForm = (new RemoveHomeForm($this->dashboard))
|
||||||
->on(RemoveHomeForm::ON_SUCCESS, function () {
|
->on(RemoveHomeForm::ON_SUCCESS, function () {
|
||||||
|
$this->getResponse()->setHeader('X-Icinga-Extra-Updates', '#menu');
|
||||||
|
|
||||||
$this->redirectNow(Url::fromPath(Dashboard::BASE_ROUTE . '/settings'));
|
$this->redirectNow(Url::fromPath(Dashboard::BASE_ROUTE . '/settings'));
|
||||||
})
|
})
|
||||||
->handleRequest($this->getServerRequest());
|
->handleRequest($this->getServerRequest());
|
||||||
|
@ -297,4 +297,8 @@ abstract class BaseDashboard implements DashboardEntry
|
|||||||
public function rewindEntries()
|
public function rewindEntries()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function unsetEntry(BaseDashboard $dashboard)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,17 @@ trait DashboardEntries
|
|||||||
return reset($dashboards);
|
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)
|
public function reorderWidget(BaseDashboard $dashboard, int $position, Sortable $origin = null)
|
||||||
{
|
{
|
||||||
if ($origin && ! $origin instanceof $this) {
|
if ($origin && ! $origin instanceof $this) {
|
||||||
@ -125,6 +136,10 @@ trait DashboardEntries
|
|||||||
|
|
||||||
$entries[$item->getName()] = $item;
|
$entries[$item->getName()] = $item;
|
||||||
$this->manageEntry($item, $dashboard->getName() === $item->getName() ? $origin : null);
|
$this->manageEntry($item, $dashboard->getName() === $item->getName() ? $origin : null);
|
||||||
|
|
||||||
|
if ($dashboard->getName() === $item->getName() && $origin) {
|
||||||
|
$origin->unsetEntry($dashboard);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setEntries($entries);
|
$this->setEntries($entries);
|
||||||
|
@ -129,4 +129,13 @@ interface DashboardEntry
|
|||||||
* @return false|BaseDashboard
|
* @return false|BaseDashboard
|
||||||
*/
|
*/
|
||||||
public function rewindEntries();
|
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
|
// The module from which this dashlet originates doesn't exist anymore
|
||||||
$this->removeEntry($newDashlet);
|
$this->removeEntry($newDashlet);
|
||||||
|
|
||||||
unset($this->dashboards[$newDashlet->getName()]);
|
$this->unsetEntry($newDashlet);
|
||||||
} elseif (! $newDashlet->isDisabled() && ! Modules\DashletManager::isUsable($newDashlet)) {
|
} elseif (! $newDashlet->isDisabled() && ! Modules\DashletManager::isUsable($newDashlet)) {
|
||||||
// The module from which this dashlet originates is probably disabled,
|
// The module from which this dashlet originates is probably disabled,
|
||||||
// so don't load this dashlet anymore and disable it
|
// so don't load this dashlet anymore and disable it
|
||||||
@ -144,7 +144,7 @@ class Pane extends BaseDashboard implements Sortable
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($newDashlet->isDisabled()) {
|
if ($newDashlet->isDisabled()) {
|
||||||
unset($this->dashboards[$newDashlet->getName()]);
|
$this->unsetEntry($newDashlet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user