3 final class DifferentialRevisionUpdateHistoryView
extends AphrontView
{
5 private $diffs = array();
6 private $selectedVersusDiffID;
7 private $selectedDiffID;
8 private $commitsForLinks = array();
9 private $unitStatus = array();
11 public function setDiffs(array $diffs) {
12 assert_instances_of($diffs, 'DifferentialDiff');
13 $this->diffs
= $diffs;
17 public function setSelectedVersusDiffID($id) {
18 $this->selectedVersusDiffID
= $id;
22 public function setSelectedDiffID($id) {
23 $this->selectedDiffID
= $id;
27 public function setCommitsForLinks(array $commits) {
28 assert_instances_of($commits, 'PhabricatorRepositoryCommit');
29 $this->commitsForLinks
= $commits;
33 public function setDiffUnitStatuses(array $unit_status) {
34 $this->unitStatus
= $unit_status;
38 public function render() {
39 $this->requireResource('differential-core-view-css');
40 $this->requireResource('differential-revision-history-css');
44 'name' => pht('Base'),
46 'desc' => pht('Base'),
53 foreach ($this->diffs
as $diff) {
55 'name' => pht('Diff %d', ++
$seq),
56 'id' => $diff->getID(),
57 'desc' => $diff->getDescription(),
58 'age' => $diff->getDateCreated(),
63 $max_id = $diff->getID();
64 $revision_id = $diff->getRevisionID();
72 foreach ($data as $row) {
82 $new_checked = ($this->selectedDiffID
== $id);
89 'checked' => $new_checked ?
'checked' : null,
90 'sigil' => 'differential-new-radio',
99 'class' => 'differential-update-history-radio',
106 if ($max_id != $id) {
107 $uniq = celerity_generate_unique_node_id();
108 $old_checked = ($this->selectedVersusDiffID
== $id);
116 'checked' => $old_checked ?
'checked' : null,
117 'disabled' => $disable ?
'disabled' : null,
126 'class' => 'differential-update-history-radio',
133 $desc = $row['desc'];
136 $age = phabricator_datetime($row['age'], $this->getUser());
142 $lint = $this->newLintStatusView($diff);
143 $unit = $this->newUnitStatusView($diff);
144 $base = $this->renderBaseRevision($diff);
151 if ($last_base !== null && $base !== $last_base) {
152 // TODO: Render some kind of notice about rebases.
157 $id_link = phutil_tag(
160 'href' => '/D'.$revision_id.'?id='.$id,
164 $id_link = phutil_tag(
167 'href' => '/differential/diff/'.$id.'/',
186 $classes[] = 'differential-update-history-old-now';
189 $classes[] = 'differential-update-history-new-now';
191 $rowc[] = nonempty(implode(' ', $classes), null);
194 Javelin
::initBehavior(
195 'differential-diff-radios',
200 $table = id(new AphrontTableView($rows));
213 $table->setColumnClasses(
222 'center differential-update-history-old',
223 'center differential-update-history-new',
225 $table->setRowClasses($rowc);
226 $table->setDeviceVisibility(
239 $show_diff = phutil_tag(
242 'class' => 'differential-update-history-footer',
251 $content = phabricator_form(
254 'action' => '/D'.$revision_id.'#toc',
264 private function renderBaseRevision(DifferentialDiff
$diff) {
265 switch ($diff->getSourceControlSystem()) {
267 $base = $diff->getSourceControlBaseRevision();
268 if (strpos($base, '@') === false) {
269 $label = substr($base, 0, 7);
271 // The diff is from git-svn
272 $base = explode('@', $base);
278 $base = $diff->getSourceControlBaseRevision();
279 $base = explode('@', $base);
289 $commit_for_link = idx(
290 $this->commitsForLinks
,
291 $diff->getSourceControlBaseRevision());
292 if ($commit_for_link) {
295 array('href' => $commit_for_link->getURI()),
304 private function newLintStatusView(DifferentialDiff
$diff) {
305 $value = $diff->getLintStatus();
306 $status = DifferentialLintStatus
::newStatusFromValue($value);
308 $icon = $status->getIconIcon();
309 $color = $status->getIconColor();
310 $name = $status->getName();
312 return $this->newDiffStatusIconView($icon, $color, $name);
315 private function newUnitStatusView(DifferentialDiff
$diff) {
316 $value = $diff->getUnitStatus();
318 // NOTE: We may be overriding the value on the diff with a value from
320 $value = idx($this->unitStatus
, $diff->getPHID(), $value);
322 $status = DifferentialUnitStatus
::newStatusFromValue($value);
324 $icon = $status->getIconIcon();
325 $color = $status->getIconColor();
326 $name = $status->getName();
328 return $this->newDiffStatusIconView($icon, $color, $name);
331 private function newDiffStatusIconView($icon, $color, $name) {
332 return id(new PHUIIconView())
333 ->setIcon($icon, $color)
334 ->addSigil('has-tooltip')