@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add setEpoch() and onboard staleness to ObjectItemListView

Summary: Fixes T3486. I don't love how this looks -- maybe we could try different icons? Like white icons on a brighter red/yellow background?

Test Plan: {F56299}

Reviewers: chad, btrahan

Reviewed By: chad

CC: aran

Maniphest Tasks: T3486

Differential Revision: https://secure.phabricator.com/D6833

+78 -35
+23 -34
src/applications/differential/view/DifferentialRevisionListView.php
··· 114 114 $list = new PhabricatorObjectItemListView(); 115 115 $list->setCards(true); 116 116 117 + $do_not_display_age = array( 118 + ArcanistDifferentialRevisionStatus::CLOSED => true, 119 + ArcanistDifferentialRevisionStatus::ABANDONED => true, 120 + ); 121 + 117 122 foreach ($this->revisions as $revision) { 118 - $item = new PhabricatorObjectItemView(); 123 + $item = id(new PhabricatorObjectItemView()) 124 + ->setUser($user); 125 + 119 126 $rev_fields = array(); 120 127 $icons = array(); 121 128 ··· 136 143 137 144 $modified = $revision->getDateModified(); 138 145 146 + $status = $revision->getStatus(); 147 + $show_age = ($fresh || $stale) && 148 + $this->highlightAge && 149 + empty($do_not_display_age[$status]); 150 + 151 + 152 + $object_age = PhabricatorObjectItemView::AGE_FRESH; 139 153 foreach ($this->fields as $field) { 140 - if (($fresh || $stale) && 141 - $field instanceof DifferentialDateModifiedFieldSpecification) { 142 - if ($stale && $modified < $stale) { 143 - $days = floor((time() - $modified) / 60 / 60 / 24); 144 - $icons['age'] = array( 145 - 'icon' => 'warning-grey', 146 - 'label' => pht('Old (%d days)', $days), 147 - ); 148 - } else if ($fresh && $modified < $fresh) { 149 - $days = floor((time() - $modified) / 60 / 60 / 24); 150 - $icons['age'] = array( 151 - 'icon' => 'perflab-grey', 152 - 'label' => pht('Stale (%d days)', $days), 153 - ); 154 - } else { 155 - // Fresh, noOp(); 154 + if ($show_age) { 155 + if ($field instanceof DifferentialDateModifiedFieldSpecification) { 156 + if ($stale && $modified < $stale) { 157 + $object_age = PhabricatorObjectItemView::AGE_OLD; 158 + } else if ($fresh && $modified < $fresh) { 159 + $object_age = PhabricatorObjectItemView::AGE_STALE; 160 + } 156 161 } 157 162 } 158 163 ··· 161 166 ->renderValueForRevisionList($revision); 162 167 } 163 168 164 - $status = $revision->getStatus(); 165 169 $status_name = 166 170 ArcanistDifferentialRevisionStatus::getNameForRevisionStatus($status); 167 171 ··· 195 199 // Reviewers 196 200 $item->addAttribute(pht('Reviewers: %s', $rev_fields['Reviewers'])); 197 201 198 - $time_icon = 'none'; 199 - $time_attr = array(); 200 - if ($this->highlightAge) { 201 - $do_not_display_age = array( 202 - ArcanistDifferentialRevisionStatus::CLOSED => true, 203 - ArcanistDifferentialRevisionStatus::ABANDONED => true, 204 - ); 205 - if (isset($icons['age']) && !isset($do_not_display_age[$status])) { 206 - $time_icon = $icons['age']['icon']; 207 - $time_attr = array( 208 - 'tip' => $icons['age']['label'], 209 - ); 210 - } 211 - } 212 - 213 - $item->addIcon($time_icon, $rev_fields['Updated'], $time_attr); 202 + $item->setEpoch($revision->getDateModified(), $object_age); 214 203 215 204 // First remove the fields we already have 216 205 $count = 7;
+11
src/infrastructure/internationalization/PhabricatorBaseEnglishTranslation.php
··· 667 667 '%d Open Pull Requests', 668 668 ), 669 669 670 + 'Stale (%s day(s))' => array( 671 + 'Stale (%s day)', 672 + 'Stale (%s days)', 673 + ), 674 + 675 + 'Old (%s day(s))' => array( 676 + 'Old (%s day)', 677 + 'Old (%s days)', 678 + ), 679 + 680 + 670 681 ); 671 682 } 672 683
+44 -1
src/view/layout/PhabricatorObjectItemView.php
··· 19 19 private $headIcons = array(); 20 20 private $disabled; 21 21 22 + const AGE_FRESH = 'fresh'; 23 + const AGE_STALE = 'stale'; 24 + const AGE_OLD = 'old'; 25 + 22 26 public function setDisabled($disabled) { 23 27 $this->disabled = $disabled; 24 28 return $this; ··· 90 94 91 95 public function addByline($byline) { 92 96 $this->bylines[] = $byline; 97 + return $this; 98 + } 99 + 100 + public function setEpoch($epoch, $age = self::AGE_FRESH) { 101 + $date = phabricator_datetime($epoch, $this->getUser()); 102 + 103 + $days = floor((time() - $epoch) / 60 / 60 / 24); 104 + 105 + switch ($age) { 106 + case self::AGE_FRESH: 107 + $this->addIcon('none', $date); 108 + break; 109 + case self::AGE_STALE: 110 + require_celerity_resource('sprite-status-css'); 111 + $attr = array( 112 + 'tip' => pht('Stale (%s day(s))', new PhutilNumber($days)), 113 + 'class' => 'icon-age-stale', 114 + 'sheet' => PHUIIconView::SPRITE_STATUS, 115 + ); 116 + $this->addIcon('time-yellow', $date, $attr); 117 + break; 118 + case self::AGE_OLD: 119 + require_celerity_resource('sprite-status-css'); 120 + $attr = array( 121 + 'tip' => pht('Old (%s day(s))', new PhutilNumber($days)), 122 + 'class' => 'icon-age-old', 123 + 'sheet' => PHUIIconView::SPRITE_STATUS, 124 + ); 125 + $this->addIcon('time-red', $date, $attr); 126 + break; 127 + default: 128 + throw new Exception("Unknown age '{$age}'!"); 129 + } 130 + 93 131 return $this; 94 132 } 95 133 ··· 261 299 ); 262 300 } 263 301 302 + $sheet = idx($spec['attributes'], 'sheet', 'icons'); 303 + 264 304 $icon = javelin_tag( 265 305 'span', 266 306 array( 267 307 'class' => 'phabricator-object-item-icon-image '. 268 - 'sprite-icons icons-'.$icon, 308 + 'sprite-'.$sheet.' '.$sheet.'-'.$icon, 269 309 'sigil' => $sigil, 270 310 'meta' => $meta, 271 311 ), ··· 291 331 $classes[] = 'phabricator-object-item-icon'; 292 332 if ($spec['icon'] == 'none') { 293 333 $classes[] = 'phabricator-object-item-icon-none'; 334 + } 335 + if (isset($spec['attributes']['class'])) { 336 + $classes[] = $spec['attributes']['class']; 294 337 } 295 338 296 339 $icon_list[] = javelin_tag(