From c29fe2deb6f081579a67d7b3544d27f6ef0c4824 Mon Sep 17 00:00:00 2001 From: vrana Date: Thu, 21 Feb 2013 10:42:19 -0800 Subject: [PATCH] Display application status in tip for needs attention number Summary: Also splits blocking and active revisions. This could display 0 with non-empty tip over it. It's intentional meaning that 0 objects need your attention but there is still some work to do. Test Plan: Hovered over number. Reviewers: epriestley, chad Reviewed By: chad CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D5049 --- .../PhabricatorApplicationAudit.php | 8 ++------ .../PhabricatorApplicationDifferential.php | 20 +++++++++++-------- .../PhabricatorApplicationFlags.php | 4 +--- .../PhabricatorApplicationManiphest.php | 11 ++++------ .../view/PhabricatorApplicationLaunchView.php | 19 +++++++++++++++--- .../view/PhabricatorApplicationStatusView.php | 15 +++++++++++++- .../PhabricatorBaseEnglishTranslation.php | 5 +++++ 7 files changed, 54 insertions(+), 28 deletions(-) diff --git a/src/applications/audit/application/PhabricatorApplicationAudit.php b/src/applications/audit/application/PhabricatorApplicationAudit.php index 73ad9a2be3..f36583689e 100644 --- a/src/applications/audit/application/PhabricatorApplicationAudit.php +++ b/src/applications/audit/application/PhabricatorApplicationAudit.php @@ -56,9 +56,7 @@ final class PhabricatorApplicationAudit extends PhabricatorApplication { ->execute(); $count = count($audits); - $type = $count - ? PhabricatorApplicationStatusView::TYPE_INFO - : PhabricatorApplicationStatusView::TYPE_EMPTY; + $type = PhabricatorApplicationStatusView::TYPE_INFO; $status[] = id(new PhabricatorApplicationStatusView()) ->setType($type) ->setText(pht('%d Commit(s) Awaiting Audit', $count)) @@ -71,9 +69,7 @@ final class PhabricatorApplicationAudit extends PhabricatorApplication { ->execute(); $count = count($commits); - $type = $count - ? PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION - : PhabricatorApplicationStatusView::TYPE_EMPTY; + $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION; $status[] = id(new PhabricatorApplicationStatusView()) ->setType($type) ->setText(pht('%d Problem Commit(s)', $count)) diff --git a/src/applications/differential/application/PhabricatorApplicationDifferential.php b/src/applications/differential/application/PhabricatorApplicationDifferential.php index 3a41d9f925..e1035ca7ad 100644 --- a/src/applications/differential/application/PhabricatorApplicationDifferential.php +++ b/src/applications/differential/application/PhabricatorApplicationDifferential.php @@ -87,22 +87,26 @@ final class PhabricatorApplicationDifferential extends PhabricatorApplication { $status = array(); - $active = count($blocking) + count($active); - $type = $active - ? PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION - : PhabricatorApplicationStatusView::TYPE_EMPTY; + $blocking = count($blocking); + $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION; + $status[] = id(new PhabricatorApplicationStatusView()) + ->setType($type) + ->setText(pht('%d Review(s) Blocking Others', $blocking)) + ->setCount($blocking); + + $active = count($active); + $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION; $status[] = id(new PhabricatorApplicationStatusView()) ->setType($type) ->setText(pht('%d Review(s) Need Attention', $active)) ->setCount($active); $waiting = count($waiting); - $type = $waiting - ? PhabricatorApplicationStatusView::TYPE_INFO - : PhabricatorApplicationStatusView::TYPE_EMPTY; + $type = PhabricatorApplicationStatusView::TYPE_INFO; $status[] = id(new PhabricatorApplicationStatusView()) ->setType($type) - ->setText(pht('%d Review(s) Waiting on Others', $waiting)); + ->setText(pht('%d Review(s) Waiting on Others', $waiting)) + ->setCount($waiting); return $status; } diff --git a/src/applications/flag/application/PhabricatorApplicationFlags.php b/src/applications/flag/application/PhabricatorApplicationFlags.php index ca9dafbb6b..b37329c3de 100644 --- a/src/applications/flag/application/PhabricatorApplicationFlags.php +++ b/src/applications/flag/application/PhabricatorApplicationFlags.php @@ -32,9 +32,7 @@ final class PhabricatorApplicationFlags extends PhabricatorApplication { ->execute(); $count = count($flags); - $type = $count - ? PhabricatorApplicationStatusView::TYPE_INFO - : PhabricatorApplicationStatusView::TYPE_EMPTY; + $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION; $status[] = id(new PhabricatorApplicationStatusView()) ->setType($type) ->setText(pht('%d Flagged Object(s)', $count)) diff --git a/src/applications/maniphest/application/PhabricatorApplicationManiphest.php b/src/applications/maniphest/application/PhabricatorApplicationManiphest.php index 654d99f341..ce7870b008 100644 --- a/src/applications/maniphest/application/PhabricatorApplicationManiphest.php +++ b/src/applications/maniphest/application/PhabricatorApplicationManiphest.php @@ -85,9 +85,7 @@ final class PhabricatorApplicationManiphest extends PhabricatorApplication { $query->execute(); $count = $query->getRowCount(); - $type = $count - ? PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION - : PhabricatorApplicationStatusView::TYPE_EMPTY; + $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION; $status[] = id(new PhabricatorApplicationStatusView()) ->setType($type) ->setText(pht('%d Unbreak Now Task(s)!', $count)) @@ -101,12 +99,11 @@ final class PhabricatorApplicationManiphest extends PhabricatorApplication { $query->execute(); $count = $query->getRowCount(); - $type = $count - ? PhabricatorApplicationStatusView::TYPE_INFO - : PhabricatorApplicationStatusView::TYPE_EMPTY; + $type = PhabricatorApplicationStatusView::TYPE_INFO; $status[] = id(new PhabricatorApplicationStatusView()) ->setType($type) - ->setText(pht('%d Assigned Task(s)', $count)); + ->setText(pht('%d Assigned Task(s)', $count)) + ->setCount($count); return $status; } diff --git a/src/applications/meta/view/PhabricatorApplicationLaunchView.php b/src/applications/meta/view/PhabricatorApplicationLaunchView.php index faa0c348ff..b065b70307 100644 --- a/src/applications/meta/view/PhabricatorApplicationLaunchView.php +++ b/src/applications/meta/view/PhabricatorApplicationLaunchView.php @@ -57,16 +57,29 @@ final class PhabricatorApplicationLaunchView extends AphrontView { } $count = 0; + $text = array(); if ($this->status) { + $attention = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION; foreach ($this->status as $status) { - $count += $status->getCount(); + if ($status->getType() == $attention) { + $count += $status->getCount(); + } + if ($status->getCount()) { + $text[] = $status->getText(); + } } } - if ($count) { - $content[] = phutil_tag( + if ($text) { + Javelin::initBehavior('phabricator-tooltips'); + $content[] = javelin_tag( 'span', array( + 'sigil' => 'has-tooltip', + 'meta' => array( + 'tip' => implode("\n", $text), + 'size' => 240, + ), 'class' => 'phabricator-application-launch-attention', ), $count); diff --git a/src/applications/meta/view/PhabricatorApplicationStatusView.php b/src/applications/meta/view/PhabricatorApplicationStatusView.php index cc2339b9c3..047bcecc8c 100644 --- a/src/applications/meta/view/PhabricatorApplicationStatusView.php +++ b/src/applications/meta/view/PhabricatorApplicationStatusView.php @@ -17,11 +17,19 @@ final class PhabricatorApplicationStatusView extends AphrontView { 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; @@ -32,9 +40,14 @@ final class PhabricatorApplicationStatusView extends AphrontView { } public function render() { + $type = $this->type; + if (!$this->count) { + $type = self::TYPE_EMPTY; + } + $classes = array( 'phabricator-application-status', - 'phabricator-application-status-type-'.$this->type, + 'phabricator-application-status-type-'.$type, ); return phutil_tag( diff --git a/src/infrastructure/internationalization/PhabricatorBaseEnglishTranslation.php b/src/infrastructure/internationalization/PhabricatorBaseEnglishTranslation.php index e5fa1e6eb3..71409b8e2c 100644 --- a/src/infrastructure/internationalization/PhabricatorBaseEnglishTranslation.php +++ b/src/infrastructure/internationalization/PhabricatorBaseEnglishTranslation.php @@ -125,6 +125,11 @@ abstract class PhabricatorBaseEnglishTranslation '%d Problem Commits', ), + '%d Review(s) Blocking Others' => array( + '%d Review Blocking Others', + '%d Reviews Blocking Others', + ), + '%d Review(s) Need Attention' => array( '%d Review Needs Attention', '%d Reviews Need Attention',