Summary: Ref T603. I had to partially revert this earlier because it accidentally blocked access to Conduit and File data for installs without "policy.allow-public", since the applications are available to "all users" but some endpoints actually need to be available even when not logged in. This readjusts the gating in the controller to properly apply application visibility restrictions, and then adds a giant pile of unit test coverage to make sure it sticks and all the weird cases are covered. Test Plan: - Added and executed unit tests. - Executed most of the tests manually, by using logged in / admin / public / disabled users. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T603 Differential Revision: https://secure.phabricator.com/D7211
57 lines
1.5 KiB
PHP
57 lines
1.5 KiB
PHP
<?php
|
|
|
|
final class PhabricatorApplicationsListController
|
|
extends PhabricatorApplicationsController
|
|
implements PhabricatorApplicationSearchResultsControllerInterface {
|
|
|
|
private $queryKey;
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$this->queryKey = idx($data, 'queryKey');
|
|
}
|
|
|
|
public function processRequest() {
|
|
$request = $this->getRequest();
|
|
$controller = id(new PhabricatorApplicationSearchController($request))
|
|
->setQueryKey($this->queryKey)
|
|
->setSearchEngine(new PhabricatorAppSearchEngine())
|
|
->setNavigation($this->buildSideNavView());
|
|
|
|
return $this->delegateToController($controller);
|
|
}
|
|
|
|
public function renderResultsList(
|
|
array $applications,
|
|
PhabricatorSavedQuery $query) {
|
|
assert_instances_of($applications, 'PhabricatorApplication');
|
|
|
|
$list = new PHUIObjectItemListView();
|
|
|
|
$applications = msort($applications, 'getName');
|
|
|
|
foreach ($applications as $application) {
|
|
if ($application->isUnlisted()) {
|
|
continue;
|
|
}
|
|
|
|
$item = id(new PHUIObjectItemView())
|
|
->setHeader($application->getName())
|
|
->setHref('/applications/view/'.get_class($application).'/')
|
|
->addAttribute($application->getShortDescription());
|
|
|
|
if (!$application->isInstalled()) {
|
|
$item->addIcon('delete', pht('Uninstalled'));
|
|
}
|
|
|
|
if ($application->isBeta()) {
|
|
$item->addIcon('lint-warning', pht('Beta'));
|
|
}
|
|
|
|
$list->addItem($item);
|
|
}
|
|
|
|
return $list;
|
|
}
|
|
|
|
}
|