mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-24 20:49:06 +01:00
Summary: Ref T10054. I think this gets everything except: - circles on icons; - I spent ~15 minutes poking at animations but wasn't able to get anything that looked reasonable whatsoever. Test Plan: - Collapsed menus. - Expanded menus. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10054 Differential Revision: https://secure.phabricator.com/D15056
112 lines
2.2 KiB
PHP
112 lines
2.2 KiB
PHP
<?php
|
|
|
|
final class PHUIApplicationMenuView extends Phobject {
|
|
|
|
private $viewer;
|
|
private $crumbs;
|
|
private $searchEngine;
|
|
private $profileMenu;
|
|
|
|
private $items = array();
|
|
|
|
public function setViewer(PhabricatorUser $viewer) {
|
|
$this->viewer = $viewer;
|
|
return $this;
|
|
}
|
|
|
|
public function getViewer() {
|
|
return $this->viewer;
|
|
}
|
|
|
|
public function addLabel($name) {
|
|
$item = id(new PHUIListItemView())
|
|
->setName($name);
|
|
|
|
return $this->addItem($item);
|
|
}
|
|
|
|
public function addLink($name, $href) {
|
|
$item = id(new PHUIListItemView())
|
|
->setName($name)
|
|
->setHref($href);
|
|
|
|
return $this->addItem($item);
|
|
}
|
|
|
|
public function setProfileMenu(
|
|
AphrontSideNavFilterView $nav) {
|
|
$this->profileMenu = $nav;
|
|
return $this;
|
|
}
|
|
|
|
public function getProfileMenu() {
|
|
return $this->profileMenu;
|
|
}
|
|
|
|
public function addItem(PHUIListItemView $item) {
|
|
$this->items[] = $item;
|
|
return $this;
|
|
}
|
|
|
|
public function setSearchEngine(PhabricatorApplicationSearchEngine $engine) {
|
|
$this->searchEngine = $engine;
|
|
return $this;
|
|
}
|
|
|
|
public function getSearchEngine() {
|
|
return $this->searchEngine;
|
|
}
|
|
|
|
public function setCrumbs(PHUICrumbsView $crumbs) {
|
|
$this->crumbs = $crumbs;
|
|
return $this;
|
|
}
|
|
|
|
public function getCrumbs() {
|
|
return $this->crumbs;
|
|
}
|
|
|
|
public function buildListView() {
|
|
$viewer = $this->getViewer();
|
|
|
|
$view = id(new PHUIListView())
|
|
->setUser($viewer);
|
|
|
|
$profile_menu = $this->getProfileMenu();
|
|
if ($profile_menu) {
|
|
foreach ($profile_menu->getMenu()->getItems() as $item) {
|
|
if ($item->getHideInApplicationMenu()) {
|
|
continue;
|
|
}
|
|
|
|
$item = clone $item;
|
|
$view->addMenuItem($item);
|
|
}
|
|
}
|
|
|
|
$crumbs = $this->getCrumbs();
|
|
if ($crumbs) {
|
|
$actions = $crumbs->getActions();
|
|
if ($actions) {
|
|
$view->newLabel(pht('Create'));
|
|
foreach ($crumbs->getActions() as $action) {
|
|
$view->addMenuItem($action);
|
|
}
|
|
}
|
|
}
|
|
|
|
$engine = $this->getSearchEngine();
|
|
if ($engine) {
|
|
$engine
|
|
->setViewer($viewer)
|
|
->addNavigationItems($view);
|
|
}
|
|
|
|
foreach ($this->items as $item) {
|
|
$view->addMenuItem($item);
|
|
}
|
|
|
|
return $view;
|
|
}
|
|
|
|
}
|