@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Convert "Diff Details" tabs to PHUITabGroup

Summary:
Ref T10628. Switch this to be nicer and more modern.

- When there's only one tab, add an option to hide it.

Test Plan:
- Viewed normal revisions (no tabs).
- Viewed X vs Y revisions (two tabs, rightmost tab selected by default).

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10628

Differential Revision: https://secure.phabricator.com/D16206

+47 -16
+12 -14
src/applications/differential/controller/DifferentialRevisionViewController.php
··· 1031 1031 ); 1032 1032 } 1033 1033 1034 - $box = id(new PHUIObjectBoxView()) 1035 - ->setHeaderText(pht('Diff Detail')) 1036 - ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 1037 - ->setUser($viewer); 1034 + $tab_group = id(new PHUITabGroupView()) 1035 + ->setHideSingleTab(true); 1038 1036 1039 - $last_tab = null; 1040 1037 foreach ($property_lists as $key => $property_list) { 1041 1038 list($tab_name, $list_view) = $property_list; 1042 1039 1043 - $tab = id(new PHUIListItemView()) 1040 + $tab = id(new PHUITabView()) 1044 1041 ->setKey($key) 1045 - ->setName($tab_name); 1046 - 1047 - $box->addPropertyList($list_view, $tab); 1048 - $last_tab = $tab; 1049 - } 1042 + ->setName($tab_name) 1043 + ->appendChild($list_view); 1050 1044 1051 - if ($last_tab) { 1052 - $last_tab->setSelected(true); 1045 + $tab_group->addTab($tab); 1046 + $tab_group->selectTab($key); 1053 1047 } 1054 1048 1055 - return $box; 1049 + return id(new PHUIObjectBoxView()) 1050 + ->setHeaderText(pht('Diff Detail')) 1051 + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 1052 + ->setUser($viewer) 1053 + ->addTabGroup($tab_group); 1056 1054 } 1057 1055 1058 1056 private function buildDiffPropertyList(
+35 -2
src/view/phui/PHUITabGroupView.php
··· 3 3 final class PHUITabGroupView extends AphrontTagView { 4 4 5 5 private $tabs = array(); 6 + private $selectedTab; 7 + 8 + private $hideSingleTab; 6 9 7 10 protected function canAppendChild() { 8 11 return false; 9 12 } 10 13 14 + public function setHideSingleTab($hide_single_tab) { 15 + $this->hideSingleTab = $hide_single_tab; 16 + return $this; 17 + } 18 + 19 + public function getHideSingleTab() { 20 + return $this->hideSingleTab; 21 + } 22 + 11 23 public function addTab(PHUITabView $tab) { 12 24 $key = $tab->getKey(); 13 25 $tab->lockKey(); ··· 25 37 return $this; 26 38 } 27 39 28 - public function getSelectedTab() { 40 + public function selectTab($key) { 41 + if (empty($this->tabs[$key])) { 42 + throw new Exception( 43 + pht( 44 + 'Unable to select tab ("%s") which does not exist.', 45 + $key)); 46 + } 47 + 48 + $this->selectedTab = $key; 49 + 50 + return $this; 51 + } 52 + 53 + public function getSelectedTabKey() { 29 54 if (!$this->tabs) { 30 55 return null; 31 56 } 32 57 58 + if ($this->selectedTab !== null) { 59 + return $this->selectedTab; 60 + } 61 + 33 62 return head($this->tabs)->getKey(); 34 63 } 35 64 ··· 51 80 ->setType(PHUIListView::NAVBAR_LIST); 52 81 $content = array(); 53 82 54 - $selected_tab = $this->getSelectedTab(); 83 + $selected_tab = $this->getSelectedTabKey(); 55 84 foreach ($this->tabs as $tab) { 56 85 $item = $tab->newMenuItem(); 57 86 $tab_key = $tab->getKey(); ··· 72 101 'id' => $tab->getContentID(), 73 102 ), 74 103 $tab); 104 + } 105 + 106 + if ($this->hideSingleTab && (count($this->tabs) == 1)) { 107 + $tabs = null; 75 108 } 76 109 77 110 return array(