1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-29 07:58:19 +01:00

Highlight update time in revision list

Summary:
This is another experiment for reducing reviewers response time.
I stole the idea (and colors) from [[ http://www.reviewboard.org/media/screenshots/2009/02/02/dashboard.png | ReviewBoard ]].
I actually quite like it (except when everything is red) and I can image that people will review just to have better color balance.

The code is not production ready for these reasons:

- We load holidays again and again for each revision. I couldn't cache it to static variable because it could persist multiple requests, right?
- I don't know how to expand height to the whole cell (I'm really bad in CSS).
- CSS rules are probably in wrong file.
- We probably want to use different colors.

This is how it looks:
{F16406}

Test Plan: Displayed revision list.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3190
This commit is contained in:
vrana 2012-08-20 14:05:46 -07:00
parent 90f5f869ae
commit b50cdc6e43
7 changed files with 110 additions and 26 deletions

View file

@ -90,6 +90,7 @@ $package_spec = array(
'differential-changeset-view-css',
'differential-results-table-css',
'differential-revision-history-css',
'differential-revision-list-css',
'differential-table-of-contents-css',
'differential-revision-comment-css',
'differential-revision-add-comment-css',

View file

@ -751,6 +751,15 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/css/application/differential/revision-history.css',
),
'differential-revision-list-css' =>
array(
'uri' => '/res/7659ad8d/rsrc/css/application/differential/revision-list.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/differential/revision-list.css',
),
'differential-table-of-contents-css' =>
array(
'uri' => '/res/0ac99a19/rsrc/css/application/differential/table-of-contents.css',
@ -2956,7 +2965,7 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/971b021e/core.pkg.js',
'type' => 'js',
),
'19ebcc79' =>
'9a22cfb9' =>
array(
'name' => 'differential.pkg.css',
'symbols' =>
@ -2965,17 +2974,18 @@ celerity_register_resource_map(array(
1 => 'differential-changeset-view-css',
2 => 'differential-results-table-css',
3 => 'differential-revision-history-css',
4 => 'differential-table-of-contents-css',
5 => 'differential-revision-comment-css',
6 => 'differential-revision-add-comment-css',
7 => 'differential-revision-comment-list-css',
8 => 'phabricator-object-selector-css',
9 => 'aphront-headsup-action-list-view-css',
10 => 'phabricator-content-source-view-css',
11 => 'differential-local-commits-view-css',
12 => 'inline-comment-summary-css',
4 => 'differential-revision-list-css',
5 => 'differential-table-of-contents-css',
6 => 'differential-revision-comment-css',
7 => 'differential-revision-add-comment-css',
8 => 'differential-revision-comment-list-css',
9 => 'phabricator-object-selector-css',
10 => 'aphront-headsup-action-list-view-css',
11 => 'phabricator-content-source-view-css',
12 => 'differential-local-commits-view-css',
13 => 'inline-comment-summary-css',
),
'uri' => '/res/pkg/19ebcc79/differential.pkg.css',
'uri' => '/res/pkg/9a22cfb9/differential.pkg.css',
'type' => 'css',
),
'ffc69a16' =>
@ -3098,7 +3108,7 @@ celerity_register_resource_map(array(
'aphront-dialog-view-css' => 'a740b991',
'aphront-error-view-css' => 'a740b991',
'aphront-form-view-css' => 'a740b991',
'aphront-headsup-action-list-view-css' => '19ebcc79',
'aphront-headsup-action-list-view-css' => '9a22cfb9',
'aphront-headsup-view-css' => 'a740b991',
'aphront-list-filter-view-css' => 'a740b991',
'aphront-pager-view-css' => 'a740b991',
@ -3108,19 +3118,20 @@ celerity_register_resource_map(array(
'aphront-tokenizer-control-css' => 'a740b991',
'aphront-tooltip-css' => 'a740b991',
'aphront-typeahead-control-css' => 'a740b991',
'differential-changeset-view-css' => '19ebcc79',
'differential-core-view-css' => '19ebcc79',
'differential-changeset-view-css' => '9a22cfb9',
'differential-core-view-css' => '9a22cfb9',
'differential-inline-comment-editor' => 'ffc69a16',
'differential-local-commits-view-css' => '19ebcc79',
'differential-results-table-css' => '19ebcc79',
'differential-revision-add-comment-css' => '19ebcc79',
'differential-revision-comment-css' => '19ebcc79',
'differential-revision-comment-list-css' => '19ebcc79',
'differential-revision-history-css' => '19ebcc79',
'differential-table-of-contents-css' => '19ebcc79',
'differential-local-commits-view-css' => '9a22cfb9',
'differential-results-table-css' => '9a22cfb9',
'differential-revision-add-comment-css' => '9a22cfb9',
'differential-revision-comment-css' => '9a22cfb9',
'differential-revision-comment-list-css' => '9a22cfb9',
'differential-revision-history-css' => '9a22cfb9',
'differential-revision-list-css' => '9a22cfb9',
'differential-table-of-contents-css' => '9a22cfb9',
'diffusion-commit-view-css' => 'c8ce2d88',
'diffusion-icons-css' => 'c8ce2d88',
'inline-comment-summary-css' => '19ebcc79',
'inline-comment-summary-css' => '9a22cfb9',
'javelin-behavior' => '6fb20113',
'javelin-behavior-aphront-basic-tokenizer' => '97f65640',
'javelin-behavior-aphront-drag-and-drop' => 'ffc69a16',
@ -3174,7 +3185,7 @@ celerity_register_resource_map(array(
'maniphest-task-summary-css' => '7839ae2d',
'maniphest-transaction-detail-css' => '7839ae2d',
'phabricator-app-buttons-css' => 'a740b991',
'phabricator-content-source-view-css' => '19ebcc79',
'phabricator-content-source-view-css' => '9a22cfb9',
'phabricator-core-buttons-css' => 'a740b991',
'phabricator-core-css' => 'a740b991',
'phabricator-directory-css' => 'a740b991',
@ -3185,7 +3196,7 @@ celerity_register_resource_map(array(
'phabricator-keyboard-shortcut' => '971b021e',
'phabricator-keyboard-shortcut-manager' => '971b021e',
'phabricator-menu-item' => '971b021e',
'phabricator-object-selector-css' => '19ebcc79',
'phabricator-object-selector-css' => '9a22cfb9',
'phabricator-paste-file-upload' => '971b021e',
'phabricator-prefab' => '971b021e',
'phabricator-project-tag-css' => '7839ae2d',

View file

@ -438,6 +438,7 @@ final class DifferentialRevisionListController extends DifferentialController {
$user_phid);
$view = id(clone $template)
->setHighlightAge(true)
->setRevisions($active);
$views[] = array(
'title' => 'Action Required',

View file

@ -25,8 +25,12 @@ final class DifferentialRevisionListView extends AphrontView {
private $handles;
private $user;
private $fields;
private $highlightAge;
const NO_DATA_STRING = 'No revisions found.';
const DAYS_FRESH = 1;
const DAYS_STALE = 3;
public function setFields(array $fields) {
assert_instances_of($fields, 'DifferentialFieldSpecification');
$this->fields = $fields;
@ -39,6 +43,11 @@ final class DifferentialRevisionListView extends AphrontView {
return $this;
}
public function setHighlightAge($bool) {
$this->highlightAge = $bool;
return $this;
}
public function getRequiredHandlePHIDs() {
$phids = array();
foreach ($this->fields as $field) {
@ -67,6 +76,15 @@ final class DifferentialRevisionListView extends AphrontView {
throw new Exception("Call setUser() before render()!");
}
if ($this->highlightAge) {
$fresh = PhabricatorCalendarHoliday::getNthBusinessDay(
time(),
-self::DAYS_FRESH);
$stale = PhabricatorCalendarHoliday::getNthBusinessDay(
time(),
-self::DAYS_STALE);
}
Javelin::initBehavior('phabricator-tooltips', array());
require_celerity_resource('aphront-tooltip-css');
@ -81,6 +99,7 @@ final class DifferentialRevisionListView extends AphrontView {
$field->setHandles($this->handles);
}
$cell_classes = array();
$rows = array();
foreach ($this->revisions as $revision) {
$phid = $revision->getPHID();
@ -104,9 +123,25 @@ final class DifferentialRevisionListView extends AphrontView {
'');
}
$row = array($flag);
$modified = $revision->getDateModified();
foreach ($this->fields as $field) {
if ($this->highlightAge &&
$field instanceof DifferentialDateModifiedFieldSpecification) {
if ($modified < $stale) {
$class = 'revision-age-old';
} else if ($modified < $fresh) {
$class = 'revision-age-stale';
} else {
$class = 'revision-age-fresh';
}
$cell_classes[count($rows)][count($row)] = $class;
}
$row[] = $field->renderValueForRevisionList($revision);
}
$rows[] = $row;
}
@ -120,9 +155,12 @@ final class DifferentialRevisionListView extends AphrontView {
$table = new AphrontTableView($rows);
$table->setHeaders($headers);
$table->setColumnClasses($classes);
$table->setCellClasses($cell_classes);
$table->setNoDataString(DifferentialRevisionListView::NO_DATA_STRING);
require_celerity_resource('differential-revision-history-css');
return $table->render();
}

View file

@ -323,6 +323,7 @@ final class PhabricatorDirectoryMainController
"View Active Revisions \xC2\xBB"));
$revision_view = id(new DifferentialRevisionListView())
->setHighlightAge(true)
->setRevisions($active)
->setFields(DifferentialRevisionListView::getDefaultFields())
->setUser($user);

View file

@ -22,6 +22,7 @@ final class AphrontTableView extends AphrontView {
protected $headers;
protected $rowClasses = array();
protected $columnClasses = array();
protected $cellClasses = array();
protected $zebraStripes = true;
protected $noDataString;
protected $className;
@ -52,6 +53,11 @@ final class AphrontTableView extends AphrontView {
return $this;
}
public function setCellClasses(array $cell_classes) {
$this->cellClasses = $cell_classes;
return $this;
}
public function setNoDataString($no_data_string) {
$this->noDataString = $no_data_string;
return $this;
@ -191,7 +197,7 @@ final class AphrontTableView extends AphrontView {
}
if ($value !== null) {
$col_classes[$key] = ' class="'.$value.'"';
$col_classes[$key] = $value;
}
}
@ -226,8 +232,11 @@ final class AphrontTableView extends AphrontView {
continue;
}
$class = $col_classes[$col_num];
if (!empty($this->cellClasses[$row_num][$col_num])) {
$class = trim($class.' '.$this->cellClasses[$row_num][$col_num]);
}
if ($class !== null) {
$table[] = '<td'.$class.'>';
$table[] = '<td class="'.$class.'">';
} else {
$table[] = '<td>';
}

View file

@ -0,0 +1,23 @@
/**
* @provides differential-revision-list-css
*/
.revision-age-fresh,
.revision-age-stale,
.revision-age-old {
margin: -4px -8px;
padding: 4px 8px;
}
.revision-age-fresh {
background: #b4e3b2;
}
.revision-age-stale {
background: #f3e782;
}
.revision-age-old {
background: #f0acac;
}