Page MenuHomePhabricator

D16791.id40439.diff
No OneTemporary

D16791.id40439.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1687,6 +1687,7 @@
'PHUITimelineView' => 'view/phui/PHUITimelineView.php',
'PHUITwoColumnView' => 'view/phui/PHUITwoColumnView.php',
'PHUITypeaheadExample' => 'applications/uiexample/examples/PHUITypeaheadExample.php',
+ 'PHUIUserAvailabilityView' => 'applications/calendar/view/PHUIUserAvailabilityView.php',
'PHUIWorkboardView' => 'view/phui/PHUIWorkboardView.php',
'PHUIWorkpanelView' => 'view/phui/PHUIWorkpanelView.php',
'PassphraseAbstractKey' => 'applications/passphrase/keys/PassphraseAbstractKey.php',
@@ -6461,6 +6462,7 @@
'PHUITimelineView' => 'AphrontView',
'PHUITwoColumnView' => 'AphrontTagView',
'PHUITypeaheadExample' => 'PhabricatorUIExample',
+ 'PHUIUserAvailabilityView' => 'AphrontTagView',
'PHUIWorkboardView' => 'AphrontTagView',
'PHUIWorkpanelView' => 'AphrontTagView',
'PassphraseAbstractKey' => 'Phobject',
diff --git a/src/applications/calendar/view/PHUIUserAvailabilityView.php b/src/applications/calendar/view/PHUIUserAvailabilityView.php
new file mode 100644
--- /dev/null
+++ b/src/applications/calendar/view/PHUIUserAvailabilityView.php
@@ -0,0 +1,44 @@
+<?php
+
+final class PHUIUserAvailabilityView
+ extends AphrontTagView {
+
+ private $user;
+
+ public function setAvailableUser(PhabricatorUser $user) {
+ $this->user = $user;
+ return $this;
+ }
+
+ public function getAvailableUser() {
+ return $this->user;
+ }
+
+ protected function getTagContent() {
+ $viewer = $this->getViewer();
+ $user = $this->getUser();
+
+ $until = $user->getAwayUntil();
+ if (!$until) {
+ return pht('Available');
+ }
+
+ $away_tag = id(new PHUITagView())
+ ->setType(PHUITagView::TYPE_SHADE)
+ ->setShade(PHUITagView::COLOR_RED)
+ ->setName(pht('Away'))
+ ->setDotColor(PHUITagView::COLOR_RED);
+
+ $now = PhabricatorTime::getNow();
+ $description = pht(
+ 'Away until %s',
+ $viewer->formatShortDateTime($until, $now));
+
+ return array(
+ $away_tag,
+ ' ',
+ $description,
+ );
+ }
+
+}
diff --git a/src/applications/people/customfield/PhabricatorUserStatusField.php b/src/applications/people/customfield/PhabricatorUserStatusField.php
--- a/src/applications/people/customfield/PhabricatorUserStatusField.php
+++ b/src/applications/people/customfield/PhabricatorUserStatusField.php
@@ -10,7 +10,7 @@
}
public function getFieldName() {
- return pht('Status');
+ return pht('Availability');
}
public function getFieldDescription() {
@@ -29,7 +29,10 @@
public function renderPropertyViewValue(array $handles) {
$user = $this->getObject();
$viewer = $this->requireViewer();
- return $user->getAvailabilityDescription($viewer);
+
+ return id(new PHUIUserAvailabilityView())
+ ->setViewer($viewer)
+ ->setAvailableUser($user);
}
}
diff --git a/src/applications/people/storage/PhabricatorUser.php b/src/applications/people/storage/PhabricatorUser.php
--- a/src/applications/people/storage/PhabricatorUser.php
+++ b/src/applications/people/storage/PhabricatorUser.php
@@ -961,23 +961,6 @@
/**
- * Describe the user's availability.
- *
- * @param PhabricatorUser Viewing user.
- * @return string Human-readable description of away status.
- * @task availability
- */
- public function getAvailabilityDescription(PhabricatorUser $viewer) {
- $until = $this->getAwayUntil();
- if ($until) {
- return pht('Away until %s', phabricator_datetime($until, $viewer));
- } else {
- return pht('Available');
- }
- }
-
-
- /**
* Get cached availability, if present.
*
* @return wild|null Cache data, or null if no cache is available.
diff --git a/src/applications/people/view/PhabricatorUserCardView.php b/src/applications/people/view/PhabricatorUserCardView.php
--- a/src/applications/people/view/PhabricatorUserCardView.php
+++ b/src/applications/people/view/PhabricatorUserCardView.php
@@ -75,8 +75,11 @@
if (PhabricatorApplication::isClassInstalledForViewer(
'PhabricatorCalendarApplication',
$viewer)) {
- $availability = $user->getAvailabilityDescription($viewer);
- $body[] = $this->addItem(pht('Status'), $availability);
+ $body[] = $this->addItem(
+ pht('Availability'),
+ id(new PHUIUserAvailabilityView())
+ ->setViewer($viewer)
+ ->setAvailableUser($user));
}
$badges = $this->buildBadges($user, $viewer);

File Metadata

Mime Type
text/plain
Expires
Mon, Oct 21, 11:52 PM (4 w, 10 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6740234
Default Alt Text
D16791.id40439.diff (4 KB)

Event Timeline