Merge pull request #4428 from Icinga/fix/right-column-lost-when-enabling-module-4427

Fix that the right column is lost when enabling a module
This commit is contained in:
Johannes Meyer 2021-07-07 09:57:24 +02:00 committed by GitHub
commit 23a9f309f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 2 deletions

View File

@ -184,7 +184,9 @@ class ConfigController extends Controller
$form->onSuccess();
if ($module->hasJs()) {
$this->redirectHttp('config/modules');
$this->getResponse()
->setReloadWindow(true)
->sendResponse();
} else {
if ($module->hasCss()) {
$this->reloadCss();
@ -221,7 +223,9 @@ class ConfigController extends Controller
$form->onSuccess();
if ($module->hasJs()) {
$this->redirectHttp('config/modules');
$this->getResponse()
->setReloadWindow(true)
->sendResponse();
} else {
if ($module->hasCss()) {
$this->reloadCss();

View File

@ -47,6 +47,13 @@ class Response extends Zend_Controller_Response_Http
*/
protected $request;
/**
* Whether to instruct the client to reload the window
*
* @var bool
*/
protected $reloadWindow;
/**
* Whether to instruct client side script code to reload CSS
*
@ -198,6 +205,30 @@ class Response extends Zend_Controller_Response_Http
return $this->request;
}
/**
* Get whether to instruct the client to reload the window
*
* @return bool
*/
public function isWindowReloaded()
{
return $this->reloadWindow;
}
/**
* Set whether to instruct the client to reload the window
*
* @param bool $reloadWindow
*
* @return $this
*/
public function setReloadWindow($reloadWindow)
{
$this->reloadWindow = $reloadWindow;
return $this;
}
/**
* Get whether to instruct client side script code to reload CSS
*
@ -302,6 +333,9 @@ class Response extends Zend_Controller_Response_Http
if ($this->getRerenderLayout()) {
$this->setHeader('X-Icinga-Container', 'layout', true);
}
if ($this->isWindowReloaded()) {
$this->setHeader('X-Icinga-Reload-Window', 'yes', true);
}
if ($this->isReloadCss()) {
$this->setHeader('X-Icinga-Reload-Css', 'now', true);
}

View File

@ -930,6 +930,11 @@
}
}
if (req.getResponseHeader('X-Icinga-Reload-Window') === 'yes') {
window.location.reload();
return;
}
if (! req.autorefresh && ! req.autosubmit) {
// TODO: Hook for response/url?
var url = req.url;