Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion application/controllers/CommentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ public function indexAction()
$this->addControl($limitControl);
$this->addControl($viewModeSwitcher);
$this->addControl($searchBar);
$continueWith = $this->createContinueWith(Links::commentsDetails(), $searchBar);

$results = $comments->execute();

$continueWith = $this->createContinueWith(Links::commentsDetails(), $searchBar, $results->hasResult());

$this->addContent(
(new ObjectList($results))
->setViewMode($viewModeSwitcher->getViewMode())
Expand Down
3 changes: 2 additions & 1 deletion application/controllers/DowntimesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ public function indexAction()
$this->addControl($limitControl);
$this->addControl($viewModeSwitcher);
$this->addControl($searchBar);
$continueWith = $this->createContinueWith(Links::downtimesDetails(), $searchBar);

$results = $downtimes->execute();

$continueWith = $this->createContinueWith(Links::downtimesDetails(), $searchBar, $results->hasResult());

$this->addContent(
(new ObjectList($results))
->setViewMode($viewModeSwitcher->getViewMode())
Expand Down
7 changes: 5 additions & 2 deletions application/controllers/HostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ public function servicesAction(): Generator

yield $this->export($services);

$serviceList = (new ObjectList($services))
$results = $services->execute();

$serviceList = (new ObjectList($results))
->setViewMode($viewModeSwitcher->getViewMode())
->setEmptyStateMessage($paginationControl->getEmptyStateMessage());

Expand All @@ -297,7 +299,8 @@ public function servicesAction(): Generator
$this->addControl($searchBar);
$continueWith = $this->createContinueWith(
Links::servicesDetails()->setFilter(Filter::equal('host.name', $this->host->name)),
$searchBar
$searchBar,
$results->hasResult()
);

$this->addContent($serviceList);
Expand Down
7 changes: 5 additions & 2 deletions application/controllers/HostgroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ public function indexAction(): Generator

yield $this->export($hosts);

$hostList = (new ObjectList($hosts))
$results = $hosts->execute();

$hostList = (new ObjectList($results))
->setViewMode($viewModeSwitcher->getViewMode())
->setEmptyStateMessage($paginationControl->getEmptyStateMessage());

Expand All @@ -122,7 +124,8 @@ public function indexAction(): Generator
$continueWith = $this->createContinueWith(
Links::hostsDetails()
->setFilter(Filter::equal('hostgroup.name', $hostgroup->name)),
$searchBar
$searchBar,
$results->hasResult()
);

$this->addContent($hostList);
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/HostsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ public function indexAction()
$this->addControl($limitControl);
$this->addControl($viewModeSwitcher);
$this->addControl($searchBar);
$continueWith = $this->createContinueWith(Links::hostsDetails(), $searchBar);

$results = $hosts->execute();

$continueWith = $this->createContinueWith(Links::hostsDetails(), $searchBar, $results->hasResult());
if ($viewModeSwitcher->getViewMode() === 'tabular') {
$hostList = (new HostItemTable($results, HostItemTable::applyColumnMetaData($hosts, $columns)))
->setSort($sortControl->getSort());
Expand Down
7 changes: 5 additions & 2 deletions application/controllers/ServicegroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ public function indexAction(): Generator

yield $this->export($services);

$serviceList = (new ObjectList($services))
$results = $services->execute();

$serviceList = (new ObjectList($results))
->setViewMode($viewModeSwitcher->getViewMode())
->setEmptyStateMessage($paginationControl->getEmptyStateMessage());

Expand All @@ -129,7 +131,8 @@ public function indexAction(): Generator
$continueWith = $this->createContinueWith(
Links::servicesDetails()
->setFilter(Filter::equal('servicegroup.name', $servicegroup->name)),
$searchBar
$searchBar,
$results->hasResult()
);

$this->addContent($serviceList);
Expand Down
5 changes: 3 additions & 2 deletions application/controllers/ServicesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,11 @@ public function indexAction()
$this->addControl($limitControl);
$this->addControl($viewModeSwitcher);
$this->addControl($searchBar);
$continueWith = $this->createContinueWith(Links::servicesDetails(), $searchBar);

$results = $services->execute();

$continueWith = $this->createContinueWith(Links::servicesDetails(), $searchBar, $results->hasResult());

if ($viewModeSwitcher->getViewMode() === 'tabular') {
$serviceList = (new ServiceItemTable($results, ServiceItemTable::applyColumnMetaData($services, $columns)))
->setSort($sortControl->getSort());
Expand Down Expand Up @@ -279,7 +280,6 @@ public function gridAction()
$this->addControl($problemToggle);
$this->addControl($sortControl);
$this->addControl($searchBar);
$continueWith = $this->createContinueWith(Links::servicesDetails(), $searchBar);

$pivotFilter = $problemToggle->isChecked() ?
Filter::equal('service.state.is_problem', 'y') : null;
Expand Down Expand Up @@ -316,6 +316,7 @@ public function gridAction()
$this->view->pivotData = $pivotData;
$this->view->pivotHeader = $pivotHeader;

$continueWith = $this->createContinueWith(Links::servicesDetails(), $searchBar, ! empty($pivotData));
/** Preserve filter and params in view links (the `BaseFilter` implementation for view scripts -.-) */
$this->view->baseUrl = Url::fromRequest()
->onlyWith([
Expand Down
18 changes: 14 additions & 4 deletions library/Icingadb/Common/SearchControls.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,24 @@ public function createSearchBar(Query $query, ...$params): SearchBar
*
* @param Url $detailsUrl
* @param SearchBar $searchBar
* @param bool $hasResults Whether the current query has results
*
* @return ContinueWith
*/
public function createContinueWith(Url $detailsUrl, SearchBar $searchBar): ContinueWith
public function createContinueWith(Url $detailsUrl, SearchBar $searchBar, bool $hasResults): ContinueWith
{
$continueWith = new ContinueWith($detailsUrl, [$searchBar, 'getFilter']);
$continueWith->setTitle(t('Show bulk processing actions for all filtered results'));
$continueWith->setBaseTarget('_next');
if ($hasResults) {
$continueWith = ContinueWith::create(
$detailsUrl,
[$searchBar, 'getFilter'],
t('Show bulk processing actions for all filtered results'),
t('A filter is required to show bulk processing actions'),
);
$continueWith->setBaseTarget('_next');
} else {
$continueWith = ContinueWith::createDisabled(t('No items found'));
}

$continueWith->getAttributes()
->set('id', $this->getRequest()->protectId('continue-with'));

Expand Down
Loading