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

Add a Conpherence Profile Menu Item

Summary: Builds a Conpherence Profile Menu Item, complete with counts for the unreads. This allows pinning to home as well as swapping out thread list in Conpherence for pinning eventually.

Test Plan: Add a menu item, chat in room, log into other account, see room count. Room count disappears after viewing.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

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

+186 -4
+3 -3
resources/celerity/map.php
··· 7 7 */ 8 8 return array( 9 9 'names' => array( 10 - 'conpherence.pkg.css' => '82aca405', 10 + 'conpherence.pkg.css' => 'b5ee2073', 11 11 'conpherence.pkg.js' => '281b1a73', 12 12 'core.pkg.css' => '476a4ec7', 13 13 'core.pkg.js' => 'fbc1c380', ··· 47 47 'rsrc/css/application/config/unhandled-exception.css' => '4c96257a', 48 48 'rsrc/css/application/conpherence/durable-column.css' => '292c71f0', 49 49 'rsrc/css/application/conpherence/header-pane.css' => '4082233d', 50 - 'rsrc/css/application/conpherence/menu.css' => '3d8e5c9c', 50 + 'rsrc/css/application/conpherence/menu.css' => '5abfb32d', 51 51 'rsrc/css/application/conpherence/message-pane.css' => 'd1fc13e1', 52 52 'rsrc/css/application/conpherence/notification.css' => '965db05b', 53 53 'rsrc/css/application/conpherence/participant-pane.css' => '604a8b02', ··· 554 554 'config-page-css' => 'c1d5121b', 555 555 'conpherence-durable-column-view' => '292c71f0', 556 556 'conpherence-header-pane-css' => '4082233d', 557 - 'conpherence-menu-css' => '3d8e5c9c', 557 + 'conpherence-menu-css' => '5abfb32d', 558 558 'conpherence-message-pane-css' => 'd1fc13e1', 559 559 'conpherence-notification-css' => '965db05b', 560 560 'conpherence-participant-pane-css' => '604a8b02',
+2
src/__phutil_library_map__.php
··· 2387 2387 'PhabricatorConpherenceColumnVisibleSetting' => 'applications/settings/setting/PhabricatorConpherenceColumnVisibleSetting.php', 2388 2388 'PhabricatorConpherenceNotificationsSetting' => 'applications/settings/setting/PhabricatorConpherenceNotificationsSetting.php', 2389 2389 'PhabricatorConpherencePreferencesSettingsPanel' => 'applications/settings/panel/PhabricatorConpherencePreferencesSettingsPanel.php', 2390 + 'PhabricatorConpherenceProfileMenuItem' => 'applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php', 2390 2391 'PhabricatorConpherenceThreadPHIDType' => 'applications/conpherence/phid/PhabricatorConpherenceThreadPHIDType.php', 2391 2392 'PhabricatorConpherenceWidgetVisibleSetting' => 'applications/settings/setting/PhabricatorConpherenceWidgetVisibleSetting.php', 2392 2393 'PhabricatorConsoleApplication' => 'applications/console/application/PhabricatorConsoleApplication.php', ··· 7473 7474 'PhabricatorConpherenceColumnVisibleSetting' => 'PhabricatorInternalSetting', 7474 7475 'PhabricatorConpherenceNotificationsSetting' => 'PhabricatorSelectSetting', 7475 7476 'PhabricatorConpherencePreferencesSettingsPanel' => 'PhabricatorEditEngineSettingsPanel', 7477 + 'PhabricatorConpherenceProfileMenuItem' => 'PhabricatorProfileMenuItem', 7476 7478 'PhabricatorConpherenceThreadPHIDType' => 'PhabricatorPHIDType', 7477 7479 'PhabricatorConpherenceWidgetVisibleSetting' => 'PhabricatorInternalSetting', 7478 7480 'PhabricatorConsoleApplication' => 'PhabricatorApplication',
+174
src/applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php
··· 1 + <?php 2 + 3 + final class PhabricatorConpherenceProfileMenuItem 4 + extends PhabricatorProfileMenuItem { 5 + 6 + const MENUITEMKEY = 'conpherence'; 7 + const FIELD_CONPHERENCE = 'conpherence'; 8 + 9 + private $conpherence; 10 + 11 + public function getMenuItemTypeIcon() { 12 + return 'fa-comments'; 13 + } 14 + 15 + public function getMenuItemTypeName() { 16 + return pht('Conpherence'); 17 + } 18 + 19 + public function canAddToObject($object) { 20 + return true; 21 + } 22 + 23 + public function attachConpherence($conpherence) { 24 + $this->conpherence = $conpherence; 25 + return $this; 26 + } 27 + 28 + public function getConpherence() { 29 + $conpherence = $this->conpherence; 30 + 31 + if (!$conpherence) { 32 + return null; 33 + } 34 + 35 + return $conpherence; 36 + } 37 + 38 + public function willBuildNavigationItems(array $items) { 39 + require_celerity_resource('conpherence-menu-css'); 40 + $viewer = $this->getViewer(); 41 + $room_phids = array(); 42 + foreach ($items as $item) { 43 + $room_phids[] = $item->getMenuItemProperty('conpherence'); 44 + } 45 + 46 + $rooms = id(new ConpherenceThreadQuery()) 47 + ->setViewer($viewer) 48 + ->withPHIDs($room_phids) 49 + ->needParticipantCache(true) 50 + ->needProfileImage(true) 51 + ->execute(); 52 + 53 + $rooms = mpull($rooms, null, 'getPHID'); 54 + foreach ($items as $item) { 55 + $room_phid = $item->getMenuItemProperty('conpherence'); 56 + $room = idx($rooms, $room_phid, null); 57 + $item->getMenuItem()->attachConpherence($room); 58 + } 59 + } 60 + 61 + public function getDisplayName( 62 + PhabricatorProfileMenuItemConfiguration $config) { 63 + $room = $this->getConpherence($config); 64 + if (!$room) { 65 + return pht('(Restricted/Invalid Conpherence)'); 66 + } 67 + 68 + $name = $this->getName($config); 69 + if (strlen($name)) { 70 + return $name; 71 + } 72 + 73 + return $room->getTitle(); 74 + } 75 + 76 + public function buildEditEngineFields( 77 + PhabricatorProfileMenuItemConfiguration $config) { 78 + return array( 79 + id(new PhabricatorDatasourceEditField()) 80 + ->setKey(self::FIELD_CONPHERENCE) 81 + ->setLabel(pht('Conpherence Room')) 82 + ->setDatasource(new ConpherenceThreadDatasource()) 83 + ->setIsRequired(true) 84 + ->setSingleValue($config->getMenuItemProperty('conpherence')), 85 + id(new PhabricatorTextEditField()) 86 + ->setKey('name') 87 + ->setLabel(pht('Name')) 88 + ->setValue($this->getName($config)), 89 + ); 90 + } 91 + 92 + private function getName( 93 + PhabricatorProfileMenuItemConfiguration $config) { 94 + return $config->getMenuItemProperty('name'); 95 + } 96 + 97 + protected function newNavigationMenuItems( 98 + PhabricatorProfileMenuItemConfiguration $config) { 99 + $viewer = $this->getViewer(); 100 + $room = $this->getConpherence($config); 101 + if (!$room) { 102 + return array(); 103 + } 104 + 105 + $data = $room->getDisplayData($viewer); 106 + $unread_count = $data['unread_count']; 107 + 108 + $count = null; 109 + if ($unread_count) { 110 + $count = phutil_tag( 111 + 'span', 112 + array( 113 + 'class' => 'conpherence-menu-item-count', 114 + ), 115 + $unread_count); 116 + } 117 + 118 + $item = $this->newItem() 119 + ->setHref('/'.$room->getMonogram()) 120 + ->setName($this->getDisplayName($config)) 121 + ->setIcon('fa-comments') 122 + ->appendChild($count); 123 + 124 + return array( 125 + $item, 126 + ); 127 + } 128 + 129 + public function validateTransactions( 130 + PhabricatorProfileMenuItemConfiguration $config, 131 + $field_key, 132 + $value, 133 + array $xactions) { 134 + 135 + $viewer = $this->getViewer(); 136 + $errors = array(); 137 + 138 + if ($field_key == self::FIELD_CONPHERENCE) { 139 + if ($this->isEmptyTransaction($value, $xactions)) { 140 + $errors[] = $this->newRequiredError( 141 + pht('You must choose a room.'), 142 + $field_key); 143 + } 144 + 145 + foreach ($xactions as $xaction) { 146 + $new = $xaction['new']; 147 + 148 + if (!$new) { 149 + continue; 150 + } 151 + 152 + if ($new === $value) { 153 + continue; 154 + } 155 + 156 + $rooms = id(new ConpherenceThreadQuery()) 157 + ->setViewer($viewer) 158 + ->withPHIDs(array($new)) 159 + ->execute(); 160 + if (!$rooms) { 161 + $errors[] = $this->newInvalidError( 162 + pht( 163 + 'Room "%s" is not a valid room which you have '. 164 + 'permission to see.', 165 + $new), 166 + $xaction['xaction']); 167 + } 168 + } 169 + } 170 + 171 + return $errors; 172 + } 173 + 174 + }
+7 -1
webroot/rsrc/css/application/conpherence/menu.css
··· 167 167 } 168 168 169 169 .conpherence-menu .conpherence-menu-item-view 170 - .conpherence-menu-item-unread-count { 170 + .conpherence-menu-item-unread-count, 171 + .conpherence-menu-item-count { 171 172 position: absolute; 172 173 right: 4px; 173 174 top: 10px; ··· 177 178 font-weight: bold; 178 179 padding: 0 5px 1px; 179 180 font-size: {$smallestfontsize}; 181 + } 182 + 183 + .phui-list-item-view .conpherence-menu-item-count { 184 + right: 7px; 185 + top: 7px; 180 186 } 181 187 182 188 .conpherence-menu .hide-unread-count .conpherence-menu-item-unread-count,