1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-24 13:38:19 +01:00

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
This commit is contained in:
vrana 2013-02-21 10:42:19 -08:00
parent 6cee50d4d6
commit c29fe2deb6
7 changed files with 54 additions and 28 deletions

View file

@ -56,9 +56,7 @@ final class PhabricatorApplicationAudit extends PhabricatorApplication {
->execute(); ->execute();
$count = count($audits); $count = count($audits);
$type = $count $type = PhabricatorApplicationStatusView::TYPE_INFO;
? PhabricatorApplicationStatusView::TYPE_INFO
: PhabricatorApplicationStatusView::TYPE_EMPTY;
$status[] = id(new PhabricatorApplicationStatusView()) $status[] = id(new PhabricatorApplicationStatusView())
->setType($type) ->setType($type)
->setText(pht('%d Commit(s) Awaiting Audit', $count)) ->setText(pht('%d Commit(s) Awaiting Audit', $count))
@ -71,9 +69,7 @@ final class PhabricatorApplicationAudit extends PhabricatorApplication {
->execute(); ->execute();
$count = count($commits); $count = count($commits);
$type = $count $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION;
? PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION
: PhabricatorApplicationStatusView::TYPE_EMPTY;
$status[] = id(new PhabricatorApplicationStatusView()) $status[] = id(new PhabricatorApplicationStatusView())
->setType($type) ->setType($type)
->setText(pht('%d Problem Commit(s)', $count)) ->setText(pht('%d Problem Commit(s)', $count))

View file

@ -87,22 +87,26 @@ final class PhabricatorApplicationDifferential extends PhabricatorApplication {
$status = array(); $status = array();
$active = count($blocking) + count($active); $blocking = count($blocking);
$type = $active $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION;
? PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION $status[] = id(new PhabricatorApplicationStatusView())
: PhabricatorApplicationStatusView::TYPE_EMPTY; ->setType($type)
->setText(pht('%d Review(s) Blocking Others', $blocking))
->setCount($blocking);
$active = count($active);
$type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION;
$status[] = id(new PhabricatorApplicationStatusView()) $status[] = id(new PhabricatorApplicationStatusView())
->setType($type) ->setType($type)
->setText(pht('%d Review(s) Need Attention', $active)) ->setText(pht('%d Review(s) Need Attention', $active))
->setCount($active); ->setCount($active);
$waiting = count($waiting); $waiting = count($waiting);
$type = $waiting $type = PhabricatorApplicationStatusView::TYPE_INFO;
? PhabricatorApplicationStatusView::TYPE_INFO
: PhabricatorApplicationStatusView::TYPE_EMPTY;
$status[] = id(new PhabricatorApplicationStatusView()) $status[] = id(new PhabricatorApplicationStatusView())
->setType($type) ->setType($type)
->setText(pht('%d Review(s) Waiting on Others', $waiting)); ->setText(pht('%d Review(s) Waiting on Others', $waiting))
->setCount($waiting);
return $status; return $status;
} }

View file

@ -32,9 +32,7 @@ final class PhabricatorApplicationFlags extends PhabricatorApplication {
->execute(); ->execute();
$count = count($flags); $count = count($flags);
$type = $count $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION;
? PhabricatorApplicationStatusView::TYPE_INFO
: PhabricatorApplicationStatusView::TYPE_EMPTY;
$status[] = id(new PhabricatorApplicationStatusView()) $status[] = id(new PhabricatorApplicationStatusView())
->setType($type) ->setType($type)
->setText(pht('%d Flagged Object(s)', $count)) ->setText(pht('%d Flagged Object(s)', $count))

View file

@ -85,9 +85,7 @@ final class PhabricatorApplicationManiphest extends PhabricatorApplication {
$query->execute(); $query->execute();
$count = $query->getRowCount(); $count = $query->getRowCount();
$type = $count $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION;
? PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION
: PhabricatorApplicationStatusView::TYPE_EMPTY;
$status[] = id(new PhabricatorApplicationStatusView()) $status[] = id(new PhabricatorApplicationStatusView())
->setType($type) ->setType($type)
->setText(pht('%d Unbreak Now Task(s)!', $count)) ->setText(pht('%d Unbreak Now Task(s)!', $count))
@ -101,12 +99,11 @@ final class PhabricatorApplicationManiphest extends PhabricatorApplication {
$query->execute(); $query->execute();
$count = $query->getRowCount(); $count = $query->getRowCount();
$type = $count $type = PhabricatorApplicationStatusView::TYPE_INFO;
? PhabricatorApplicationStatusView::TYPE_INFO
: PhabricatorApplicationStatusView::TYPE_EMPTY;
$status[] = id(new PhabricatorApplicationStatusView()) $status[] = id(new PhabricatorApplicationStatusView())
->setType($type) ->setType($type)
->setText(pht('%d Assigned Task(s)', $count)); ->setText(pht('%d Assigned Task(s)', $count))
->setCount($count);
return $status; return $status;
} }

View file

@ -57,16 +57,29 @@ final class PhabricatorApplicationLaunchView extends AphrontView {
} }
$count = 0; $count = 0;
$text = array();
if ($this->status) { if ($this->status) {
$attention = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION;
foreach ($this->status as $status) { foreach ($this->status as $status) {
if ($status->getType() == $attention) {
$count += $status->getCount(); $count += $status->getCount();
} }
if ($status->getCount()) {
$text[] = $status->getText();
}
}
} }
if ($count) { if ($text) {
$content[] = phutil_tag( Javelin::initBehavior('phabricator-tooltips');
$content[] = javelin_tag(
'span', 'span',
array( array(
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => implode("\n", $text),
'size' => 240,
),
'class' => 'phabricator-application-launch-attention', 'class' => 'phabricator-application-launch-attention',
), ),
$count); $count);

View file

@ -17,11 +17,19 @@ final class PhabricatorApplicationStatusView extends AphrontView {
return $this; return $this;
} }
public function getType() {
return $this->type;
}
public function setText($text) { public function setText($text) {
$this->text = $text; $this->text = $text;
return $this; return $this;
} }
public function getText() {
return $this->text;
}
public function setCount($count) { public function setCount($count) {
$this->count = $count; $this->count = $count;
return $this; return $this;
@ -32,9 +40,14 @@ final class PhabricatorApplicationStatusView extends AphrontView {
} }
public function render() { public function render() {
$type = $this->type;
if (!$this->count) {
$type = self::TYPE_EMPTY;
}
$classes = array( $classes = array(
'phabricator-application-status', 'phabricator-application-status',
'phabricator-application-status-type-'.$this->type, 'phabricator-application-status-type-'.$type,
); );
return phutil_tag( return phutil_tag(

View file

@ -125,6 +125,11 @@ abstract class PhabricatorBaseEnglishTranslation
'%d Problem Commits', '%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(s) Need Attention' => array(
'%d Review Needs Attention', '%d Review Needs Attention',
'%d Reviews Need Attention', '%d Reviews Need Attention',