mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-23 12:09:12 +01:00
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
This commit is contained in:
parent
9eb36db1d7
commit
d06129b81e
3 changed files with 78 additions and 35 deletions
|
@ -114,8 +114,15 @@ final class DifferentialRevisionListView extends AphrontView {
|
||||||
$list = new PhabricatorObjectItemListView();
|
$list = new PhabricatorObjectItemListView();
|
||||||
$list->setCards(true);
|
$list->setCards(true);
|
||||||
|
|
||||||
|
$do_not_display_age = array(
|
||||||
|
ArcanistDifferentialRevisionStatus::CLOSED => true,
|
||||||
|
ArcanistDifferentialRevisionStatus::ABANDONED => true,
|
||||||
|
);
|
||||||
|
|
||||||
foreach ($this->revisions as $revision) {
|
foreach ($this->revisions as $revision) {
|
||||||
$item = new PhabricatorObjectItemView();
|
$item = id(new PhabricatorObjectItemView())
|
||||||
|
->setUser($user);
|
||||||
|
|
||||||
$rev_fields = array();
|
$rev_fields = array();
|
||||||
$icons = array();
|
$icons = array();
|
||||||
|
|
||||||
|
@ -136,23 +143,21 @@ final class DifferentialRevisionListView extends AphrontView {
|
||||||
|
|
||||||
$modified = $revision->getDateModified();
|
$modified = $revision->getDateModified();
|
||||||
|
|
||||||
|
$status = $revision->getStatus();
|
||||||
|
$show_age = ($fresh || $stale) &&
|
||||||
|
$this->highlightAge &&
|
||||||
|
empty($do_not_display_age[$status]);
|
||||||
|
|
||||||
|
|
||||||
|
$object_age = PhabricatorObjectItemView::AGE_FRESH;
|
||||||
foreach ($this->fields as $field) {
|
foreach ($this->fields as $field) {
|
||||||
if (($fresh || $stale) &&
|
if ($show_age) {
|
||||||
$field instanceof DifferentialDateModifiedFieldSpecification) {
|
if ($field instanceof DifferentialDateModifiedFieldSpecification) {
|
||||||
if ($stale && $modified < $stale) {
|
if ($stale && $modified < $stale) {
|
||||||
$days = floor((time() - $modified) / 60 / 60 / 24);
|
$object_age = PhabricatorObjectItemView::AGE_OLD;
|
||||||
$icons['age'] = array(
|
|
||||||
'icon' => 'warning-grey',
|
|
||||||
'label' => pht('Old (%d days)', $days),
|
|
||||||
);
|
|
||||||
} else if ($fresh && $modified < $fresh) {
|
} else if ($fresh && $modified < $fresh) {
|
||||||
$days = floor((time() - $modified) / 60 / 60 / 24);
|
$object_age = PhabricatorObjectItemView::AGE_STALE;
|
||||||
$icons['age'] = array(
|
}
|
||||||
'icon' => 'perflab-grey',
|
|
||||||
'label' => pht('Stale (%d days)', $days),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// Fresh, noOp();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +166,6 @@ final class DifferentialRevisionListView extends AphrontView {
|
||||||
->renderValueForRevisionList($revision);
|
->renderValueForRevisionList($revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
$status = $revision->getStatus();
|
|
||||||
$status_name =
|
$status_name =
|
||||||
ArcanistDifferentialRevisionStatus::getNameForRevisionStatus($status);
|
ArcanistDifferentialRevisionStatus::getNameForRevisionStatus($status);
|
||||||
|
|
||||||
|
@ -195,22 +199,7 @@ final class DifferentialRevisionListView extends AphrontView {
|
||||||
// Reviewers
|
// Reviewers
|
||||||
$item->addAttribute(pht('Reviewers: %s', $rev_fields['Reviewers']));
|
$item->addAttribute(pht('Reviewers: %s', $rev_fields['Reviewers']));
|
||||||
|
|
||||||
$time_icon = 'none';
|
$item->setEpoch($revision->getDateModified(), $object_age);
|
||||||
$time_attr = array();
|
|
||||||
if ($this->highlightAge) {
|
|
||||||
$do_not_display_age = array(
|
|
||||||
ArcanistDifferentialRevisionStatus::CLOSED => true,
|
|
||||||
ArcanistDifferentialRevisionStatus::ABANDONED => true,
|
|
||||||
);
|
|
||||||
if (isset($icons['age']) && !isset($do_not_display_age[$status])) {
|
|
||||||
$time_icon = $icons['age']['icon'];
|
|
||||||
$time_attr = array(
|
|
||||||
'tip' => $icons['age']['label'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$item->addIcon($time_icon, $rev_fields['Updated'], $time_attr);
|
|
||||||
|
|
||||||
// First remove the fields we already have
|
// First remove the fields we already have
|
||||||
$count = 7;
|
$count = 7;
|
||||||
|
|
|
@ -667,6 +667,17 @@ abstract class PhabricatorBaseEnglishTranslation
|
||||||
'%d Open Pull Requests',
|
'%d Open Pull Requests',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
'Stale (%s day(s))' => array(
|
||||||
|
'Stale (%s day)',
|
||||||
|
'Stale (%s days)',
|
||||||
|
),
|
||||||
|
|
||||||
|
'Old (%s day(s))' => array(
|
||||||
|
'Old (%s day)',
|
||||||
|
'Old (%s days)',
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,10 @@ final class PhabricatorObjectItemView extends AphrontTagView {
|
||||||
private $headIcons = array();
|
private $headIcons = array();
|
||||||
private $disabled;
|
private $disabled;
|
||||||
|
|
||||||
|
const AGE_FRESH = 'fresh';
|
||||||
|
const AGE_STALE = 'stale';
|
||||||
|
const AGE_OLD = 'old';
|
||||||
|
|
||||||
public function setDisabled($disabled) {
|
public function setDisabled($disabled) {
|
||||||
$this->disabled = $disabled;
|
$this->disabled = $disabled;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -93,6 +97,40 @@ final class PhabricatorObjectItemView extends AphrontTagView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setEpoch($epoch, $age = self::AGE_FRESH) {
|
||||||
|
$date = phabricator_datetime($epoch, $this->getUser());
|
||||||
|
|
||||||
|
$days = floor((time() - $epoch) / 60 / 60 / 24);
|
||||||
|
|
||||||
|
switch ($age) {
|
||||||
|
case self::AGE_FRESH:
|
||||||
|
$this->addIcon('none', $date);
|
||||||
|
break;
|
||||||
|
case self::AGE_STALE:
|
||||||
|
require_celerity_resource('sprite-status-css');
|
||||||
|
$attr = array(
|
||||||
|
'tip' => pht('Stale (%s day(s))', new PhutilNumber($days)),
|
||||||
|
'class' => 'icon-age-stale',
|
||||||
|
'sheet' => PHUIIconView::SPRITE_STATUS,
|
||||||
|
);
|
||||||
|
$this->addIcon('time-yellow', $date, $attr);
|
||||||
|
break;
|
||||||
|
case self::AGE_OLD:
|
||||||
|
require_celerity_resource('sprite-status-css');
|
||||||
|
$attr = array(
|
||||||
|
'tip' => pht('Old (%s day(s))', new PhutilNumber($days)),
|
||||||
|
'class' => 'icon-age-old',
|
||||||
|
'sheet' => PHUIIconView::SPRITE_STATUS,
|
||||||
|
);
|
||||||
|
$this->addIcon('time-red', $date, $attr);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Exception("Unknown age '{$age}'!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function addAction(PHUIListItemView $action) {
|
public function addAction(PHUIListItemView $action) {
|
||||||
if (count($this->actions) >= 3) {
|
if (count($this->actions) >= 3) {
|
||||||
throw new Exception("Limit 3 actions per item.");
|
throw new Exception("Limit 3 actions per item.");
|
||||||
|
@ -261,11 +299,13 @@ final class PhabricatorObjectItemView extends AphrontTagView {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sheet = idx($spec['attributes'], 'sheet', 'icons');
|
||||||
|
|
||||||
$icon = javelin_tag(
|
$icon = javelin_tag(
|
||||||
'span',
|
'span',
|
||||||
array(
|
array(
|
||||||
'class' => 'phabricator-object-item-icon-image '.
|
'class' => 'phabricator-object-item-icon-image '.
|
||||||
'sprite-icons icons-'.$icon,
|
'sprite-'.$sheet.' '.$sheet.'-'.$icon,
|
||||||
'sigil' => $sigil,
|
'sigil' => $sigil,
|
||||||
'meta' => $meta,
|
'meta' => $meta,
|
||||||
),
|
),
|
||||||
|
@ -292,6 +332,9 @@ final class PhabricatorObjectItemView extends AphrontTagView {
|
||||||
if ($spec['icon'] == 'none') {
|
if ($spec['icon'] == 'none') {
|
||||||
$classes[] = 'phabricator-object-item-icon-none';
|
$classes[] = 'phabricator-object-item-icon-none';
|
||||||
}
|
}
|
||||||
|
if (isset($spec['attributes']['class'])) {
|
||||||
|
$classes[] = $spec['attributes']['class'];
|
||||||
|
}
|
||||||
|
|
||||||
$icon_list[] = javelin_tag(
|
$icon_list[] = javelin_tag(
|
||||||
'li',
|
'li',
|
||||||
|
|
Loading…
Add table
Reference in a new issue