Skip to content

Commit

Permalink
Utilize Url::setFilter() where applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
nilmerg committed Sep 1, 2023
1 parent 4cec700 commit 2c378d1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 25 deletions.
4 changes: 1 addition & 3 deletions src/Common/StateBadges.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,7 @@ public function createLink($content, array $filter = null): Link
}

if (! $urlFilter->isEmpty()) {
$urlParams = $url->getParams()->toArray(false);
$url->setQueryString(QueryString::render($urlFilter))
->addParams($urlParams);
$url->setFilter($urlFilter);
}

return new Link($content, $url);
Expand Down
23 changes: 2 additions & 21 deletions src/Compat/SearchControls.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,7 @@ public function createSearchBar(Query $query, ...$params): SearchBar
->on(SearchBar::ON_SENT, function (SearchBar $form) {
/** @var Url $redirectUrl */
$redirectUrl = $form->getRedirectUrl();
$existingParams = $redirectUrl->getParams();
$redirectUrl->setQueryString(QueryString::render($form->getFilter()));
foreach ($existingParams->toArray(false) as $name => $value) {
if (is_int($name)) {
$name = $value;
$value = true;
}

$redirectUrl->getParams()->addEncoded($name, $value);
}

$redirectUrl->setFilter($form->getFilter());
$form->setRedirectUrl($redirectUrl);
})->on(SearchBar::ON_SUCCESS, function (SearchBar $form) {
$this->getResponse()->redirectAndExit($form->getRedirectUrl());
Expand Down Expand Up @@ -227,16 +217,7 @@ public function createSearchEditor(Query $query, ...$params): SearchEditor
})->on(SearchEditor::ON_SUCCESS, function (SearchEditor $form) {
/** @var Url $redirectUrl */
$redirectUrl = $form->getRedirectUrl();
$existingParams = $redirectUrl->getParams();
$redirectUrl->setQueryString(QueryString::render($form->getFilter()));
foreach ($existingParams->toArray(false) as $name => $value) {
if (is_int($name)) {
$name = $value;
$value = true;
}

$redirectUrl->getParams()->addEncoded($name, $value);
}
$redirectUrl->setFilter($form->getFilter());

$this->getResponse()
->setHeader('X-Icinga-Container', '_self')
Expand Down
2 changes: 1 addition & 1 deletion src/Widget/ContinueWith.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function assemble()
} else {
$this->addHtml(new ActionLink(
null,
$this->url->setQueryString(QueryString::render($filter)),
$this->url->setFilter($filter),
'share',
['class' => 'control-button', 'title' => $this->title]
));
Expand Down

0 comments on commit 2c378d1

Please sign in to comment.