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',
|
||||
'AphrontResponse' => 'aphront/response/AphrontResponse.php',
|
||||
'AphrontSideNavFilterView' => 'view/layout/AphrontSideNavFilterView.php',
|
||||
'AphrontSideNavView' => 'view/layout/AphrontSideNavView.php',
|
||||
'AphrontTableView' => 'view/control/AphrontTableView.php',
|
||||
'AphrontTokenizerTemplateView' => 'view/control/AphrontTokenizerTemplateView.php',
|
||||
'AphrontTypeaheadTemplateView' => 'view/control/AphrontTypeaheadTemplateView.php',
|
||||
|
@ -838,6 +837,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorMarkupCache' => 'applications/cache/storage/PhabricatorMarkupCache.php',
|
||||
'PhabricatorMarkupEngine' => 'infrastructure/markup/PhabricatorMarkupEngine.php',
|
||||
'PhabricatorMarkupInterface' => 'infrastructure/markup/PhabricatorMarkupInterface.php',
|
||||
'PhabricatorMenuItemView' => 'view/layout/PhabricatorMenuItemView.php',
|
||||
'PhabricatorMercurialGraphStream' => 'applications/repository/daemon/PhabricatorMercurialGraphStream.php',
|
||||
'PhabricatorMetaMTAAttachment' => 'applications/metamta/storage/PhabricatorMetaMTAAttachment.php',
|
||||
'PhabricatorMetaMTAController' => 'applications/metamta/controller/PhabricatorMetaMTAController.php',
|
||||
|
@ -1381,7 +1381,6 @@ phutil_register_library_map(array(
|
|||
'AphrontRequestFailureView' => 'AphrontView',
|
||||
'AphrontRequestTestCase' => 'PhabricatorTestCase',
|
||||
'AphrontSideNavFilterView' => 'AphrontView',
|
||||
'AphrontSideNavView' => 'AphrontView',
|
||||
'AphrontTableView' => 'AphrontView',
|
||||
'AphrontTokenizerTemplateView' => 'AphrontView',
|
||||
'AphrontTypeaheadTemplateView' => 'AphrontView',
|
||||
|
@ -2063,6 +2062,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorMainMenuSearchView' => 'AphrontView',
|
||||
'PhabricatorMainMenuView' => 'AphrontView',
|
||||
'PhabricatorMarkupCache' => 'PhabricatorCacheDAO',
|
||||
'PhabricatorMenuItemView' => 'AphrontView',
|
||||
'PhabricatorMetaMTAController' => 'PhabricatorController',
|
||||
'PhabricatorMetaMTADAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorMetaMTAEmailBodyParserTestCase' => 'PhabricatorTestCase',
|
||||
|
|
|
@ -129,28 +129,29 @@ final class AphrontSideNavFilterView extends AphrontView {
|
|||
}
|
||||
}
|
||||
|
||||
$view = new AphrontSideNavView();
|
||||
$view->setFlexNav($this->flexNav);
|
||||
$view->setFlexible($this->flexible);
|
||||
$view->setActive($this->active);
|
||||
if ($this->user) {
|
||||
$view->setUser($this->user);
|
||||
if ($this->flexNav) {
|
||||
return $this->renderFlexNav();
|
||||
} else {
|
||||
return $this->renderLegacyNav();
|
||||
}
|
||||
}
|
||||
|
||||
private function renderNavItems() {
|
||||
$results = array();
|
||||
foreach ($this->items as $item) {
|
||||
list($type, $key, $name) = $item;
|
||||
switch ($type) {
|
||||
case 'custom':
|
||||
$view->addNavItem($name);
|
||||
$results[] = $name;
|
||||
break;
|
||||
case 'spacer':
|
||||
$view->addNavItem('<br />');
|
||||
$results[] = '<br />';
|
||||
break;
|
||||
case 'label':
|
||||
$view->addNavItem(
|
||||
phutil_render_tag(
|
||||
'span',
|
||||
array(),
|
||||
phutil_escape_html($name)));
|
||||
$results[] = phutil_render_tag(
|
||||
'span',
|
||||
array(),
|
||||
phutil_escape_html($name));
|
||||
break;
|
||||
case 'filter':
|
||||
$class = ($key == $this->selectedFilter)
|
||||
|
@ -173,22 +174,121 @@ final class AphrontSideNavFilterView extends AphrontView {
|
|||
}
|
||||
}
|
||||
|
||||
$view->addNavItem(
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $href,
|
||||
'class' => $class,
|
||||
),
|
||||
phutil_escape_html($name)));
|
||||
$results[] = phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $href,
|
||||
'class' => $class,
|
||||
),
|
||||
phutil_escape_html($name));
|
||||
break;
|
||||
default:
|
||||
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