Merge pull request #4164 from Icinga/fix/view-compact-handling

Fix view compact handling
This commit is contained in:
Johannes Meyer 2020-06-04 10:23:15 +02:00 committed by GitHub
commit aa14b59e14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 55 additions and 23 deletions

View File

@ -45,6 +45,11 @@ Please consider an upgrade of your central Icinga system to a newer distribution
[icinga.com](https://icinga.com/subscription/support-details/) provides an overview about [icinga.com](https://icinga.com/subscription/support-details/) provides an overview about
currently supported distributions. currently supported distributions.
**Framework changes affecting third-party code**
* Url parameter `view=compact` is now deprecated. `showCompact` should be used instead.
Details are in pull request [#4164](https://github.com/Icinga/icingaweb2/pull/4164).
## Upgrading to Icinga Web 2 2.7.x <a id="upgrading-to-2.7.x"></a> ## Upgrading to Icinga Web 2 2.7.x <a id="upgrading-to-2.7.x"></a>
**Breaking changes** **Breaking changes**

View File

@ -235,7 +235,7 @@ class Controller extends ModuleActionController
'sort', // setupSortControl() 'sort', // setupSortControl()
'dir', // setupSortControl() 'dir', // setupSortControl()
'backend', // Framework 'backend', // Framework
'view', // Framework 'showCompact', // Framework
'_dev' // Framework '_dev' // Framework
); );

View File

@ -129,7 +129,10 @@ class ActionController extends Zend_Controller_Action
$this->_helper->layout()->showFullscreen = $request->getUrl()->shift('showFullscreen'); $this->_helper->layout()->showFullscreen = $request->getUrl()->shift('showFullscreen');
$this->_helper->layout()->moduleName = $moduleName; $this->_helper->layout()->moduleName = $moduleName;
$this->view->compact = $request->getParam('view') === 'compact'; if ($request->getUrl()->getParam('view') === 'compact') {
$request->getUrl()->remove('view');
$this->view->compact = true;
}
if ($request->getUrl()->shift('showCompact')) { if ($request->getUrl()->shift('showCompact')) {
$this->view->compact = true; $this->view->compact = true;
} }

View File

@ -828,6 +828,32 @@ class Url
return $url; return $url;
} }
/**
* Return a copy of this url with only the given parameter(s)
*
* The argument can be either a single query parameter name or
* an array of parameter names to keep on on the query
*
* @param string|array $keyOrArrayOfKeys
*
* @return static
*/
public function onlyWith($keyOrArrayOfKeys)
{
if (! is_array($keyOrArrayOfKeys)) {
$keyOrArrayOfKeys = [$keyOrArrayOfKeys];
}
$url = clone $this;
foreach ($url->getParams()->toArray(false) as $key => $_) {
if (! in_array($key, $keyOrArrayOfKeys, true)) {
$url->remove($key);
}
}
return $url;
}
public function __clone() public function __clone()
{ {
$this->params = clone $this->params; $this->params = clone $this->params;

View File

@ -285,12 +285,10 @@ class FilterEditor extends AbstractWidget
} }
} }
$url = $this->url()->setQueryString( $url = Url::fromRequest()->onlyWith($this->preserveParams);
$filter->toQueryString() $urlParams = $url->getParams();
)->addParams($preserve); $url->setQueryString($filter->toQueryString());
if ($modify) { $url->getParams()->mergeValues($urlParams->toArray(false));
$url->getParams()->add('modifyFilter');
}
$this->redirectNow($url); $this->redirectNow($url);
} }

View File

@ -355,7 +355,7 @@ class ListController extends Controller
$this->view->form = $form; $this->view->form = $form;
$this->params $this->params
->remove('view') ->remove('showCompact')
->remove('format'); ->remove('format');
$orientation = $this->params->shift('vertical', 0) ? 'vertical' : 'horizontal'; $orientation = $this->params->shift('vertical', 0) ? 'vertical' : 'horizontal';
/* /*

View File

@ -35,7 +35,7 @@ class ServicesController extends Controller
$serviceList = new ServiceList($this->backend); $serviceList = new ServiceList($this->backend);
$this->applyRestriction('monitoring/filter/objects', $serviceList); $this->applyRestriction('monitoring/filter/objects', $serviceList);
$serviceList->addFilter(Filter::fromQueryString( $serviceList->addFilter(Filter::fromQueryString(
(string) $this->params->without(array('service_problem', 'service_handled', 'view')) (string) $this->params->without(array('service_problem', 'service_handled', 'showCompact'))
)); ));
$this->serviceList = $serviceList; $this->serviceList = $serviceList;
$this->serviceList->setColumns(array( $this->serviceList->setColumns(array(

View File

@ -43,7 +43,7 @@
<div class="action-links"> <div class="action-links">
<?= $this->qlink( <?= $this->qlink(
$this->translate('Show More'), $this->translate('Show More'),
$this->url()->without(array('view', 'limit')), $this->url()->without(array('showCompact', 'limit')),
null, null,
array( array(
'class' => 'action-link', 'class' => 'action-link',

View File

@ -71,7 +71,7 @@
<div class="action-links"> <div class="action-links">
<?= $this->qlink( <?= $this->qlink(
$this->translate('Show More'), $this->translate('Show More'),
$this->url()->without(array('view', 'limit')), $this->url()->without(array('showCompact', 'limit')),
null, null,
array( array(
'class' => 'action-link', 'class' => 'action-link',

View File

@ -46,7 +46,7 @@ if (! $this->compact): ?>
<div class="action-links"> <div class="action-links">
<?= $this->qlink( <?= $this->qlink(
$this->translate('Show More'), $this->translate('Show More'),
$this->url()->without(array('view', 'limit')), $this->url()->without(array('showCompact', 'limit')),
null, null,
array( array(
'class' => 'action-link', 'class' => 'action-link',

View File

@ -284,7 +284,7 @@ if (! $this->compact): ?>
<div class="action-links"> <div class="action-links">
<?= $this->qlink( <?= $this->qlink(
$this->translate('Show More'), $this->translate('Show More'),
$this->url()->without(array('view', 'limit')), $this->url()->without(array('showCompact', 'limit')),
null, null,
array( array(
'class' => 'action-link', 'class' => 'action-link',

View File

@ -102,7 +102,7 @@ if (! $this->compact): ?>
<div class="action-links"> <div class="action-links">
<?= $this->qlink( <?= $this->qlink(
$this->translate('Show More'), $this->translate('Show More'),
$this->url()->without(array('view', 'limit')), $this->url()->without(array('showCompact', 'limit')),
null, null,
array( array(
'class' => 'action-link', 'class' => 'action-link',

View File

@ -112,7 +112,7 @@ if (! $this->compact): ?>
<div class="action-links"> <div class="action-links">
<?= $this->qlink( <?= $this->qlink(
$this->translate('Show More'), $this->translate('Show More'),
$this->url(isset($notificationsUrl) ? $notificationsUrl : null)->without(array('view', 'limit')), $this->url(isset($notificationsUrl) ? $notificationsUrl : null)->without(array('showCompact', 'limit')),
null, null,
array( array(
'class' => 'action-link', 'class' => 'action-link',

View File

@ -172,7 +172,7 @@ if (! $this->compact): ?>
<div class="action-links"> <div class="action-links">
<?= $this->qlink( <?= $this->qlink(
$this->translate('Show More'), $this->translate('Show More'),
$this->url()->without(array('view', 'limit')), $this->url()->without(array('showCompact', 'limit')),
null, null,
array( array(
'class' => 'action-link', 'class' => 'action-link',

View File

@ -130,7 +130,7 @@ if (! $this->compact): ?>
<div class="action-links"> <div class="action-links">
<?= $this->qlink( <?= $this->qlink(
$this->translate('Show More'), $this->translate('Show More'),
$this->url()->without(array('view', 'limit')), $this->url()->without(array('showCompact', 'limit')),
null, null,
array( array(
'class' => 'action-link', 'class' => 'action-link',

View File

@ -247,7 +247,7 @@ $rowAction = Url::fromPath('monitoring/event/show');
<?php if ($this->compact) { <?php if ($this->compact) {
echo $this->qlink( echo $this->qlink(
$this->translate('Show More'), $this->translate('Show More'),
$url->without(array('view', 'limit')), $url->without(array('showCompact', 'limit')),
null, null,
array( array(
'class' => 'action-link', 'class' => 'action-link',

View File

@ -4,7 +4,7 @@ if ($dataView->hasMore()): ?>
<div class="text-right"> <div class="text-right">
<?= $this->qlink( <?= $this->qlink(
$this->translate('Show More'), $this->translate('Show More'),
$this->url()->without(array('view', 'limit')), $this->url()->without(array('showCompact', 'limit')),
null, null,
array( array(
'data-base-target' => '_next', 'data-base-target' => '_next',

View File

@ -147,7 +147,7 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite
$dir = $url->shift('dir'); $dir = $url->shift('dir');
$page = $url->shift('page'); $page = $url->shift('page');
$format = $url->shift('format'); $format = $url->shift('format');
$view = $url->shift('view'); $view = $url->shift('showCompact');
$view = $url->shift('backend'); $view = $url->shift('backend');
foreach ($url->getParams() as $k => $v) { foreach ($url->getParams() as $k => $v) {
$this->where($k, $v); $this->where($k, $v);

View File

@ -42,8 +42,8 @@
var $modal = _this.$ghost.clone(); var $modal = _this.$ghost.clone();
var $urlTarget = _this.icinga.loader.getLinkTargetFor($a); var $urlTarget = _this.icinga.loader.getLinkTargetFor($a);
// Add view=compact, we don't want controls in a modal // Add showCompact, we don't want controls in a modal
url = _this.icinga.utils.addUrlParams(url, { 'view': 'compact' }); url = _this.icinga.utils.addUrlFlag(url, 'showCompact');
// Set the toggle's base target on the modal to use it as redirect target // Set the toggle's base target on the modal to use it as redirect target
$modal.data('redirectTarget', $urlTarget); $modal.data('redirectTarget', $urlTarget);