mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 05:50:55 +01:00
Merge AphrontSideNavView into AphrontSideNavFilterView
Summary: After D4034 there are no AphrontSideNavView callsites outside of AphrontSideNavFilterView. Test Plan: Looked at about a million side navs. Reviewers: chad Reviewed By: chad CC: aran Maniphest Tasks: T1960 Differential Revision: https://secure.phabricator.com/D4035
This commit is contained in:
parent
20ee3003b5
commit
7ebd9af013
3 changed files with 125 additions and 166 deletions
|
@ -82,7 +82,6 @@ phutil_register_library_map(array(
|
||||||
'AphrontRequestTestCase' => 'aphront/__tests__/AphrontRequestTestCase.php',
|
'AphrontRequestTestCase' => 'aphront/__tests__/AphrontRequestTestCase.php',
|
||||||
'AphrontResponse' => 'aphront/response/AphrontResponse.php',
|
'AphrontResponse' => 'aphront/response/AphrontResponse.php',
|
||||||
'AphrontSideNavFilterView' => 'view/layout/AphrontSideNavFilterView.php',
|
'AphrontSideNavFilterView' => 'view/layout/AphrontSideNavFilterView.php',
|
||||||
'AphrontSideNavView' => 'view/layout/AphrontSideNavView.php',
|
|
||||||
'AphrontTableView' => 'view/control/AphrontTableView.php',
|
'AphrontTableView' => 'view/control/AphrontTableView.php',
|
||||||
'AphrontTokenizerTemplateView' => 'view/control/AphrontTokenizerTemplateView.php',
|
'AphrontTokenizerTemplateView' => 'view/control/AphrontTokenizerTemplateView.php',
|
||||||
'AphrontTypeaheadTemplateView' => 'view/control/AphrontTypeaheadTemplateView.php',
|
'AphrontTypeaheadTemplateView' => 'view/control/AphrontTypeaheadTemplateView.php',
|
||||||
|
@ -838,6 +837,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorMarkupCache' => 'applications/cache/storage/PhabricatorMarkupCache.php',
|
'PhabricatorMarkupCache' => 'applications/cache/storage/PhabricatorMarkupCache.php',
|
||||||
'PhabricatorMarkupEngine' => 'infrastructure/markup/PhabricatorMarkupEngine.php',
|
'PhabricatorMarkupEngine' => 'infrastructure/markup/PhabricatorMarkupEngine.php',
|
||||||
'PhabricatorMarkupInterface' => 'infrastructure/markup/PhabricatorMarkupInterface.php',
|
'PhabricatorMarkupInterface' => 'infrastructure/markup/PhabricatorMarkupInterface.php',
|
||||||
|
'PhabricatorMenuItemView' => 'view/layout/PhabricatorMenuItemView.php',
|
||||||
'PhabricatorMercurialGraphStream' => 'applications/repository/daemon/PhabricatorMercurialGraphStream.php',
|
'PhabricatorMercurialGraphStream' => 'applications/repository/daemon/PhabricatorMercurialGraphStream.php',
|
||||||
'PhabricatorMetaMTAAttachment' => 'applications/metamta/storage/PhabricatorMetaMTAAttachment.php',
|
'PhabricatorMetaMTAAttachment' => 'applications/metamta/storage/PhabricatorMetaMTAAttachment.php',
|
||||||
'PhabricatorMetaMTAController' => 'applications/metamta/controller/PhabricatorMetaMTAController.php',
|
'PhabricatorMetaMTAController' => 'applications/metamta/controller/PhabricatorMetaMTAController.php',
|
||||||
|
@ -1381,7 +1381,6 @@ phutil_register_library_map(array(
|
||||||
'AphrontRequestFailureView' => 'AphrontView',
|
'AphrontRequestFailureView' => 'AphrontView',
|
||||||
'AphrontRequestTestCase' => 'PhabricatorTestCase',
|
'AphrontRequestTestCase' => 'PhabricatorTestCase',
|
||||||
'AphrontSideNavFilterView' => 'AphrontView',
|
'AphrontSideNavFilterView' => 'AphrontView',
|
||||||
'AphrontSideNavView' => 'AphrontView',
|
|
||||||
'AphrontTableView' => 'AphrontView',
|
'AphrontTableView' => 'AphrontView',
|
||||||
'AphrontTokenizerTemplateView' => 'AphrontView',
|
'AphrontTokenizerTemplateView' => 'AphrontView',
|
||||||
'AphrontTypeaheadTemplateView' => 'AphrontView',
|
'AphrontTypeaheadTemplateView' => 'AphrontView',
|
||||||
|
@ -2063,6 +2062,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorMainMenuSearchView' => 'AphrontView',
|
'PhabricatorMainMenuSearchView' => 'AphrontView',
|
||||||
'PhabricatorMainMenuView' => 'AphrontView',
|
'PhabricatorMainMenuView' => 'AphrontView',
|
||||||
'PhabricatorMarkupCache' => 'PhabricatorCacheDAO',
|
'PhabricatorMarkupCache' => 'PhabricatorCacheDAO',
|
||||||
|
'PhabricatorMenuItemView' => 'AphrontView',
|
||||||
'PhabricatorMetaMTAController' => 'PhabricatorController',
|
'PhabricatorMetaMTAController' => 'PhabricatorController',
|
||||||
'PhabricatorMetaMTADAO' => 'PhabricatorLiskDAO',
|
'PhabricatorMetaMTADAO' => 'PhabricatorLiskDAO',
|
||||||
'PhabricatorMetaMTAEmailBodyParserTestCase' => 'PhabricatorTestCase',
|
'PhabricatorMetaMTAEmailBodyParserTestCase' => 'PhabricatorTestCase',
|
||||||
|
|
|
@ -129,28 +129,29 @@ final class AphrontSideNavFilterView extends AphrontView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$view = new AphrontSideNavView();
|
if ($this->flexNav) {
|
||||||
$view->setFlexNav($this->flexNav);
|
return $this->renderFlexNav();
|
||||||
$view->setFlexible($this->flexible);
|
} else {
|
||||||
$view->setActive($this->active);
|
return $this->renderLegacyNav();
|
||||||
if ($this->user) {
|
|
||||||
$view->setUser($this->user);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function renderNavItems() {
|
||||||
|
$results = array();
|
||||||
foreach ($this->items as $item) {
|
foreach ($this->items as $item) {
|
||||||
list($type, $key, $name) = $item;
|
list($type, $key, $name) = $item;
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'custom':
|
case 'custom':
|
||||||
$view->addNavItem($name);
|
$results[] = $name;
|
||||||
break;
|
break;
|
||||||
case 'spacer':
|
case 'spacer':
|
||||||
$view->addNavItem('<br />');
|
$results[] = '<br />';
|
||||||
break;
|
break;
|
||||||
case 'label':
|
case 'label':
|
||||||
$view->addNavItem(
|
$results[] = phutil_render_tag(
|
||||||
phutil_render_tag(
|
'span',
|
||||||
'span',
|
array(),
|
||||||
array(),
|
phutil_escape_html($name));
|
||||||
phutil_escape_html($name)));
|
|
||||||
break;
|
break;
|
||||||
case 'filter':
|
case 'filter':
|
||||||
$class = ($key == $this->selectedFilter)
|
$class = ($key == $this->selectedFilter)
|
||||||
|
@ -173,22 +174,121 @@ final class AphrontSideNavFilterView extends AphrontView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$view->addNavItem(
|
$results[] = phutil_render_tag(
|
||||||
phutil_render_tag(
|
'a',
|
||||||
'a',
|
array(
|
||||||
array(
|
'href' => $href,
|
||||||
'href' => $href,
|
'class' => $class,
|
||||||
'class' => $class,
|
),
|
||||||
),
|
phutil_escape_html($name));
|
||||||
phutil_escape_html($name)));
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Exception("Unknown item type '{$type}'.");
|
throw new Exception("Unknown item type '{$type}'.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$view->appendChild($this->renderChildren());
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
return $view->render();
|
private function renderFlexNav() {
|
||||||
|
|
||||||
|
$user = $this->user;
|
||||||
|
|
||||||
|
require_celerity_resource('phabricator-nav-view-css');
|
||||||
|
|
||||||
|
$nav_classes = array();
|
||||||
|
$nav_classes[] = 'phabricator-nav';
|
||||||
|
|
||||||
|
$nav_id = null;
|
||||||
|
$drag_id = null;
|
||||||
|
$content_id = celerity_generate_unique_node_id();
|
||||||
|
$local_id = null;
|
||||||
|
$local_menu = null;
|
||||||
|
$main_id = celerity_generate_unique_node_id();
|
||||||
|
|
||||||
|
if ($this->flexible) {
|
||||||
|
$drag_id = celerity_generate_unique_node_id();
|
||||||
|
$flex_bar = phutil_render_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'phabricator-nav-drag',
|
||||||
|
'id' => $drag_id,
|
||||||
|
),
|
||||||
|
'');
|
||||||
|
} else {
|
||||||
|
$flex_bar = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nav_menu = null;
|
||||||
|
if ($this->items) {
|
||||||
|
$local_id = celerity_generate_unique_node_id();
|
||||||
|
$nav_classes[] = 'has-local-nav';
|
||||||
|
$local_menu = phutil_render_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'phabricator-nav-col phabricator-nav-local',
|
||||||
|
'id' => $local_id,
|
||||||
|
),
|
||||||
|
self::renderSingleView($this->renderNavItems()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Javelin::initBehavior(
|
||||||
|
'phabricator-nav',
|
||||||
|
array(
|
||||||
|
'mainID' => $main_id,
|
||||||
|
'localID' => $local_id,
|
||||||
|
'dragID' => $drag_id,
|
||||||
|
'contentID' => $content_id,
|
||||||
|
));
|
||||||
|
|
||||||
|
if ($this->active && $local_id) {
|
||||||
|
Javelin::initBehavior(
|
||||||
|
'phabricator-active-nav',
|
||||||
|
array(
|
||||||
|
'localID' => $local_id,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
$header_part =
|
||||||
|
'<div class="phabricator-nav-head">'.
|
||||||
|
'<div class="phabricator-nav-head-tablet">'.
|
||||||
|
'<a href="#" class="nav-button nav-button-w nav-button-menu" '.
|
||||||
|
'id="tablet-menu1"></a>'.
|
||||||
|
'<a href="#" class="nav-button nav-button-e nav-button-content '.
|
||||||
|
'nav-button-selected" id="tablet-menu2"></a>'.
|
||||||
|
'</div>'.
|
||||||
|
'</div>';
|
||||||
|
|
||||||
|
return $header_part.phutil_render_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => implode(' ', $nav_classes),
|
||||||
|
'id' => $main_id,
|
||||||
|
),
|
||||||
|
$local_menu.
|
||||||
|
$flex_bar.
|
||||||
|
phutil_render_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'phabricator-nav-content',
|
||||||
|
'id' => $content_id,
|
||||||
|
),
|
||||||
|
$this->renderChildren()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function renderLegacyNav() {
|
||||||
|
require_celerity_resource('aphront-side-nav-view-css');
|
||||||
|
|
||||||
|
return
|
||||||
|
'<table class="aphront-side-nav-view">'.
|
||||||
|
'<tr>'.
|
||||||
|
'<th class="aphront-side-nav-navigation">'.
|
||||||
|
self::renderSingleView($this->renderNavItems()).
|
||||||
|
'</th>'.
|
||||||
|
'<td class="aphront-side-nav-content">'.
|
||||||
|
$this->renderChildren().
|
||||||
|
'</td>'.
|
||||||
|
'</tr>'.
|
||||||
|
'</table>';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,141 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class AphrontSideNavView extends AphrontView {
|
|
||||||
|
|
||||||
private $items = array();
|
|
||||||
private $flexNav;
|
|
||||||
private $isFlexible;
|
|
||||||
private $user;
|
|
||||||
private $active;
|
|
||||||
|
|
||||||
public function setUser(PhabricatorUser $user) {
|
|
||||||
$this->user = $user;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addNavItem($item) {
|
|
||||||
$this->items[] = $item;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setFlexNav($flex) {
|
|
||||||
$this->flexNav = $flex;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setFlexible($flexible) {
|
|
||||||
$this->isFlexible = $flexible;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setActive($active) {
|
|
||||||
$this->active = $active;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function render() {
|
|
||||||
$view = new AphrontNullView();
|
|
||||||
$view->appendChild($this->items);
|
|
||||||
|
|
||||||
if ($this->flexNav) {
|
|
||||||
$user = $this->user;
|
|
||||||
|
|
||||||
require_celerity_resource('phabricator-nav-view-css');
|
|
||||||
|
|
||||||
$nav_classes = array();
|
|
||||||
$nav_classes[] = 'phabricator-nav';
|
|
||||||
|
|
||||||
$nav_id = null;
|
|
||||||
$drag_id = null;
|
|
||||||
$content_id = celerity_generate_unique_node_id();
|
|
||||||
$local_id = null;
|
|
||||||
$local_menu = null;
|
|
||||||
$main_id = celerity_generate_unique_node_id();
|
|
||||||
|
|
||||||
if ($this->isFlexible) {
|
|
||||||
$drag_id = celerity_generate_unique_node_id();
|
|
||||||
$flex_bar = phutil_render_tag(
|
|
||||||
'div',
|
|
||||||
array(
|
|
||||||
'class' => 'phabricator-nav-drag',
|
|
||||||
'id' => $drag_id,
|
|
||||||
),
|
|
||||||
'');
|
|
||||||
} else {
|
|
||||||
$flex_bar = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$nav_menu = null;
|
|
||||||
if ($this->items) {
|
|
||||||
$local_id = celerity_generate_unique_node_id();
|
|
||||||
$nav_classes[] = 'has-local-nav';
|
|
||||||
$local_menu = phutil_render_tag(
|
|
||||||
'div',
|
|
||||||
array(
|
|
||||||
'class' => 'phabricator-nav-col phabricator-nav-local',
|
|
||||||
'id' => $local_id,
|
|
||||||
),
|
|
||||||
$view->render());
|
|
||||||
}
|
|
||||||
|
|
||||||
Javelin::initBehavior(
|
|
||||||
'phabricator-nav',
|
|
||||||
array(
|
|
||||||
'mainID' => $main_id,
|
|
||||||
'localID' => $local_id,
|
|
||||||
'dragID' => $drag_id,
|
|
||||||
'contentID' => $content_id,
|
|
||||||
));
|
|
||||||
|
|
||||||
if ($this->active && $local_id) {
|
|
||||||
Javelin::initBehavior(
|
|
||||||
'phabricator-active-nav',
|
|
||||||
array(
|
|
||||||
'localID' => $local_id,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
$header_part =
|
|
||||||
'<div class="phabricator-nav-head">'.
|
|
||||||
'<div class="phabricator-nav-head-tablet">'.
|
|
||||||
'<a href="#" class="nav-button nav-button-w nav-button-menu" '.
|
|
||||||
'id="tablet-menu1"></a>'.
|
|
||||||
'<a href="#" class="nav-button nav-button-e nav-button-content '.
|
|
||||||
'nav-button-selected" id="tablet-menu2"></a>'.
|
|
||||||
'</div>'.
|
|
||||||
'</div>';
|
|
||||||
|
|
||||||
return $header_part.phutil_render_tag(
|
|
||||||
'div',
|
|
||||||
array(
|
|
||||||
'class' => implode(' ', $nav_classes),
|
|
||||||
'id' => $main_id,
|
|
||||||
),
|
|
||||||
$local_menu.
|
|
||||||
$flex_bar.
|
|
||||||
phutil_render_tag(
|
|
||||||
'div',
|
|
||||||
array(
|
|
||||||
'class' => 'phabricator-nav-content',
|
|
||||||
'id' => $content_id,
|
|
||||||
),
|
|
||||||
$this->renderChildren()));
|
|
||||||
} else {
|
|
||||||
|
|
||||||
require_celerity_resource('aphront-side-nav-view-css');
|
|
||||||
|
|
||||||
return
|
|
||||||
'<table class="aphront-side-nav-view">'.
|
|
||||||
'<tr>'.
|
|
||||||
'<th class="aphront-side-nav-navigation">'.
|
|
||||||
$view->render().
|
|
||||||
'</th>'.
|
|
||||||
'<td class="aphront-side-nav-content">'.
|
|
||||||
$this->renderChildren().
|
|
||||||
'</td>'.
|
|
||||||
'</tr>'.
|
|
||||||
'</table>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in a new issue