2011-01-27 23:55:52 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialRevisionUpdateHistoryView extends AphrontView {
|
|
|
|
|
|
|
|
private $diffs = array();
|
2011-02-03 22:20:43 +01:00
|
|
|
private $selectedVersusDiffID;
|
|
|
|
private $selectedDiffID;
|
2011-04-18 22:38:54 +02:00
|
|
|
private $selectedWhitespace;
|
2011-01-27 23:55:52 +01:00
|
|
|
|
2012-05-22 02:55:35 +02:00
|
|
|
public function setDiffs(array $diffs) {
|
|
|
|
assert_instances_of($diffs, 'DifferentialDiff');
|
2011-01-27 23:55:52 +01:00
|
|
|
$this->diffs = $diffs;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2011-02-03 22:20:43 +01:00
|
|
|
public function setSelectedVersusDiffID($id) {
|
|
|
|
$this->selectedVersusDiffID = $id;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setSelectedDiffID($id) {
|
|
|
|
$this->selectedDiffID = $id;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2011-04-18 22:38:54 +02:00
|
|
|
public function setSelectedWhitespace($whitespace) {
|
|
|
|
$this->selectedWhitespace = $whitespace;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2011-01-27 23:55:52 +01:00
|
|
|
public function render() {
|
|
|
|
|
2014-01-02 20:59:35 +01:00
|
|
|
$this->requireResource('differential-core-view-css');
|
|
|
|
$this->requireResource('differential-revision-history-css');
|
2011-01-27 23:55:52 +01:00
|
|
|
|
|
|
|
$data = array(
|
|
|
|
array(
|
|
|
|
'name' => 'Base',
|
|
|
|
'id' => null,
|
|
|
|
'desc' => 'Base',
|
|
|
|
'age' => null,
|
2011-02-05 02:53:14 +01:00
|
|
|
'obj' => null,
|
2011-01-27 23:55:52 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
$seq = 0;
|
|
|
|
foreach ($this->diffs as $diff) {
|
|
|
|
$data[] = array(
|
|
|
|
'name' => 'Diff '.(++$seq),
|
|
|
|
'id' => $diff->getID(),
|
2011-02-05 02:53:14 +01:00
|
|
|
'desc' => $diff->getDescription(),
|
2011-01-27 23:55:52 +01:00
|
|
|
'age' => $diff->getDateCreated(),
|
2011-02-05 02:53:14 +01:00
|
|
|
'obj' => $diff,
|
2011-01-27 23:55:52 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-02-03 22:20:43 +01:00
|
|
|
$max_id = $diff->getID();
|
|
|
|
|
2011-01-27 23:55:52 +01:00
|
|
|
$idx = 0;
|
|
|
|
$rows = array();
|
2011-02-04 00:41:58 +01:00
|
|
|
$disable = false;
|
|
|
|
$radios = array();
|
2011-07-17 03:44:48 +02:00
|
|
|
$last_base = null;
|
2011-01-27 23:55:52 +01:00
|
|
|
foreach ($data as $row) {
|
|
|
|
|
2012-01-31 21:07:41 +01:00
|
|
|
$diff = $row['obj'];
|
2012-02-06 19:55:55 +01:00
|
|
|
$name = $row['name'];
|
|
|
|
$id = $row['id'];
|
2011-01-27 23:55:52 +01:00
|
|
|
|
2011-02-03 22:20:43 +01:00
|
|
|
$old_class = null;
|
|
|
|
$new_class = null;
|
|
|
|
|
2011-02-04 00:41:58 +01:00
|
|
|
if ($id) {
|
|
|
|
$new_checked = ($this->selectedDiffID == $id);
|
2013-01-25 21:57:17 +01:00
|
|
|
$new = javelin_tag(
|
2011-02-04 00:41:58 +01:00
|
|
|
'input',
|
|
|
|
array(
|
|
|
|
'type' => 'radio',
|
|
|
|
'name' => 'id',
|
|
|
|
'value' => $id,
|
|
|
|
'checked' => $new_checked ? 'checked' : null,
|
|
|
|
'sigil' => 'differential-new-radio',
|
|
|
|
));
|
|
|
|
if ($new_checked) {
|
|
|
|
$new_class = " revhistory-new-now";
|
|
|
|
$disable = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$new = null;
|
|
|
|
}
|
|
|
|
|
2011-02-03 22:20:43 +01:00
|
|
|
if ($max_id != $id) {
|
|
|
|
$uniq = celerity_generate_unique_node_id();
|
|
|
|
$old_checked = ($this->selectedVersusDiffID == $id);
|
2013-01-18 03:39:02 +01:00
|
|
|
$old = phutil_tag(
|
2011-02-03 22:20:43 +01:00
|
|
|
'input',
|
|
|
|
array(
|
|
|
|
'type' => 'radio',
|
|
|
|
'name' => 'vs',
|
2011-02-04 00:41:58 +01:00
|
|
|
'value' => $id,
|
2011-02-03 22:20:43 +01:00
|
|
|
'id' => $uniq,
|
|
|
|
'checked' => $old_checked ? 'checked' : null,
|
2011-02-04 00:41:58 +01:00
|
|
|
'disabled' => $disable ? 'disabled' : null,
|
2011-02-03 22:20:43 +01:00
|
|
|
));
|
|
|
|
$radios[] = $uniq;
|
|
|
|
if ($old_checked) {
|
|
|
|
$old_class = " revhistory-old-now";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$old = null;
|
|
|
|
}
|
|
|
|
|
2011-07-17 03:44:48 +02:00
|
|
|
$desc = $row['desc'];
|
|
|
|
|
2011-02-05 02:53:14 +01:00
|
|
|
if ($row['age']) {
|
2011-12-04 01:36:19 +01:00
|
|
|
$age = phabricator_datetime($row['age'], $this->getUser());
|
2011-02-05 02:53:14 +01:00
|
|
|
} else {
|
|
|
|
$age = null;
|
|
|
|
}
|
2011-01-27 23:55:52 +01:00
|
|
|
|
|
|
|
if (++$idx % 2) {
|
2013-02-08 21:07:44 +01:00
|
|
|
$class = 'alt';
|
2011-01-27 23:55:52 +01:00
|
|
|
} else {
|
|
|
|
$class = null;
|
|
|
|
}
|
|
|
|
|
2013-02-08 21:07:44 +01:00
|
|
|
$lint_attrs = array('class' => 'revhistory-star');
|
|
|
|
$unit_attrs = array('class' => 'revhistory-star');
|
2012-01-31 21:07:41 +01:00
|
|
|
if ($diff) {
|
2011-02-05 02:53:14 +01:00
|
|
|
$lint = self::renderDiffLintStar($row['obj']);
|
|
|
|
$unit = self::renderDiffUnitStar($row['obj']);
|
2013-02-08 21:07:44 +01:00
|
|
|
$lint_attrs['title'] = self::getDiffLintMessage($diff);
|
|
|
|
$unit_attrs['title'] = self::getDiffUnitMessage($diff);
|
2012-01-31 21:07:41 +01:00
|
|
|
$base = $this->renderBaseRevision($diff);
|
2011-02-05 02:53:14 +01:00
|
|
|
} else {
|
|
|
|
$lint = null;
|
|
|
|
$unit = null;
|
2012-01-31 21:07:41 +01:00
|
|
|
$base = null;
|
2011-02-05 02:53:14 +01:00
|
|
|
}
|
|
|
|
|
2011-07-17 03:44:48 +02:00
|
|
|
if ($last_base !== null && $base !== $last_base) {
|
|
|
|
// TODO: Render some kind of notice about rebases.
|
|
|
|
}
|
|
|
|
$last_base = $base;
|
|
|
|
|
2013-01-18 03:43:35 +01:00
|
|
|
$id_link = phutil_tag(
|
2012-11-16 20:48:17 +01:00
|
|
|
'a',
|
|
|
|
array('href' => '/differential/diff/'.$id.'/'),
|
2013-01-18 03:43:35 +01:00
|
|
|
$id);
|
2013-02-08 21:07:44 +01:00
|
|
|
$rows[] = phutil_tag(
|
|
|
|
'tr',
|
|
|
|
array('class' => $class),
|
|
|
|
array(
|
|
|
|
phutil_tag('td', array('class' => 'revhistory-name'), $name),
|
|
|
|
phutil_tag('td', array('class' => 'revhistory-id'), $id_link),
|
|
|
|
phutil_tag('td', array('class' => 'revhistory-base'), $base),
|
|
|
|
phutil_tag('td', array('class' => 'revhistory-desc'), $desc),
|
|
|
|
phutil_tag('td', array('class' => 'revhistory-age'), $age),
|
|
|
|
phutil_tag('td', $lint_attrs, $lint),
|
|
|
|
phutil_tag('td', $unit_attrs, $unit),
|
|
|
|
phutil_tag('td', array('class' => 'revhistory-old'.$old_class), $old),
|
|
|
|
phutil_tag('td', array('class' => 'revhistory-new'.$new_class), $new),
|
|
|
|
));
|
2011-01-27 23:55:52 +01:00
|
|
|
}
|
|
|
|
|
2011-07-17 03:44:48 +02:00
|
|
|
Javelin::initBehavior(
|
|
|
|
'differential-diff-radios',
|
|
|
|
array(
|
|
|
|
'radios' => $radios,
|
|
|
|
));
|
2011-02-04 00:41:58 +01:00
|
|
|
|
2011-07-17 03:44:48 +02:00
|
|
|
$options = array(
|
2012-03-13 01:06:36 +01:00
|
|
|
DifferentialChangesetParser::WHITESPACE_IGNORE_FORCE => 'Ignore All',
|
2012-02-06 20:13:45 +01:00
|
|
|
DifferentialChangesetParser::WHITESPACE_IGNORE_ALL => 'Ignore Most',
|
|
|
|
DifferentialChangesetParser::WHITESPACE_IGNORE_TRAILING =>
|
|
|
|
'Ignore Trailing',
|
|
|
|
DifferentialChangesetParser::WHITESPACE_SHOW_ALL => 'Show All',
|
2011-07-17 03:44:48 +02:00
|
|
|
);
|
2011-04-18 22:38:54 +02:00
|
|
|
|
2011-07-17 03:44:48 +02:00
|
|
|
foreach ($options as $value => $label) {
|
2013-02-13 23:50:15 +01:00
|
|
|
$options[$value] = phutil_tag(
|
2011-07-17 03:44:48 +02:00
|
|
|
'option',
|
|
|
|
array(
|
|
|
|
'value' => $value,
|
|
|
|
'selected' => ($value == $this->selectedWhitespace)
|
|
|
|
? 'selected'
|
|
|
|
: null,
|
|
|
|
),
|
2013-01-18 03:43:35 +01:00
|
|
|
$label);
|
2011-07-17 03:44:48 +02:00
|
|
|
}
|
2013-02-13 23:50:15 +01:00
|
|
|
$select = phutil_tag('select', array('name' => 'whitespace'), $options);
|
|
|
|
|
|
|
|
array_unshift($rows, phutil_tag('tr', array(), array(
|
|
|
|
phutil_tag('th', array(), pht('Diff')),
|
|
|
|
phutil_tag('th', array(), pht('ID')),
|
|
|
|
phutil_tag('th', array(), pht('Base')),
|
|
|
|
phutil_tag('th', array(), pht('Description')),
|
|
|
|
phutil_tag('th', array(), pht('Created')),
|
|
|
|
phutil_tag('th', array(), pht('Lint')),
|
|
|
|
phutil_tag('th', array(), pht('Unit')),
|
|
|
|
)));
|
|
|
|
|
2013-11-11 18:23:23 +01:00
|
|
|
$label = pht('Whitespace Changes: %s', $select);
|
|
|
|
|
|
|
|
$content = phutil_tag_div(
|
|
|
|
'differential-revision-history differential-panel',
|
|
|
|
phutil_tag(
|
|
|
|
'form',
|
|
|
|
array('action' => '#toc'),
|
|
|
|
phutil_tag(
|
|
|
|
'table',
|
|
|
|
array('class' => 'differential-revision-history-table'), array(
|
|
|
|
phutil_implode_html("\n", $rows),
|
|
|
|
phutil_tag('tr', array(), phutil_tag(
|
|
|
|
'td',
|
|
|
|
array('colspan' => 9, 'class' => 'diff-differ-submit'),
|
|
|
|
array(
|
|
|
|
phutil_tag('label', array(), $label),
|
|
|
|
phutil_tag('button', array(), pht('Show Diff')),
|
|
|
|
)))
|
|
|
|
))));
|
2013-09-29 00:55:38 +02:00
|
|
|
|
|
|
|
return id(new PHUIObjectBoxView())
|
Provide more structure to PHUIObjectBoxView
Summary:
Three changes here.
- Add `setActionList()`, and use that to set the action list.
- Add `setPropertyList()`, and use that to set the property list.
These will let us add some apropriate CSS so we can fix the border issue, and get rid of a bunch of goofy `.x + .y` selectors.
- Replace `addContent()` with `appendChild()`.
This is just a consistency thing; `AphrontView` already provides `appendChild()`, and `addContent()` did the same thing.
Test Plan:
- Viewed "All Config".
- Viewed a countdown.
- Viewed a revision (add comment, change list, table of contents, comment, local commits, open revisions affecting these files, update history).
- Viewed Diffusion (browse, change, history, repository, lint).
- Viewed Drydock (resource, lease).
- Viewed Files.
- Viewed Herald.
- Viewed Legalpad.
- Viewed macro (edit, edit audio, view).
- Viewed Maniphest.
- Viewed Applications.
- Viewed Paste.
- Viewed People.
- Viewed Phulux.
- Viewed Pholio.
- Viewed Phame (blog, post).
- Viewed Phortune (account, product).
- Viewed Ponder (questions, answers, comments).
- Viewed Releeph.
- Viewed Projects.
- Viewed Slowvote.
NOTE: Images in Files aren't on a black background anymore -- I assume that's on purpose?
NOTE: Some jankiness in Phortune, I'll clean that up when I get back to it. Not related to this diff.
Reviewers: chad
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D7174
2013-09-30 18:36:04 +02:00
|
|
|
->setHeaderText(pht('Revision Update History'))
|
2014-02-14 06:02:19 +01:00
|
|
|
->setFlush(true)
|
Provide more structure to PHUIObjectBoxView
Summary:
Three changes here.
- Add `setActionList()`, and use that to set the action list.
- Add `setPropertyList()`, and use that to set the property list.
These will let us add some apropriate CSS so we can fix the border issue, and get rid of a bunch of goofy `.x + .y` selectors.
- Replace `addContent()` with `appendChild()`.
This is just a consistency thing; `AphrontView` already provides `appendChild()`, and `addContent()` did the same thing.
Test Plan:
- Viewed "All Config".
- Viewed a countdown.
- Viewed a revision (add comment, change list, table of contents, comment, local commits, open revisions affecting these files, update history).
- Viewed Diffusion (browse, change, history, repository, lint).
- Viewed Drydock (resource, lease).
- Viewed Files.
- Viewed Herald.
- Viewed Legalpad.
- Viewed macro (edit, edit audio, view).
- Viewed Maniphest.
- Viewed Applications.
- Viewed Paste.
- Viewed People.
- Viewed Phulux.
- Viewed Pholio.
- Viewed Phame (blog, post).
- Viewed Phortune (account, product).
- Viewed Ponder (questions, answers, comments).
- Viewed Releeph.
- Viewed Projects.
- Viewed Slowvote.
NOTE: Images in Files aren't on a black background anymore -- I assume that's on purpose?
NOTE: Some jankiness in Phortune, I'll clean that up when I get back to it. Not related to this diff.
Reviewers: chad
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D7174
2013-09-30 18:36:04 +02:00
|
|
|
->appendChild($content);
|
2011-01-27 23:55:52 +01:00
|
|
|
}
|
2011-02-05 02:53:14 +01:00
|
|
|
|
|
|
|
const STAR_NONE = 'none';
|
|
|
|
const STAR_OKAY = 'okay';
|
|
|
|
const STAR_WARN = 'warn';
|
|
|
|
const STAR_FAIL = 'fail';
|
|
|
|
const STAR_SKIP = 'skip';
|
|
|
|
|
|
|
|
public static function renderDiffLintStar(DifferentialDiff $diff) {
|
|
|
|
static $map = array(
|
|
|
|
DifferentialLintStatus::LINT_NONE => self::STAR_NONE,
|
|
|
|
DifferentialLintStatus::LINT_OKAY => self::STAR_OKAY,
|
|
|
|
DifferentialLintStatus::LINT_WARN => self::STAR_WARN,
|
|
|
|
DifferentialLintStatus::LINT_FAIL => self::STAR_FAIL,
|
|
|
|
DifferentialLintStatus::LINT_SKIP => self::STAR_SKIP,
|
2012-06-15 02:09:24 +02:00
|
|
|
DifferentialLintStatus::LINT_POSTPONED => self::STAR_SKIP
|
2011-02-05 02:53:14 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$star = idx($map, $diff->getLintStatus(), self::STAR_FAIL);
|
|
|
|
|
|
|
|
return self::renderDiffStar($star);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function renderDiffUnitStar(DifferentialDiff $diff) {
|
|
|
|
static $map = array(
|
|
|
|
DifferentialUnitStatus::UNIT_NONE => self::STAR_NONE,
|
|
|
|
DifferentialUnitStatus::UNIT_OKAY => self::STAR_OKAY,
|
|
|
|
DifferentialUnitStatus::UNIT_WARN => self::STAR_WARN,
|
|
|
|
DifferentialUnitStatus::UNIT_FAIL => self::STAR_FAIL,
|
|
|
|
DifferentialUnitStatus::UNIT_SKIP => self::STAR_SKIP,
|
2011-06-09 01:16:59 +02:00
|
|
|
DifferentialUnitStatus::UNIT_POSTPONED => self::STAR_SKIP,
|
2011-02-05 02:53:14 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$star = idx($map, $diff->getUnitStatus(), self::STAR_FAIL);
|
|
|
|
|
|
|
|
return self::renderDiffStar($star);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getDiffLintMessage(DifferentialDiff $diff) {
|
|
|
|
switch ($diff->getLintStatus()) {
|
|
|
|
case DifferentialLintStatus::LINT_NONE:
|
|
|
|
return 'No Linters Available';
|
|
|
|
case DifferentialLintStatus::LINT_OKAY:
|
|
|
|
return 'Lint OK';
|
|
|
|
case DifferentialLintStatus::LINT_WARN:
|
|
|
|
return 'Lint Warnings';
|
|
|
|
case DifferentialLintStatus::LINT_FAIL:
|
|
|
|
return 'Lint Errors';
|
|
|
|
case DifferentialLintStatus::LINT_SKIP:
|
|
|
|
return 'Lint Skipped';
|
2012-06-15 02:09:24 +02:00
|
|
|
case DifferentialLintStatus::LINT_POSTPONED:
|
|
|
|
return 'Lint Postponed';
|
2011-02-05 02:53:14 +01:00
|
|
|
}
|
|
|
|
return '???';
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getDiffUnitMessage(DifferentialDiff $diff) {
|
|
|
|
switch ($diff->getUnitStatus()) {
|
|
|
|
case DifferentialUnitStatus::UNIT_NONE:
|
|
|
|
return 'No Unit Test Coverage';
|
|
|
|
case DifferentialUnitStatus::UNIT_OKAY:
|
|
|
|
return 'Unit Tests OK';
|
|
|
|
case DifferentialUnitStatus::UNIT_WARN:
|
|
|
|
return 'Unit Test Warnings';
|
|
|
|
case DifferentialUnitStatus::UNIT_FAIL:
|
|
|
|
return 'Unit Test Errors';
|
|
|
|
case DifferentialUnitStatus::UNIT_SKIP:
|
|
|
|
return 'Unit Tests Skipped';
|
2011-06-09 01:16:59 +02:00
|
|
|
case DifferentialUnitStatus::UNIT_POSTPONED:
|
|
|
|
return 'Unit Tests Postponed';
|
2011-02-05 02:53:14 +01:00
|
|
|
}
|
|
|
|
return '???';
|
|
|
|
}
|
|
|
|
|
|
|
|
private static function renderDiffStar($star) {
|
|
|
|
$class = 'diff-star-'.$star;
|
2013-02-06 00:14:18 +01:00
|
|
|
return phutil_tag(
|
|
|
|
'span',
|
|
|
|
array('class' => $class),
|
|
|
|
"\xE2\x98\x85");
|
2011-02-05 02:53:14 +01:00
|
|
|
}
|
|
|
|
|
2011-07-17 03:44:48 +02:00
|
|
|
private function renderBaseRevision(DifferentialDiff $diff) {
|
|
|
|
switch ($diff->getSourceControlSystem()) {
|
|
|
|
case 'git':
|
2012-01-08 10:39:35 +01:00
|
|
|
$base = $diff->getSourceControlBaseRevision();
|
|
|
|
if (strpos($base, '@') === false) {
|
|
|
|
return substr($base, 0, 7);
|
|
|
|
} else {
|
|
|
|
// The diff is from git-svn
|
|
|
|
$base = explode('@', $base);
|
|
|
|
$base = last($base);
|
|
|
|
return $base;
|
|
|
|
}
|
2011-07-17 03:44:48 +02:00
|
|
|
case 'svn':
|
|
|
|
$base = $diff->getSourceControlBaseRevision();
|
|
|
|
$base = explode('@', $base);
|
2012-01-08 10:39:35 +01:00
|
|
|
$base = last($base);
|
2011-07-17 03:44:48 +02:00
|
|
|
return $base;
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2011-01-27 23:55:52 +01:00
|
|
|
}
|