1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 12:00:55 +01:00

Inform about disabled and away users in Differential fields

Summary:
I've tried colors, italics, strike-through and this is a compromise between me and @leebyron.

NOTE: I don't want to disturb @epriestley from playing Diablo 3.

Test Plan: {F11439, size=full}

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, epriestley, leebyron

Differential Revision: https://secure.phabricator.com/D2481
This commit is contained in:
vrana 2012-05-16 14:38:16 -07:00
parent e9c3894861
commit 6d5dcea3ba
5 changed files with 44 additions and 26 deletions

View file

@ -32,10 +32,7 @@ final class DifferentialAuthorFieldSpecification
}
public function renderValueForRevisionView() {
$author_phid = $this->getAuthorPHID();
$handle = $this->getHandle($author_phid);
return $handle->renderLink();
return $this->renderUserList(array($this->getAuthorPHID()));
}
private function getAuthorPHID() {

View file

@ -265,6 +265,45 @@ abstract class DifferentialFieldSpecification {
}
/**
* Load users, their current statuses and return a markup with links to the
* user profiles and information about their current status.
*
* @return string Display markup.
* @task view
*/
public function renderUserList(array $user_phids) {
if (!$user_phids) {
return '<em>None</em>';
}
$statuses = id(new PhabricatorUserStatus())->loadAllWhere(
'userPHID IN (%Ls) AND UNIX_TIMESTAMP() BETWEEN dateFrom AND dateTo',
$user_phids);
$statuses = mpull($statuses, null, 'getUserPHID');
$links = array();
foreach ($user_phids as $user_phid) {
$handle = $this->getHandle($user_phid);
$extra = null;
$status = idx($statuses, $handle->getPHID());
if ($handle->isDisabled()) {
$extra = ' <strong>(disabled)</strong>';
} else if ($status) {
$until = phabricator_date($status->getDateTo(), $this->getUser());
if ($status->getStatus() == PhabricatorUserStatus::STATUS_SPORADIC) {
$extra = ' <strong title="until '.$until.'">(sporadic)</strong>';
} else {
$extra = ' <strong title="until '.$until.'">(away)</strong>';
}
}
$links[] = $handle->renderLink().$extra;
}
return implode(', ', $links);
}
/**
* Return a markup block representing a warning to display with the comment
* box when preparing to accept a diff. A return value of null indicates no

View file

@ -11,6 +11,8 @@ phutil_require_module('phabricator', 'applications/differential/field/exception/
phutil_require_module('phabricator', 'applications/differential/field/exception/parse');
phutil_require_module('phabricator', 'applications/metamta/storage/mailinglist');
phutil_require_module('phabricator', 'applications/people/storage/user');
phutil_require_module('phabricator', 'applications/people/storage/userstatus');
phutil_require_module('phabricator', 'view/utils');
phutil_require_module('phutil', 'utils');

View file

@ -34,17 +34,7 @@ final class DifferentialCCsFieldSpecification
}
public function renderValueForRevisionView() {
$cc_phids = $this->getCCPHIDs();
if (!$cc_phids) {
return '<em>None</em>';
}
$links = array();
foreach ($cc_phids as $cc_phid) {
$links[] = $this->getHandle($cc_phid)->renderLink();
}
return implode(', ', $links);
return $this->renderUserList($this->getCCPHIDs());
}
private function getCCPHIDs() {

View file

@ -35,17 +35,7 @@ final class DifferentialReviewersFieldSpecification
}
public function renderValueForRevisionView() {
$reviewer_phids = $this->getReviewerPHIDs();
if (!$reviewer_phids) {
return '<em>None</em>';
}
$links = array();
foreach ($reviewer_phids as $reviewer_phid) {
$links[] = $this->getHandle($reviewer_phid)->renderLink();
}
return implode(', ', $links);
return $this->renderUserList($this->getReviewerPHIDs());
}
private function getReviewerPHIDs() {