mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-06 11:58:30 +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:
parent
90f5f869ae
commit
b50cdc6e43
7 changed files with 110 additions and 26 deletions
|
@ -90,6 +90,7 @@ $package_spec = array(
|
||||||
'differential-changeset-view-css',
|
'differential-changeset-view-css',
|
||||||
'differential-results-table-css',
|
'differential-results-table-css',
|
||||||
'differential-revision-history-css',
|
'differential-revision-history-css',
|
||||||
|
'differential-revision-list-css',
|
||||||
'differential-table-of-contents-css',
|
'differential-table-of-contents-css',
|
||||||
'differential-revision-comment-css',
|
'differential-revision-comment-css',
|
||||||
'differential-revision-add-comment-css',
|
'differential-revision-add-comment-css',
|
||||||
|
|
|
@ -751,6 +751,15 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'disk' => '/rsrc/css/application/differential/revision-history.css',
|
'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' =>
|
'differential-table-of-contents-css' =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/0ac99a19/rsrc/css/application/differential/table-of-contents.css',
|
'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',
|
'uri' => '/res/pkg/971b021e/core.pkg.js',
|
||||||
'type' => 'js',
|
'type' => 'js',
|
||||||
),
|
),
|
||||||
'19ebcc79' =>
|
'9a22cfb9' =>
|
||||||
array(
|
array(
|
||||||
'name' => 'differential.pkg.css',
|
'name' => 'differential.pkg.css',
|
||||||
'symbols' =>
|
'symbols' =>
|
||||||
|
@ -2965,17 +2974,18 @@ celerity_register_resource_map(array(
|
||||||
1 => 'differential-changeset-view-css',
|
1 => 'differential-changeset-view-css',
|
||||||
2 => 'differential-results-table-css',
|
2 => 'differential-results-table-css',
|
||||||
3 => 'differential-revision-history-css',
|
3 => 'differential-revision-history-css',
|
||||||
4 => 'differential-table-of-contents-css',
|
4 => 'differential-revision-list-css',
|
||||||
5 => 'differential-revision-comment-css',
|
5 => 'differential-table-of-contents-css',
|
||||||
6 => 'differential-revision-add-comment-css',
|
6 => 'differential-revision-comment-css',
|
||||||
7 => 'differential-revision-comment-list-css',
|
7 => 'differential-revision-add-comment-css',
|
||||||
8 => 'phabricator-object-selector-css',
|
8 => 'differential-revision-comment-list-css',
|
||||||
9 => 'aphront-headsup-action-list-view-css',
|
9 => 'phabricator-object-selector-css',
|
||||||
10 => 'phabricator-content-source-view-css',
|
10 => 'aphront-headsup-action-list-view-css',
|
||||||
11 => 'differential-local-commits-view-css',
|
11 => 'phabricator-content-source-view-css',
|
||||||
12 => 'inline-comment-summary-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',
|
'type' => 'css',
|
||||||
),
|
),
|
||||||
'ffc69a16' =>
|
'ffc69a16' =>
|
||||||
|
@ -3098,7 +3108,7 @@ celerity_register_resource_map(array(
|
||||||
'aphront-dialog-view-css' => 'a740b991',
|
'aphront-dialog-view-css' => 'a740b991',
|
||||||
'aphront-error-view-css' => 'a740b991',
|
'aphront-error-view-css' => 'a740b991',
|
||||||
'aphront-form-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-headsup-view-css' => 'a740b991',
|
||||||
'aphront-list-filter-view-css' => 'a740b991',
|
'aphront-list-filter-view-css' => 'a740b991',
|
||||||
'aphront-pager-view-css' => 'a740b991',
|
'aphront-pager-view-css' => 'a740b991',
|
||||||
|
@ -3108,19 +3118,20 @@ celerity_register_resource_map(array(
|
||||||
'aphront-tokenizer-control-css' => 'a740b991',
|
'aphront-tokenizer-control-css' => 'a740b991',
|
||||||
'aphront-tooltip-css' => 'a740b991',
|
'aphront-tooltip-css' => 'a740b991',
|
||||||
'aphront-typeahead-control-css' => 'a740b991',
|
'aphront-typeahead-control-css' => 'a740b991',
|
||||||
'differential-changeset-view-css' => '19ebcc79',
|
'differential-changeset-view-css' => '9a22cfb9',
|
||||||
'differential-core-view-css' => '19ebcc79',
|
'differential-core-view-css' => '9a22cfb9',
|
||||||
'differential-inline-comment-editor' => 'ffc69a16',
|
'differential-inline-comment-editor' => 'ffc69a16',
|
||||||
'differential-local-commits-view-css' => '19ebcc79',
|
'differential-local-commits-view-css' => '9a22cfb9',
|
||||||
'differential-results-table-css' => '19ebcc79',
|
'differential-results-table-css' => '9a22cfb9',
|
||||||
'differential-revision-add-comment-css' => '19ebcc79',
|
'differential-revision-add-comment-css' => '9a22cfb9',
|
||||||
'differential-revision-comment-css' => '19ebcc79',
|
'differential-revision-comment-css' => '9a22cfb9',
|
||||||
'differential-revision-comment-list-css' => '19ebcc79',
|
'differential-revision-comment-list-css' => '9a22cfb9',
|
||||||
'differential-revision-history-css' => '19ebcc79',
|
'differential-revision-history-css' => '9a22cfb9',
|
||||||
'differential-table-of-contents-css' => '19ebcc79',
|
'differential-revision-list-css' => '9a22cfb9',
|
||||||
|
'differential-table-of-contents-css' => '9a22cfb9',
|
||||||
'diffusion-commit-view-css' => 'c8ce2d88',
|
'diffusion-commit-view-css' => 'c8ce2d88',
|
||||||
'diffusion-icons-css' => 'c8ce2d88',
|
'diffusion-icons-css' => 'c8ce2d88',
|
||||||
'inline-comment-summary-css' => '19ebcc79',
|
'inline-comment-summary-css' => '9a22cfb9',
|
||||||
'javelin-behavior' => '6fb20113',
|
'javelin-behavior' => '6fb20113',
|
||||||
'javelin-behavior-aphront-basic-tokenizer' => '97f65640',
|
'javelin-behavior-aphront-basic-tokenizer' => '97f65640',
|
||||||
'javelin-behavior-aphront-drag-and-drop' => 'ffc69a16',
|
'javelin-behavior-aphront-drag-and-drop' => 'ffc69a16',
|
||||||
|
@ -3174,7 +3185,7 @@ celerity_register_resource_map(array(
|
||||||
'maniphest-task-summary-css' => '7839ae2d',
|
'maniphest-task-summary-css' => '7839ae2d',
|
||||||
'maniphest-transaction-detail-css' => '7839ae2d',
|
'maniphest-transaction-detail-css' => '7839ae2d',
|
||||||
'phabricator-app-buttons-css' => 'a740b991',
|
'phabricator-app-buttons-css' => 'a740b991',
|
||||||
'phabricator-content-source-view-css' => '19ebcc79',
|
'phabricator-content-source-view-css' => '9a22cfb9',
|
||||||
'phabricator-core-buttons-css' => 'a740b991',
|
'phabricator-core-buttons-css' => 'a740b991',
|
||||||
'phabricator-core-css' => 'a740b991',
|
'phabricator-core-css' => 'a740b991',
|
||||||
'phabricator-directory-css' => 'a740b991',
|
'phabricator-directory-css' => 'a740b991',
|
||||||
|
@ -3185,7 +3196,7 @@ celerity_register_resource_map(array(
|
||||||
'phabricator-keyboard-shortcut' => '971b021e',
|
'phabricator-keyboard-shortcut' => '971b021e',
|
||||||
'phabricator-keyboard-shortcut-manager' => '971b021e',
|
'phabricator-keyboard-shortcut-manager' => '971b021e',
|
||||||
'phabricator-menu-item' => '971b021e',
|
'phabricator-menu-item' => '971b021e',
|
||||||
'phabricator-object-selector-css' => '19ebcc79',
|
'phabricator-object-selector-css' => '9a22cfb9',
|
||||||
'phabricator-paste-file-upload' => '971b021e',
|
'phabricator-paste-file-upload' => '971b021e',
|
||||||
'phabricator-prefab' => '971b021e',
|
'phabricator-prefab' => '971b021e',
|
||||||
'phabricator-project-tag-css' => '7839ae2d',
|
'phabricator-project-tag-css' => '7839ae2d',
|
||||||
|
|
|
@ -438,6 +438,7 @@ final class DifferentialRevisionListController extends DifferentialController {
|
||||||
$user_phid);
|
$user_phid);
|
||||||
|
|
||||||
$view = id(clone $template)
|
$view = id(clone $template)
|
||||||
|
->setHighlightAge(true)
|
||||||
->setRevisions($active);
|
->setRevisions($active);
|
||||||
$views[] = array(
|
$views[] = array(
|
||||||
'title' => 'Action Required',
|
'title' => 'Action Required',
|
||||||
|
|
|
@ -25,8 +25,12 @@ final class DifferentialRevisionListView extends AphrontView {
|
||||||
private $handles;
|
private $handles;
|
||||||
private $user;
|
private $user;
|
||||||
private $fields;
|
private $fields;
|
||||||
|
private $highlightAge;
|
||||||
const NO_DATA_STRING = 'No revisions found.';
|
const NO_DATA_STRING = 'No revisions found.';
|
||||||
|
|
||||||
|
const DAYS_FRESH = 1;
|
||||||
|
const DAYS_STALE = 3;
|
||||||
|
|
||||||
public function setFields(array $fields) {
|
public function setFields(array $fields) {
|
||||||
assert_instances_of($fields, 'DifferentialFieldSpecification');
|
assert_instances_of($fields, 'DifferentialFieldSpecification');
|
||||||
$this->fields = $fields;
|
$this->fields = $fields;
|
||||||
|
@ -39,6 +43,11 @@ final class DifferentialRevisionListView extends AphrontView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setHighlightAge($bool) {
|
||||||
|
$this->highlightAge = $bool;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getRequiredHandlePHIDs() {
|
public function getRequiredHandlePHIDs() {
|
||||||
$phids = array();
|
$phids = array();
|
||||||
foreach ($this->fields as $field) {
|
foreach ($this->fields as $field) {
|
||||||
|
@ -67,6 +76,15 @@ final class DifferentialRevisionListView extends AphrontView {
|
||||||
throw new Exception("Call setUser() before render()!");
|
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());
|
Javelin::initBehavior('phabricator-tooltips', array());
|
||||||
require_celerity_resource('aphront-tooltip-css');
|
require_celerity_resource('aphront-tooltip-css');
|
||||||
|
|
||||||
|
@ -81,6 +99,7 @@ final class DifferentialRevisionListView extends AphrontView {
|
||||||
$field->setHandles($this->handles);
|
$field->setHandles($this->handles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$cell_classes = array();
|
||||||
$rows = array();
|
$rows = array();
|
||||||
foreach ($this->revisions as $revision) {
|
foreach ($this->revisions as $revision) {
|
||||||
$phid = $revision->getPHID();
|
$phid = $revision->getPHID();
|
||||||
|
@ -104,9 +123,25 @@ final class DifferentialRevisionListView extends AphrontView {
|
||||||
'');
|
'');
|
||||||
}
|
}
|
||||||
$row = array($flag);
|
$row = array($flag);
|
||||||
|
|
||||||
|
$modified = $revision->getDateModified();
|
||||||
|
|
||||||
foreach ($this->fields as $field) {
|
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);
|
$row[] = $field->renderValueForRevisionList($revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows[] = $row;
|
$rows[] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,9 +155,12 @@ final class DifferentialRevisionListView extends AphrontView {
|
||||||
$table = new AphrontTableView($rows);
|
$table = new AphrontTableView($rows);
|
||||||
$table->setHeaders($headers);
|
$table->setHeaders($headers);
|
||||||
$table->setColumnClasses($classes);
|
$table->setColumnClasses($classes);
|
||||||
|
$table->setCellClasses($cell_classes);
|
||||||
|
|
||||||
$table->setNoDataString(DifferentialRevisionListView::NO_DATA_STRING);
|
$table->setNoDataString(DifferentialRevisionListView::NO_DATA_STRING);
|
||||||
|
|
||||||
|
require_celerity_resource('differential-revision-history-css');
|
||||||
|
|
||||||
return $table->render();
|
return $table->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -323,6 +323,7 @@ final class PhabricatorDirectoryMainController
|
||||||
"View Active Revisions \xC2\xBB"));
|
"View Active Revisions \xC2\xBB"));
|
||||||
|
|
||||||
$revision_view = id(new DifferentialRevisionListView())
|
$revision_view = id(new DifferentialRevisionListView())
|
||||||
|
->setHighlightAge(true)
|
||||||
->setRevisions($active)
|
->setRevisions($active)
|
||||||
->setFields(DifferentialRevisionListView::getDefaultFields())
|
->setFields(DifferentialRevisionListView::getDefaultFields())
|
||||||
->setUser($user);
|
->setUser($user);
|
||||||
|
|
|
@ -22,6 +22,7 @@ final class AphrontTableView extends AphrontView {
|
||||||
protected $headers;
|
protected $headers;
|
||||||
protected $rowClasses = array();
|
protected $rowClasses = array();
|
||||||
protected $columnClasses = array();
|
protected $columnClasses = array();
|
||||||
|
protected $cellClasses = array();
|
||||||
protected $zebraStripes = true;
|
protected $zebraStripes = true;
|
||||||
protected $noDataString;
|
protected $noDataString;
|
||||||
protected $className;
|
protected $className;
|
||||||
|
@ -52,6 +53,11 @@ final class AphrontTableView extends AphrontView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setCellClasses(array $cell_classes) {
|
||||||
|
$this->cellClasses = $cell_classes;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function setNoDataString($no_data_string) {
|
public function setNoDataString($no_data_string) {
|
||||||
$this->noDataString = $no_data_string;
|
$this->noDataString = $no_data_string;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -191,7 +197,7 @@ final class AphrontTableView extends AphrontView {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($value !== null) {
|
if ($value !== null) {
|
||||||
$col_classes[$key] = ' class="'.$value.'"';
|
$col_classes[$key] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,8 +232,11 @@ final class AphrontTableView extends AphrontView {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$class = $col_classes[$col_num];
|
$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) {
|
if ($class !== null) {
|
||||||
$table[] = '<td'.$class.'>';
|
$table[] = '<td class="'.$class.'">';
|
||||||
} else {
|
} else {
|
||||||
$table[] = '<td>';
|
$table[] = '<td>';
|
||||||
}
|
}
|
||||||
|
|
23
webroot/rsrc/css/application/differential/revision-list.css
Normal file
23
webroot/rsrc/css/application/differential/revision-list.css
Normal 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;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue