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

Remove counts from home navigation

Summary: Ref T12136. This just yanks the band-aid off. Fundamentally these were useful well before Dashboards and advanced bucketing, but not so much any more. They also have some performance hit.

Test Plan: Add some tasks and diffs onto a new instance, see there is no count on the home menu bar.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T12136

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

+1 -347
-2
src/__phutil_library_map__.php
··· 1830 1830 'PhabricatorApplicationSearchEngine' => 'applications/search/engine/PhabricatorApplicationSearchEngine.php', 1831 1831 'PhabricatorApplicationSearchEngineTestCase' => 'applications/search/engine/__tests__/PhabricatorApplicationSearchEngineTestCase.php', 1832 1832 'PhabricatorApplicationSearchResultView' => 'applications/search/view/PhabricatorApplicationSearchResultView.php', 1833 - 'PhabricatorApplicationStatusView' => 'applications/meta/view/PhabricatorApplicationStatusView.php', 1834 1833 'PhabricatorApplicationTestCase' => 'applications/base/__tests__/PhabricatorApplicationTestCase.php', 1835 1834 'PhabricatorApplicationTransaction' => 'applications/transactions/storage/PhabricatorApplicationTransaction.php', 1836 1835 'PhabricatorApplicationTransactionComment' => 'applications/transactions/storage/PhabricatorApplicationTransactionComment.php', ··· 6712 6711 'PhabricatorApplicationSearchEngine' => 'Phobject', 6713 6712 'PhabricatorApplicationSearchEngineTestCase' => 'PhabricatorTestCase', 6714 6713 'PhabricatorApplicationSearchResultView' => 'Phobject', 6715 - 'PhabricatorApplicationStatusView' => 'AphrontView', 6716 6714 'PhabricatorApplicationTestCase' => 'PhabricatorTestCase', 6717 6715 'PhabricatorApplicationTransaction' => array( 6718 6716 'PhabricatorLiskDAO',
-16
src/applications/base/PhabricatorApplication.php
··· 12 12 extends Phobject 13 13 implements PhabricatorPolicyInterface { 14 14 15 - const MAX_STATUS_ITEMS = 100; 16 - 17 15 const GROUP_CORE = 'core'; 18 16 const GROUP_UTILITIES = 'util'; 19 17 const GROUP_ADMIN = 'admin'; ··· 270 268 271 269 272 270 /* -( UI Integration )----------------------------------------------------- */ 273 - 274 - 275 - /** 276 - * Render status elements (like "3 Waiting Reviews") for application list 277 - * views. These provide a way to alert users to new or pending action items 278 - * in applications. 279 - * 280 - * @param PhabricatorUser Viewing user. 281 - * @return list<PhabricatorApplicationStatusView> Application status elements. 282 - * @task ui 283 - */ 284 - public function loadStatus(PhabricatorUser $user) { 285 - return array(); 286 - } 287 271 288 272 289 273 /**
-76
src/applications/differential/application/PhabricatorDifferentialApplication.php
··· 103 103 ); 104 104 } 105 105 106 - public static function loadNeedAttentionRevisions(PhabricatorUser $viewer) { 107 - if (!$viewer->isLoggedIn()) { 108 - return array(); 109 - } 110 - 111 - $viewer_phid = $viewer->getPHID(); 112 - 113 - $responsible_phids = id(new DifferentialResponsibleDatasource()) 114 - ->setViewer($viewer) 115 - ->evaluateTokens(array($viewer_phid)); 116 - 117 - $revision_query = id(new DifferentialRevisionQuery()) 118 - ->setViewer($viewer) 119 - ->withStatus(DifferentialRevisionQuery::STATUS_OPEN) 120 - ->withResponsibleUsers($responsible_phids) 121 - ->needReviewerStatus(true) 122 - ->needRelationships(true) 123 - ->needFlags(true) 124 - ->needDrafts(true) 125 - ->setLimit(self::MAX_STATUS_ITEMS); 126 - 127 - $revisions = $revision_query->execute(); 128 - 129 - $query = id(new PhabricatorSavedQuery()) 130 - ->attachParameterMap( 131 - array( 132 - 'responsiblePHIDs' => $responsible_phids, 133 - )); 134 - 135 - $groups = id(new DifferentialRevisionRequiredActionResultBucket()) 136 - ->setViewer($viewer) 137 - ->newResultGroups($query, $revisions); 138 - 139 - $include = array(); 140 - foreach ($groups as $group) { 141 - switch ($group->getKey()) { 142 - case DifferentialRevisionRequiredActionResultBucket::KEY_MUSTREVIEW: 143 - case DifferentialRevisionRequiredActionResultBucket::KEY_SHOULDREVIEW: 144 - foreach ($group->getObjects() as $object) { 145 - $include[] = $object; 146 - } 147 - break; 148 - default: 149 - break; 150 - } 151 - } 152 - 153 - return $include; 154 - } 155 - 156 - public function loadStatus(PhabricatorUser $user) { 157 - $revisions = self::loadNeedAttentionRevisions($user); 158 - $limit = self::MAX_STATUS_ITEMS; 159 - 160 - if (count($revisions) >= $limit) { 161 - $display_count = ($limit - 1); 162 - $display_label = pht( 163 - '%s+ Active Review(s)', 164 - new PhutilNumber($display_count)); 165 - } else { 166 - $display_count = count($revisions); 167 - $display_label = pht( 168 - '%s Review(s) Need Attention', 169 - new PhutilNumber($display_count)); 170 - } 171 - 172 - $status = array(); 173 - 174 - $status[] = id(new PhabricatorApplicationStatusView()) 175 - ->setType(PhabricatorApplicationStatusView::TYPE_WARNING) 176 - ->setText($display_label) 177 - ->setCount($display_count); 178 - 179 - return $status; 180 - } 181 - 182 106 public function supportsEmailIntegration() { 183 107 return true; 184 108 }
-26
src/applications/flag/application/PhabricatorFlagsApplication.php
··· 32 32 return self::GROUP_UTILITIES; 33 33 } 34 34 35 - public function loadStatus(PhabricatorUser $user) { 36 - $status = array(); 37 - $limit = self::MAX_STATUS_ITEMS; 38 - 39 - $flags = id(new PhabricatorFlagQuery()) 40 - ->setViewer($user) 41 - ->withOwnerPHIDs(array($user->getPHID())) 42 - ->setLimit(self::MAX_STATUS_ITEMS) 43 - ->execute(); 44 - 45 - $count = count($flags); 46 - if ($count >= $limit) { 47 - $count_str = pht('%s+ Flagged Object(s)', new PhutilNumber($limit - 1)); 48 - } else { 49 - $count_str = pht('%s Flagged Object(s)', new PhutilNumber($count)); 50 - } 51 - 52 - $type = PhabricatorApplicationStatusView::TYPE_WARNING; 53 - $status[] = id(new PhabricatorApplicationStatusView()) 54 - ->setType($type) 55 - ->setText($count_str) 56 - ->setCount($count); 57 - 58 - return $status; 59 - } 60 - 61 35 public function getRoutes() { 62 36 return array( 63 37 '/flag/' => array(
-2
src/applications/home/controller/PhabricatorHomeController.php
··· 31 31 32 32 $tiles[] = id(new PhabricatorApplicationLaunchView()) 33 33 ->setApplication($home_app) 34 - ->setApplicationStatus($home_app->loadStatus($user)) 35 34 ->addClass('phabricator-application-launch-phone-only') 36 35 ->setUser($user); 37 36 ··· 44 43 45 44 $tile = id(new PhabricatorApplicationLaunchView()) 46 45 ->setApplication($application) 47 - ->setApplicationStatus($application->loadStatus($user)) 48 46 ->setUser($user); 49 47 50 48 $tiles[] = $tile;
-31
src/applications/maniphest/application/PhabricatorManiphestApplication.php
··· 59 59 ); 60 60 } 61 61 62 - public function loadStatus(PhabricatorUser $user) { 63 - $status = array(); 64 - 65 - if (!$user->isLoggedIn()) { 66 - return $status; 67 - } 68 - 69 - $limit = self::MAX_STATUS_ITEMS; 70 - 71 - $query = id(new ManiphestTaskQuery()) 72 - ->setViewer($user) 73 - ->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()) 74 - ->withOwners(array($user->getPHID())) 75 - ->setLimit($limit); 76 - 77 - $count = count($query->execute()); 78 - if ($count >= $limit) { 79 - $count_str = pht('%s+ Assigned Task(s)', new PhutilNumber($limit - 1)); 80 - } else { 81 - $count_str = pht('%s Assigned Task(s)', new PhutilNumber($count)); 82 - } 83 - 84 - $type = PhabricatorApplicationStatusView::TYPE_WARNING; 85 - $status[] = id(new PhabricatorApplicationStatusView()) 86 - ->setType($type) 87 - ->setText($count_str) 88 - ->setCount($count); 89 - 90 - return $status; 91 - } 92 - 93 62 public function supportsEmailIntegration() { 94 63 return true; 95 64 }
+1 -72
src/applications/meta/view/PhabricatorApplicationLaunchView.php
··· 3 3 final class PhabricatorApplicationLaunchView extends AphrontTagView { 4 4 5 5 private $application; 6 - private $status; 7 6 8 7 public function setApplication(PhabricatorApplication $application) { 9 8 $this->application = $application; 10 - return $this; 11 - } 12 - 13 - public function setApplicationStatus(array $status) { 14 - $this->status = $status; 15 9 return $this; 16 10 } 17 11 ··· 49 43 ), 50 44 $application->getShortDescription()); 51 45 52 - $counts = array(); 53 - $text = array(); 54 - if ($this->status) { 55 - foreach ($this->status as $status) { 56 - $type = $status->getType(); 57 - $counts[$type] = idx($counts, $type, 0) + $status->getCount(); 58 - if ($status->getCount()) { 59 - $text[] = $status->getText(); 60 - } 61 - } 62 - } 63 - 64 - $attention = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION; 65 - $warning = PhabricatorApplicationStatusView::TYPE_WARNING; 66 - if (!empty($counts[$attention]) || !empty($counts[$warning])) { 67 - $count = idx($counts, $attention, 0); 68 - $count1 = $count2 = ''; 69 - if ($count > 0) { 70 - $count1 = phutil_tag( 71 - 'span', 72 - array( 73 - 'class' => 'phabricator-application-attention-count', 74 - ), 75 - $this->formatStatusItemCount($count)); 76 - } 77 - 78 - 79 - if (!empty($counts[$warning])) { 80 - $count2 = phutil_tag( 81 - 'span', 82 - array( 83 - 'class' => 'phabricator-application-warning-count', 84 - ), 85 - $this->formatStatusItemCount($counts[$warning])); 86 - } 87 - 88 - if (nonempty($count1) && nonempty($count2)) { 89 - $numbers = array($count1, ' / ', $count2); 90 - } else { 91 - $numbers = array($count1, $count2); 92 - } 93 - 94 - Javelin::initBehavior('phabricator-tooltips'); 95 - $content[] = javelin_tag( 96 - 'span', 97 - array( 98 - 'sigil' => 'has-tooltip', 99 - 'meta' => array( 100 - 'tip' => implode("\n", $text), 101 - 'size' => 300, 102 - 'align' => 'E', 103 - ), 104 - 'class' => 'phabricator-application-launch-attention', 105 - ), 106 - $numbers); 107 - } 108 - 109 46 $classes = array(); 110 47 $classes[] = 'phabricator-application-launch-icon'; 48 + 111 49 $styles = array(); 112 50 $classes[] = $application->getIcon(); 113 51 $classes[] = 'phui-icon-view'; ··· 126 64 $icon, 127 65 $content, 128 66 ); 129 - } 130 - 131 - private function formatStatusItemCount($count) { 132 - $limit = PhabricatorApplication::MAX_STATUS_ITEMS; 133 - if ($count >= $limit) { 134 - return pht('%s+', new PhutilNumber($limit - 1)); 135 - } else { 136 - return pht('%s', new PhutilNumber($count)); 137 - } 138 67 } 139 68 140 69 }
-61
src/applications/meta/view/PhabricatorApplicationStatusView.php
··· 1 - <?php 2 - 3 - final class PhabricatorApplicationStatusView extends AphrontView { 4 - 5 - private $count; 6 - private $text; 7 - private $type; 8 - 9 - const TYPE_NEEDS_ATTENTION = 'needs'; 10 - const TYPE_INFO = 'info'; 11 - const TYPE_OKAY = 'okay'; 12 - const TYPE_WARNING = 'warning'; 13 - const TYPE_EMPTY = 'empty'; 14 - 15 - public function setType($type) { 16 - $this->type = $type; 17 - return $this; 18 - } 19 - 20 - public function getType() { 21 - return $this->type; 22 - } 23 - 24 - public function setText($text) { 25 - $this->text = $text; 26 - return $this; 27 - } 28 - 29 - public function getText() { 30 - return $this->text; 31 - } 32 - 33 - public function setCount($count) { 34 - $this->count = $count; 35 - return $this; 36 - } 37 - 38 - public function getCount() { 39 - return $this->count; 40 - } 41 - 42 - public function render() { 43 - $type = $this->type; 44 - if (!$this->count) { 45 - $type = self::TYPE_EMPTY; 46 - } 47 - 48 - $classes = array( 49 - 'phabricator-application-status', 50 - 'phabricator-application-status-type-'.$type, 51 - ); 52 - 53 - return phutil_tag( 54 - 'span', 55 - array( 56 - 'class' => implode(' ', $classes), 57 - ), 58 - $this->text); 59 - } 60 - 61 - }
-38
src/applications/people/application/PhabricatorPeopleApplication.php
··· 92 92 ); 93 93 } 94 94 95 - public function loadStatus(PhabricatorUser $user) { 96 - if (!$user->getIsAdmin()) { 97 - return array(); 98 - } 99 - $limit = self::MAX_STATUS_ITEMS; 100 - 101 - $need_approval = id(new PhabricatorPeopleQuery()) 102 - ->setViewer($user) 103 - ->withIsApproved(false) 104 - ->withIsDisabled(false) 105 - ->setLimit($limit) 106 - ->execute(); 107 - if (!$need_approval) { 108 - return array(); 109 - } 110 - 111 - $status = array(); 112 - 113 - $count = count($need_approval); 114 - if ($count >= $limit) { 115 - $count_str = pht( 116 - '%s+ User(s) Need Approval', 117 - new PhutilNumber($limit - 1)); 118 - } else { 119 - $count_str = pht( 120 - '%s User(s) Need Approval', 121 - new PhutilNumber($count)); 122 - } 123 - 124 - $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION; 125 - $status[] = id(new PhabricatorApplicationStatusView()) 126 - ->setType($type) 127 - ->setText($count_str) 128 - ->setCount($count); 129 - 130 - return $status; 131 - } 132 - 133 95 public function getApplicationSearchDocumentTypes() { 134 96 return array( 135 97 PhabricatorPeopleUserPHIDType::TYPECONST,
-23
src/applications/phrequent/application/PhabricatorPhrequentApplication.php
··· 46 46 ); 47 47 } 48 48 49 - public function loadStatus(PhabricatorUser $user) { 50 - $status = array(); 51 - $limit = self::MAX_STATUS_ITEMS; 52 - 53 - // Show number of objects that are currently 54 - // being tracked for a user. 55 - 56 - $count = PhrequentUserTimeQuery::getUserTotalObjectsTracked($user, $limit); 57 - if ($count >= $limit) { 58 - $count_str = pht('%s+ Object(s) Tracked', new PhutilNumber($limit - 1)); 59 - } else { 60 - $count_str = pht('%s Object(s) Tracked', new PhutilNumber($count)); 61 - } 62 - 63 - $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION; 64 - $status[] = id(new PhabricatorApplicationStatusView()) 65 - ->setType($type) 66 - ->setText($count_str) 67 - ->setCount($count); 68 - 69 - return $status; 70 - } 71 - 72 49 }