1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

When Favorites is uninstalled or not visible to the viewer, hide the menu

Summary: Ref T5867. The `executeOne()` currently raises a policy exception if the application isn't visible to the viewer, or we fatal if the application has been uninstalled.

Test Plan:
  - Viewed pages with the application uninstalled, saw working pages with no favorites menu.
  - Viewed pages with the application restricted, saw working pages with no favorites menu.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T5867

Differential Revision: https://secure.phabricator.com/D17219
This commit is contained in:
epriestley 2017-01-18 06:05:25 -08:00
parent 0513a24235
commit b21cd24341

View file

@ -36,6 +36,11 @@ final class PhabricatorFavoritesApplication extends PhabricatorApplication {
PhabricatorUser $viewer,
PhabricatorController $controller = null) {
$dropdown = $this->renderFavoritesDropdown($viewer);
if (!$dropdown) {
return null;
}
return id(new PHUIButtonView())
->setTag('a')
->setHref('#')
@ -43,17 +48,21 @@ final class PhabricatorFavoritesApplication extends PhabricatorApplication {
->addClass('phabricator-core-user-menu')
->setNoCSS(true)
->setDropdown(true)
->setDropdownMenu($this->renderFavoritesDropdown($viewer));
->setDropdownMenu($dropdown);
}
private function renderFavoritesDropdown(PhabricatorUser $viewer) {
$application = __CLASS__;
$favorites = id(new PhabricatorApplicationQuery())
$applications = id(new PhabricatorApplicationQuery())
->setViewer($viewer)
->withClasses(array($application))
->withInstalled(true)
->executeOne();
->execute();
$favorites = head($applications);
if (!$favorites) {
return null;
}
$menu_engine = id(new PhabricatorFavoritesProfileMenuEngine())
->setViewer($viewer)