1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

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
This commit is contained in:
Chad Little 2017-01-20 16:02:37 -08:00
parent 402b6473d8
commit 20d1bb8fdf
10 changed files with 1 additions and 347 deletions

View file

@ -1830,7 +1830,6 @@ phutil_register_library_map(array(
'PhabricatorApplicationSearchEngine' => 'applications/search/engine/PhabricatorApplicationSearchEngine.php',
'PhabricatorApplicationSearchEngineTestCase' => 'applications/search/engine/__tests__/PhabricatorApplicationSearchEngineTestCase.php',
'PhabricatorApplicationSearchResultView' => 'applications/search/view/PhabricatorApplicationSearchResultView.php',
'PhabricatorApplicationStatusView' => 'applications/meta/view/PhabricatorApplicationStatusView.php',
'PhabricatorApplicationTestCase' => 'applications/base/__tests__/PhabricatorApplicationTestCase.php',
'PhabricatorApplicationTransaction' => 'applications/transactions/storage/PhabricatorApplicationTransaction.php',
'PhabricatorApplicationTransactionComment' => 'applications/transactions/storage/PhabricatorApplicationTransactionComment.php',
@ -6712,7 +6711,6 @@ phutil_register_library_map(array(
'PhabricatorApplicationSearchEngine' => 'Phobject',
'PhabricatorApplicationSearchEngineTestCase' => 'PhabricatorTestCase',
'PhabricatorApplicationSearchResultView' => 'Phobject',
'PhabricatorApplicationStatusView' => 'AphrontView',
'PhabricatorApplicationTestCase' => 'PhabricatorTestCase',
'PhabricatorApplicationTransaction' => array(
'PhabricatorLiskDAO',

View file

@ -12,8 +12,6 @@ abstract class PhabricatorApplication
extends Phobject
implements PhabricatorPolicyInterface {
const MAX_STATUS_ITEMS = 100;
const GROUP_CORE = 'core';
const GROUP_UTILITIES = 'util';
const GROUP_ADMIN = 'admin';
@ -272,20 +270,6 @@ abstract class PhabricatorApplication
/* -( UI Integration )----------------------------------------------------- */
/**
* Render status elements (like "3 Waiting Reviews") for application list
* views. These provide a way to alert users to new or pending action items
* in applications.
*
* @param PhabricatorUser Viewing user.
* @return list<PhabricatorApplicationStatusView> Application status elements.
* @task ui
*/
public function loadStatus(PhabricatorUser $user) {
return array();
}
/**
* You can provide an optional piece of flavor text for the application. This
* is currently rendered in application launch views if the application has no

View file

@ -103,82 +103,6 @@ final class PhabricatorDifferentialApplication extends PhabricatorApplication {
);
}
public static function loadNeedAttentionRevisions(PhabricatorUser $viewer) {
if (!$viewer->isLoggedIn()) {
return array();
}
$viewer_phid = $viewer->getPHID();
$responsible_phids = id(new DifferentialResponsibleDatasource())
->setViewer($viewer)
->evaluateTokens(array($viewer_phid));
$revision_query = id(new DifferentialRevisionQuery())
->setViewer($viewer)
->withStatus(DifferentialRevisionQuery::STATUS_OPEN)
->withResponsibleUsers($responsible_phids)
->needReviewerStatus(true)
->needRelationships(true)
->needFlags(true)
->needDrafts(true)
->setLimit(self::MAX_STATUS_ITEMS);
$revisions = $revision_query->execute();
$query = id(new PhabricatorSavedQuery())
->attachParameterMap(
array(
'responsiblePHIDs' => $responsible_phids,
));
$groups = id(new DifferentialRevisionRequiredActionResultBucket())
->setViewer($viewer)
->newResultGroups($query, $revisions);
$include = array();
foreach ($groups as $group) {
switch ($group->getKey()) {
case DifferentialRevisionRequiredActionResultBucket::KEY_MUSTREVIEW:
case DifferentialRevisionRequiredActionResultBucket::KEY_SHOULDREVIEW:
foreach ($group->getObjects() as $object) {
$include[] = $object;
}
break;
default:
break;
}
}
return $include;
}
public function loadStatus(PhabricatorUser $user) {
$revisions = self::loadNeedAttentionRevisions($user);
$limit = self::MAX_STATUS_ITEMS;
if (count($revisions) >= $limit) {
$display_count = ($limit - 1);
$display_label = pht(
'%s+ Active Review(s)',
new PhutilNumber($display_count));
} else {
$display_count = count($revisions);
$display_label = pht(
'%s Review(s) Need Attention',
new PhutilNumber($display_count));
}
$status = array();
$status[] = id(new PhabricatorApplicationStatusView())
->setType(PhabricatorApplicationStatusView::TYPE_WARNING)
->setText($display_label)
->setCount($display_count);
return $status;
}
public function supportsEmailIntegration() {
return true;
}

View file

@ -32,32 +32,6 @@ final class PhabricatorFlagsApplication extends PhabricatorApplication {
return self::GROUP_UTILITIES;
}
public function loadStatus(PhabricatorUser $user) {
$status = array();
$limit = self::MAX_STATUS_ITEMS;
$flags = id(new PhabricatorFlagQuery())
->setViewer($user)
->withOwnerPHIDs(array($user->getPHID()))
->setLimit(self::MAX_STATUS_ITEMS)
->execute();
$count = count($flags);
if ($count >= $limit) {
$count_str = pht('%s+ Flagged Object(s)', new PhutilNumber($limit - 1));
} else {
$count_str = pht('%s Flagged Object(s)', new PhutilNumber($count));
}
$type = PhabricatorApplicationStatusView::TYPE_WARNING;
$status[] = id(new PhabricatorApplicationStatusView())
->setType($type)
->setText($count_str)
->setCount($count);
return $status;
}
public function getRoutes() {
return array(
'/flag/' => array(

View file

@ -31,7 +31,6 @@ abstract class PhabricatorHomeController extends PhabricatorController {
$tiles[] = id(new PhabricatorApplicationLaunchView())
->setApplication($home_app)
->setApplicationStatus($home_app->loadStatus($user))
->addClass('phabricator-application-launch-phone-only')
->setUser($user);
@ -44,7 +43,6 @@ abstract class PhabricatorHomeController extends PhabricatorController {
$tile = id(new PhabricatorApplicationLaunchView())
->setApplication($application)
->setApplicationStatus($application->loadStatus($user))
->setUser($user);
$tiles[] = $tile;

View file

@ -59,37 +59,6 @@ final class PhabricatorManiphestApplication extends PhabricatorApplication {
);
}
public function loadStatus(PhabricatorUser $user) {
$status = array();
if (!$user->isLoggedIn()) {
return $status;
}
$limit = self::MAX_STATUS_ITEMS;
$query = id(new ManiphestTaskQuery())
->setViewer($user)
->withStatuses(ManiphestTaskStatus::getOpenStatusConstants())
->withOwners(array($user->getPHID()))
->setLimit($limit);
$count = count($query->execute());
if ($count >= $limit) {
$count_str = pht('%s+ Assigned Task(s)', new PhutilNumber($limit - 1));
} else {
$count_str = pht('%s Assigned Task(s)', new PhutilNumber($count));
}
$type = PhabricatorApplicationStatusView::TYPE_WARNING;
$status[] = id(new PhabricatorApplicationStatusView())
->setType($type)
->setText($count_str)
->setCount($count);
return $status;
}
public function supportsEmailIntegration() {
return true;
}

View file

@ -3,18 +3,12 @@
final class PhabricatorApplicationLaunchView extends AphrontTagView {
private $application;
private $status;
public function setApplication(PhabricatorApplication $application) {
$this->application = $application;
return $this;
}
public function setApplicationStatus(array $status) {
$this->status = $status;
return $this;
}
protected function getTagName() {
return $this->application ? 'a' : 'div';
}
@ -49,65 +43,9 @@ final class PhabricatorApplicationLaunchView extends AphrontTagView {
),
$application->getShortDescription());
$counts = array();
$text = array();
if ($this->status) {
foreach ($this->status as $status) {
$type = $status->getType();
$counts[$type] = idx($counts, $type, 0) + $status->getCount();
if ($status->getCount()) {
$text[] = $status->getText();
}
}
}
$attention = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION;
$warning = PhabricatorApplicationStatusView::TYPE_WARNING;
if (!empty($counts[$attention]) || !empty($counts[$warning])) {
$count = idx($counts, $attention, 0);
$count1 = $count2 = '';
if ($count > 0) {
$count1 = phutil_tag(
'span',
array(
'class' => 'phabricator-application-attention-count',
),
$this->formatStatusItemCount($count));
}
if (!empty($counts[$warning])) {
$count2 = phutil_tag(
'span',
array(
'class' => 'phabricator-application-warning-count',
),
$this->formatStatusItemCount($counts[$warning]));
}
if (nonempty($count1) && nonempty($count2)) {
$numbers = array($count1, ' / ', $count2);
} else {
$numbers = array($count1, $count2);
}
Javelin::initBehavior('phabricator-tooltips');
$content[] = javelin_tag(
'span',
array(
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => implode("\n", $text),
'size' => 300,
'align' => 'E',
),
'class' => 'phabricator-application-launch-attention',
),
$numbers);
}
$classes = array();
$classes[] = 'phabricator-application-launch-icon';
$styles = array();
$classes[] = $application->getIcon();
$classes[] = 'phui-icon-view';
@ -128,13 +66,4 @@ final class PhabricatorApplicationLaunchView extends AphrontTagView {
);
}
private function formatStatusItemCount($count) {
$limit = PhabricatorApplication::MAX_STATUS_ITEMS;
if ($count >= $limit) {
return pht('%s+', new PhutilNumber($limit - 1));
} else {
return pht('%s', new PhutilNumber($count));
}
}
}

View file

@ -1,61 +0,0 @@
<?php
final class PhabricatorApplicationStatusView extends AphrontView {
private $count;
private $text;
private $type;
const TYPE_NEEDS_ATTENTION = 'needs';
const TYPE_INFO = 'info';
const TYPE_OKAY = 'okay';
const TYPE_WARNING = 'warning';
const TYPE_EMPTY = 'empty';
public function setType($type) {
$this->type = $type;
return $this;
}
public function getType() {
return $this->type;
}
public function setText($text) {
$this->text = $text;
return $this;
}
public function getText() {
return $this->text;
}
public function setCount($count) {
$this->count = $count;
return $this;
}
public function getCount() {
return $this->count;
}
public function render() {
$type = $this->type;
if (!$this->count) {
$type = self::TYPE_EMPTY;
}
$classes = array(
'phabricator-application-status',
'phabricator-application-status-type-'.$type,
);
return phutil_tag(
'span',
array(
'class' => implode(' ', $classes),
),
$this->text);
}
}

View file

@ -92,44 +92,6 @@ final class PhabricatorPeopleApplication extends PhabricatorApplication {
);
}
public function loadStatus(PhabricatorUser $user) {
if (!$user->getIsAdmin()) {
return array();
}
$limit = self::MAX_STATUS_ITEMS;
$need_approval = id(new PhabricatorPeopleQuery())
->setViewer($user)
->withIsApproved(false)
->withIsDisabled(false)
->setLimit($limit)
->execute();
if (!$need_approval) {
return array();
}
$status = array();
$count = count($need_approval);
if ($count >= $limit) {
$count_str = pht(
'%s+ User(s) Need Approval',
new PhutilNumber($limit - 1));
} else {
$count_str = pht(
'%s User(s) Need Approval',
new PhutilNumber($count));
}
$type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION;
$status[] = id(new PhabricatorApplicationStatusView())
->setType($type)
->setText($count_str)
->setCount($count);
return $status;
}
public function getApplicationSearchDocumentTypes() {
return array(
PhabricatorPeopleUserPHIDType::TYPECONST,

View file

@ -46,27 +46,4 @@ final class PhabricatorPhrequentApplication extends PhabricatorApplication {
);
}
public function loadStatus(PhabricatorUser $user) {
$status = array();
$limit = self::MAX_STATUS_ITEMS;
// Show number of objects that are currently
// being tracked for a user.
$count = PhrequentUserTimeQuery::getUserTotalObjectsTracked($user, $limit);
if ($count >= $limit) {
$count_str = pht('%s+ Object(s) Tracked', new PhutilNumber($limit - 1));
} else {
$count_str = pht('%s Object(s) Tracked', new PhutilNumber($count));
}
$type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION;
$status[] = id(new PhabricatorApplicationStatusView())
->setType($type)
->setText($count_str)
->setCount($count);
return $status;
}
}