1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-27 16:00:59 +01:00

Link to undisplayed inline comments

Summary:
We currently don't link to comments which aren't visible. Link to the
appropriate diff in a new window, indicating where the comment lives.

Test Plan: Clicked visible, not-so-visible comments.

Reviewers: btrahan, jungejason, davidreuss

Reviewed By: btrahan

CC: aran, btrahan, epriestley

Maniphest Tasks: T555, T449

Differential Revision: https://secure.phabricator.com/D1333
This commit is contained in:
epriestley 2012-01-06 07:36:55 -08:00
parent 58f2cb2509
commit e5c0bfc8e3
4 changed files with 72 additions and 5 deletions

View file

@ -210,6 +210,7 @@ class DifferentialRevisionViewController extends DifferentialController {
$comment_view->setChangesets($all_changesets); $comment_view->setChangesets($all_changesets);
$comment_view->setUser($user); $comment_view->setUser($user);
$comment_view->setTargetDiff($target); $comment_view->setTargetDiff($target);
$comment_view->setVersusDiffID($diff_vs);
$changeset_view = new DifferentialChangesetListView(); $changeset_view = new DifferentialChangesetListView();
$changeset_view->setChangesets($visible_changesets); $changeset_view->setChangesets($visible_changesets);

View file

@ -27,6 +27,7 @@ final class DifferentialRevisionCommentView extends AphrontView {
private $target; private $target;
private $commentNumber; private $commentNumber;
private $user; private $user;
private $versusDiffID;
public function setComment($comment) { public function setComment($comment) {
$this->comment = $comment; $this->comment = $comment;
@ -61,6 +62,12 @@ final class DifferentialRevisionCommentView extends AphrontView {
public function setTargetDiff($target) { public function setTargetDiff($target) {
$this->target = $target; $this->target = $target;
return $this;
}
public function setVersusDiffID($diff_vs) {
$this->versusDiffID = $diff_vs;
return $this;
} }
public function setCommentNumber($comment_number) { public function setCommentNumber($comment_number) {
@ -181,8 +188,42 @@ final class DifferentialRevisionCommentView extends AphrontView {
($inline->getLineNumber() + $inline->getLineLength()); ($inline->getLineNumber() + $inline->getLineLength());
} }
if (!$this->target || $on_target = ($this->target) &&
$changeset->getDiffID() === $this->target->getID()) { ($this->target->getID() == $changeset->getDiffID());
$is_visible = false;
if ($inline->getIsNewFile()) {
// This comment is on the right side of the versus diff, and visible
// on the left side of the page.
if ($this->versusDiffID) {
if ($changeset->getDiffID() == $this->versusDiffID) {
$is_visible = true;
}
}
// This comment is on the right side of the target diff, and visible
// on the right side of the page.
if ($on_target) {
$is_visible = true;
}
} else {
// Ths comment is on the left side of the target diff, and visible
// on the left side of the page.
if (!$this->versusDiffID) {
if ($on_target) {
$is_visible = true;
}
}
// TODO: We still get one edge case wrong here, when we have a
// versus diff and the file didn't exist in the old version. The
// comment is visible because we show the left side of the target
// diff when there's no corresponding file in the versus diff, but
// we incorrectly link it off-page.
}
$where = null;
if ($is_visible) {
$lines = phutil_render_tag( $lines = phutil_render_tag(
'a', 'a',
array( array(
@ -190,6 +231,17 @@ final class DifferentialRevisionCommentView extends AphrontView {
'class' => 'num', 'class' => 'num',
), ),
$lines); $lines);
} else {
$diff_id = $changeset->getDiffID();
$lines = phutil_render_tag(
'a',
array(
'href' => '?id='.$diff_id.'#inline-'.$inline->getID(),
'class' => 'num',
'target' => '_blank',
),
$lines." \xE2\x86\x97");
$where = '(On Diff #'.$diff_id.')';
} }
$inline_content = $inline->getContent(); $inline_content = $inline->getContent();
@ -212,6 +264,7 @@ final class DifferentialRevisionCommentView extends AphrontView {
$inline_render[] = $inline_render[] =
'<tr>'. '<tr>'.
'<td class="inline-line-number">'.$lines.'</td>'. '<td class="inline-line-number">'.$lines.'</td>'.
'<td class="inline-which-diff">'.$where.'</td>'.
'<td>'. '<td>'.
'<div class="phabricator-remarkup">'. '<div class="phabricator-remarkup">'.
$inline_content. $inline_content.

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,6 +24,7 @@ final class DifferentialRevisionCommentListView extends AphrontView {
private $changesets; private $changesets;
private $user; private $user;
private $target; private $target;
private $versusDiffID;
public function setComments(array $comments) { public function setComments(array $comments) {
$this->comments = $comments; $this->comments = $comments;
@ -52,6 +53,12 @@ final class DifferentialRevisionCommentListView extends AphrontView {
public function setTargetDiff(DifferentialDiff $target) { public function setTargetDiff(DifferentialDiff $target) {
$this->target = $target; $this->target = $target;
return $this;
}
public function setVersusDiffID($diff_vs) {
$this->versusDiffID = $diff_vs;
return $this;
} }
public function render() { public function render() {
@ -75,6 +82,7 @@ final class DifferentialRevisionCommentListView extends AphrontView {
$view->setInlineComments(idx($inlines, $comment->getID(), array())); $view->setInlineComments(idx($inlines, $comment->getID(), array()));
$view->setChangesets($this->changesets); $view->setChangesets($this->changesets);
$view->setTargetDiff($this->target); $view->setTargetDiff($this->target);
$view->setVersusDiffID($this->versusDiffID);
$view->setCommentNumber($num++); $view->setCommentNumber($num++);
$html[] = $view->render(); $html[] = $view->render();

View file

@ -191,6 +191,11 @@
width: 70px; /* Need lots of width for 23,950-23,951 */ width: 70px; /* Need lots of width for 23,950-23,951 */
} }
.differential-inline-summary td.inline-which-diff {
padding: 0 8px 0 0;
color: #666666;
}
.differential-inline-summary td.inline-line-number a:hover { .differential-inline-summary td.inline-line-number a:hover {
background: #3b5998; background: #3b5998;
color: white; color: white;