@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.

Conpherence - get lots of rooms stuff hooked up nicely

Summary:
Ref T7566. This does a big chunk of what's left

- Main view
- "Rooms" sub header
- 5 Rooms shown at a time, with room you're looking at in the top on page load
- e.g. viewing /conpherence/x/ the room x is at top always
- solves corner case of when you have yet to "join" the room
- "See More" link takes you to application search for rooms you have participated in
- if no rooms, there is a "Create Room" and "Find Rooms" links.
- "Messages" sub header
- same as before
- policy icons showing up in the menu
- Durable column view - still just the latest N, no changes really there
- Transactions - special cased rendering to try to say room vs thread as appropos
- Bug fix - we weren't recording the initial participants transaction post D12177 / D12163. This fixes that.

Should probably test pagination, and if you want to show more than 5 rooms of have it behave more like messages (where you can wind up in the middle of a paginated list) that will be more work. Also, if lots of messages / rooms (100 is the limit) we might not display rooms if we're supposed to. Yay whale usage! :D

Test Plan: made a new room - success. made a new message - success. viewed a room from /conpherenece/room/ i wasn't a participant in and noted it showed up at the top of the five rooms. clicked around rooms and stuff loaded nicely.

Reviewers: chad, epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7566

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

+220 -49
+10 -23
src/applications/conpherence/controller/ConpherenceListController.php
··· 6 6 const UNSELECTED_MODE = 'unselected'; 7 7 const PAGING_MODE = 'paging'; 8 8 9 - private $conpherenceID; 10 - 11 - public function setConpherenceID($conpherence_id) { 12 - $this->conpherenceID = $conpherence_id; 13 - return $this; 14 - } 15 - public function getConpherenceID() { 16 - return $this->conpherenceID; 17 - } 18 - 19 - public function willProcessRequest(array $data) { 20 - $this->setConpherenceID(idx($data, 'id')); 21 - } 22 - 23 9 /** 24 10 * Three main modes of operation... 25 11 * ··· 44 30 45 31 return $mode; 46 32 } 47 - public function processRequest() { 48 - $request = $this->getRequest(); 33 + 34 + public function handleRequest(AphrontRequest $request) { 49 35 $user = $request->getUser(); 50 36 $title = pht('Conpherence'); 51 37 $conpherence = null; ··· 58 44 $mode = $this->determineMode(); 59 45 switch ($mode) { 60 46 case self::SELECTED_MODE: 61 - $conpherence_id = $this->getConpherenceID(); 47 + $conpherence_id = $request->getURIData('id'); 62 48 $conpherence = id(new ConpherenceThreadQuery()) 63 49 ->setViewer($user) 64 50 ->withIDs(array($conpherence_id)) ··· 70 56 $title = $conpherence->getTitle(); 71 57 } 72 58 $cursor = $conpherence->getParticipantIfExists($user->getPHID()); 73 - if ($cursor) { 74 - $data = $this->loadParticipationWithMidCursor($cursor); 75 - $all_participation = $data['all_participation']; 76 - $scroll_up_participant = $data['scroll_up_participant']; 77 - $scroll_down_participant = $data['scroll_down_participant']; 78 - } else { 59 + if (!$cursor || $conpherence->getIsRoom()) { 79 60 $data = $this->loadDefaultParticipation($too_many); 80 61 $all_participation = $data['all_participation']; 81 62 $scroll_down_participant = $data['scroll_down_participant']; ··· 85 66 $all_participation = 86 67 array($conpherence->getPHID() => $menu_participation) + 87 68 $all_participation; 69 + 70 + } else { 71 + $data = $this->loadParticipationWithMidCursor($cursor); 72 + $all_participation = $data['all_participation']; 73 + $scroll_up_participant = $data['scroll_up_participant']; 74 + $scroll_down_participant = $data['scroll_down_participant']; 88 75 } 89 76 break; 90 77 case self::PAGING_MODE:
+3
src/applications/conpherence/editor/ConpherenceEditor.php
··· 135 135 case ConpherenceTransactionType::TYPE_TITLE: 136 136 return $object->getTitle(); 137 137 case ConpherenceTransactionType::TYPE_PARTICIPANTS: 138 + if ($this->getIsNewObject()) { 139 + return array(); 140 + } 138 141 return $object->getParticipantPHIDs(); 139 142 case ConpherenceTransactionType::TYPE_FILES: 140 143 return $object->getFilePHIDs();
+109 -17
src/applications/conpherence/storage/ConpherenceTransaction.php
··· 53 53 54 54 switch ($this->getTransactionType()) { 55 55 case ConpherenceTransactionType::TYPE_TITLE: 56 - if ($old && $new) { 57 - $title = pht( 58 - '%s renamed this thread from "%s" to "%s".', 59 - $this->renderHandleLink($author_phid), 60 - $old, 61 - $new); 62 - } else if ($old) { 63 - $title = pht( 64 - '%s deleted the thread name "%s".', 65 - $this->renderHandleLink($author_phid), 66 - $old); 56 + case PhabricatorTransactions::TYPE_VIEW_POLICY: 57 + case PhabricatorTransactions::TYPE_EDIT_POLICY: 58 + case PhabricatorTransactions::TYPE_JOIN_POLICY: 59 + if ($this->getObject()->getIsRoom()) { 60 + return $this->getRoomTitle(); 67 61 } else { 68 - $title = pht( 69 - '%s named this thread "%s".', 70 - $this->renderHandleLink($author_phid), 71 - $new); 62 + return $this->getThreadTitle(); 72 63 } 73 - return $title; 64 + break; 74 65 case ConpherenceTransactionType::TYPE_FILES: 75 66 $add = array_diff($new, $old); 76 67 $rem = array_diff($old, $new); ··· 126 117 return parent::getTitle(); 127 118 } 128 119 120 + private function getRoomTitle() { 121 + $author_phid = $this->getAuthorPHID(); 122 + 123 + $old = $this->getOldValue(); 124 + $new = $this->getNewValue(); 125 + 126 + switch ($this->getTransactionType()) { 127 + case ConpherenceTransactionType::TYPE_TITLE: 128 + if ($old && $new) { 129 + $title = pht( 130 + '%s renamed this room from "%s" to "%s".', 131 + $this->renderHandleLink($author_phid), 132 + $old, 133 + $new); 134 + } else if ($old) { 135 + $title = pht( 136 + '%s deleted the room name "%s".', 137 + $this->renderHandleLink($author_phid), 138 + $old); 139 + } else { 140 + $title = pht( 141 + '%s named this room "%s".', 142 + $this->renderHandleLink($author_phid), 143 + $new); 144 + } 145 + return $title; 146 + break; 147 + case PhabricatorTransactions::TYPE_VIEW_POLICY: 148 + return pht( 149 + '%s changed the visibility of this room from "%s" to "%s".', 150 + $this->renderHandleLink($author_phid), 151 + $this->renderPolicyName($old, 'old'), 152 + $this->renderPolicyName($new, 'new')); 153 + break; 154 + case PhabricatorTransactions::TYPE_EDIT_POLICY: 155 + return pht( 156 + '%s changed the edit policy of this room from "%s" to "%s".', 157 + $this->renderHandleLink($author_phid), 158 + $this->renderPolicyName($old, 'old'), 159 + $this->renderPolicyName($new, 'new')); 160 + break; 161 + case PhabricatorTransactions::TYPE_JOIN_POLICY: 162 + return pht( 163 + '%s changed the join policy of this room from "%s" to "%s".', 164 + $this->renderHandleLink($author_phid), 165 + $this->renderPolicyName($old, 'old'), 166 + $this->renderPolicyName($new, 'new')); 167 + break; 168 + } 169 + } 170 + 171 + private function getThreadTitle() { 172 + $author_phid = $this->getAuthorPHID(); 173 + 174 + $old = $this->getOldValue(); 175 + $new = $this->getNewValue(); 176 + 177 + switch ($this->getTransactionType()) { 178 + case ConpherenceTransactionType::TYPE_TITLE: 179 + if ($old && $new) { 180 + $title = pht( 181 + '%s renamed this thread from "%s" to "%s".', 182 + $this->renderHandleLink($author_phid), 183 + $old, 184 + $new); 185 + } else if ($old) { 186 + $title = pht( 187 + '%s deleted the thread name "%s".', 188 + $this->renderHandleLink($author_phid), 189 + $old); 190 + } else { 191 + $title = pht( 192 + '%s named this thread "%s".', 193 + $this->renderHandleLink($author_phid), 194 + $new); 195 + } 196 + return $title; 197 + break; 198 + case PhabricatorTransactions::TYPE_VIEW_POLICY: 199 + return pht( 200 + '%s changed the visibility of this thread from "%s" to "%s".', 201 + $this->renderHandleLink($author_phid), 202 + $this->renderPolicyName($old, 'old'), 203 + $this->renderPolicyName($new, 'new')); 204 + break; 205 + case PhabricatorTransactions::TYPE_EDIT_POLICY: 206 + return pht( 207 + '%s changed the edit policy of this thread from "%s" to "%s".', 208 + $this->renderHandleLink($author_phid), 209 + $this->renderPolicyName($old, 'old'), 210 + $this->renderPolicyName($new, 'new')); 211 + break; 212 + case PhabricatorTransactions::TYPE_JOIN_POLICY: 213 + return pht( 214 + '%s changed the join policy of this thread from "%s" to "%s".', 215 + $this->renderHandleLink($author_phid), 216 + $this->renderPolicyName($old, 'old'), 217 + $this->renderPolicyName($new, 'new')); 218 + break; 219 + } 220 + } 221 + 129 222 public function getRequiredHandlePHIDs() { 130 223 $phids = parent::getRequiredHandlePHIDs(); 131 224 ··· 146 239 147 240 return $phids; 148 241 } 149 - 150 242 }
+98 -9
src/applications/conpherence/view/ConpherenceThreadListView.php
··· 33 33 public function render() { 34 34 require_celerity_resource('conpherence-menu-css'); 35 35 36 + $grouped = mgroup($this->threads, 'getIsRoom'); 37 + $rooms = idx($grouped, true, array()); 38 + $rooms = array_slice($grouped[true], 0, 5); 39 + 40 + $policies = array(); 41 + foreach ($rooms as $room) { 42 + $policies[] = $room->getViewPolicy(); 43 + } 44 + $policy_objects = array(); 45 + if ($policies) { 46 + $policy_objects = id(new PhabricatorPolicyQuery()) 47 + ->setViewer($this->getUser()) 48 + ->withPHIDs($policies) 49 + ->execute(); 50 + } 51 + 36 52 $menu = id(new PHUIListView()) 37 53 ->addClass('conpherence-menu') 38 54 ->setID('conpherence-menu'); 39 55 40 - $this->addThreadsToMenu($menu, $this->threads); 56 + $this->addRoomsToMenu($menu, $rooms, $policy_objects); 57 + $messages = idx($grouped, false, array()); 58 + $this->addThreadsToMenu($menu, $messages); 41 59 42 60 return $menu; 43 61 } 44 62 45 63 public function renderSingleThread(ConpherenceThread $thread) { 46 - return $this->renderThread($thread); 64 + $policy_objects = id(new PhabricatorPolicyQuery()) 65 + ->setViewer($this->getUser()) 66 + ->setObject($thread) 67 + ->execute(); 68 + return $this->renderThread($thread, $policy_objects); 47 69 } 48 70 49 71 public function renderThreadsHTML() { ··· 68 90 return phutil_implode_html('', $thread_html); 69 91 } 70 92 71 - private function renderThreadItem(ConpherenceThread $thread) { 93 + private function renderThreadItem( 94 + ConpherenceThread $thread, 95 + $policy_objects = array()) { 72 96 return id(new PHUIListItemView()) 73 97 ->setType(PHUIListItemView::TYPE_CUSTOM) 74 - ->setName($this->renderThread($thread)); 98 + ->setName($this->renderThread($thread, $policy_objects)); 75 99 } 76 100 77 - private function renderThread(ConpherenceThread $thread) { 101 + private function renderThread( 102 + ConpherenceThread $thread, 103 + array $policy_objects) { 104 + 78 105 $user = $this->getUser(); 79 106 80 107 $uri = $this->baseURI.$thread->getID().'/'; 81 108 $data = $thread->getDisplayData($user); 82 - $title = $data['title']; 109 + $title = phutil_tag( 110 + 'span', 111 + array(), 112 + array( 113 + id(new PHUIIconView()) 114 + ->addClass('mmr') 115 + ->setIconFont($thread->getPolicyIconName($policy_objects)), 116 + $data['title'], 117 + )); 83 118 $subtitle = $data['subtitle']; 84 119 $unread_count = $data['unread_count']; 85 120 $epoch = $data['epoch']; ··· 104 139 )); 105 140 } 106 141 142 + private function addRoomsToMenu( 143 + PHUIListView $menu, 144 + array $conpherences, 145 + array $policy_objects) { 146 + 147 + $header = $this->renderMenuItemHeader(pht('Rooms')); 148 + $menu->addMenuItem($header); 149 + 150 + if (empty($conpherences)) { 151 + $join_item = id(new PHUIListItemView()) 152 + ->setType(PHUIListItemView::TYPE_LINK) 153 + ->setHref('/conpherence/room/') 154 + ->setName(pht('Join a Room')); 155 + $menu->addMenuItem($join_item); 156 + 157 + $create_item = id(new PHUIListItemView()) 158 + ->setType(PHUIListItemView::TYPE_LINK) 159 + ->setHref('/conpherence/room/new/') 160 + ->setWorkflow(true) 161 + ->setName(pht('Create a Room')); 162 + $menu->addMenuItem($create_item); 163 + 164 + return $menu; 165 + } 166 + 167 + foreach ($conpherences as $conpherence) { 168 + $item = $this->renderThreadItem($conpherence, $policy_objects); 169 + $menu->addMenuItem($item); 170 + } 171 + 172 + $more_item = id(new PHUIListItemView()) 173 + ->setType(PHUIListItemView::TYPE_LINK) 174 + ->setHref('/conpherence/room/query/participant/') 175 + ->setName(pht('See More')); 176 + $menu->addMenuItem($more_item); 177 + 178 + return $menu; 179 + } 180 + 181 + 107 182 private function addThreadsToMenu( 108 183 PHUIListView $menu, 109 184 array $conpherences) { ··· 113 188 $menu->addMenuItem($item); 114 189 } 115 190 116 - $header = $this->renderMenuItemHeader(pht('Recent')); 191 + $header = $this->renderMenuItemHeader(pht('Messages')); 117 192 $menu->addMenuItem($header); 118 193 119 194 foreach ($conpherences as $conpherence) { ··· 163 238 return $item; 164 239 } 165 240 166 - private function getNoConpherencesMenuItem() { 241 + private function getNoMessagesMenuItem() { 167 242 $message = phutil_tag( 168 243 'div', 169 244 array( 170 245 'class' => 'no-conpherences-menu-item', 171 246 ), 172 - pht('No Conpherences')); 247 + pht('No Messages')); 173 248 174 249 return id(new PHUIListItemView()) 175 250 ->setType(PHUIListItemView::TYPE_CUSTOM) 176 251 ->setName($message); 177 252 } 253 + 254 + private function getNoRoomsMenuItem() { 255 + $message = phutil_tag( 256 + 'div', 257 + array( 258 + 'class' => 'no-conpherences-menu-item', 259 + ), 260 + pht('No Rooms')); 261 + 262 + return id(new PHUIListItemView()) 263 + ->setType(PHUIListItemView::TYPE_CUSTOM) 264 + ->setName($message); 265 + } 266 + 178 267 179 268 }