From c307d50d6fac7be1168dd665f76cdc7b195f4ed0 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 25 Apr 2022 12:14:07 +0200 Subject: [PATCH] [WIP] It's not yet final what Icinga Web 2 implements --- src/Compat/CompatController.php | 4 ++++ src/Compat/SearchControls.php | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Compat/CompatController.php b/src/Compat/CompatController.php index 08e69f14..cabfd504 100644 --- a/src/Compat/CompatController.php +++ b/src/Compat/CompatController.php @@ -261,6 +261,10 @@ public function sendMultipartUpdate(BaseHtmlElement ...$additionalControls) return; } + if ($redirectUrl !== null && ($dashletId = $this->Window()->getDashletId()) !== null) { + $redirectUrl->setParam('_dashlet', bin2hex($dashletId)); + } + if ($this->tabs->count() > 0) { if ($redirectUrl !== null) { $this->tabs->setRefreshUrl($redirectUrl); diff --git a/src/Compat/SearchControls.php b/src/Compat/SearchControls.php index f9b12a11..b1e0f289 100644 --- a/src/Compat/SearchControls.php +++ b/src/Compat/SearchControls.php @@ -3,6 +3,7 @@ namespace ipl\Web\Compat; use GuzzleHttp\Psr7\ServerRequest; +use Icinga\Application\Icinga; use ipl\Orm\Query; use ipl\Stdlib\Seq; use ipl\Web\Control\SearchBar; @@ -43,10 +44,13 @@ private function callHandleRequest() */ public function createSearchBar(Query $query, array $preserveParams = null): SearchBar { - $requestUrl = Url::fromRequest(); - $redirectUrl = $preserveParams !== null - ? $requestUrl->onlyWith($preserveParams) - : (clone $requestUrl)->setParams([]); + $preserveParams = array_merge( + Icinga::app()->getFrameworkParams(), + $preserveParams ?? [] + ); + + $requestUrl = Url::fromPath($this->getRequest()->getUrl()->getRelativeUrl()); + $redirectUrl = $requestUrl->onlyWith($preserveParams); $filter = QueryString::fromString((string) $this->params) ->on(QueryString::ON_CONDITION, function (Filter\Condition $condition) use ($query) { @@ -132,10 +136,15 @@ public function createSearchBar(Query $query, array $preserveParams = null): Sea */ public function createSearchEditor(Query $query, array $preserveParams = null): SearchEditor { - $requestUrl = Url::fromRequest(); + $requestUrl = Url::fromPath($this->getRequest()->getUrl()->getRelativeUrl()); $moduleName = $this->getRequest()->getModuleName(); $controllerName = $this->getRequest()->getControllerName(); $redirectUrl = Url::fromPath("$moduleName/$controllerName"); + + $preserveParams = array_merge( + Icinga::app()->getFrameworkParams(), + $preserveParams ?? [] + ); if (! empty($preserveParams)) { $redirectUrl->setParams($requestUrl->onlyWith($preserveParams)->getParams()); }