mirror of
https://we.phorge.it/source/phorge.git
synced 2024-09-20 17:28:51 +02: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:
parent
0513a24235
commit
b21cd24341
1 changed files with 13 additions and 4 deletions
|
@ -36,6 +36,11 @@ final class PhabricatorFavoritesApplication extends PhabricatorApplication {
|
||||||
PhabricatorUser $viewer,
|
PhabricatorUser $viewer,
|
||||||
PhabricatorController $controller = null) {
|
PhabricatorController $controller = null) {
|
||||||
|
|
||||||
|
$dropdown = $this->renderFavoritesDropdown($viewer);
|
||||||
|
if (!$dropdown) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return id(new PHUIButtonView())
|
return id(new PHUIButtonView())
|
||||||
->setTag('a')
|
->setTag('a')
|
||||||
->setHref('#')
|
->setHref('#')
|
||||||
|
@ -43,17 +48,21 @@ final class PhabricatorFavoritesApplication extends PhabricatorApplication {
|
||||||
->addClass('phabricator-core-user-menu')
|
->addClass('phabricator-core-user-menu')
|
||||||
->setNoCSS(true)
|
->setNoCSS(true)
|
||||||
->setDropdown(true)
|
->setDropdown(true)
|
||||||
->setDropdownMenu($this->renderFavoritesDropdown($viewer));
|
->setDropdownMenu($dropdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function renderFavoritesDropdown(PhabricatorUser $viewer) {
|
private function renderFavoritesDropdown(PhabricatorUser $viewer) {
|
||||||
|
|
||||||
$application = __CLASS__;
|
$application = __CLASS__;
|
||||||
$favorites = id(new PhabricatorApplicationQuery())
|
|
||||||
|
$applications = id(new PhabricatorApplicationQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withClasses(array($application))
|
->withClasses(array($application))
|
||||||
->withInstalled(true)
|
->withInstalled(true)
|
||||||
->executeOne();
|
->execute();
|
||||||
|
$favorites = head($applications);
|
||||||
|
if (!$favorites) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$menu_engine = id(new PhabricatorFavoritesProfileMenuEngine())
|
$menu_engine = id(new PhabricatorFavoritesProfileMenuEngine())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
|
|
Loading…
Reference in a new issue