1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 21:32:43 +01:00

Reduce reliance on getRevisionID() on DifferentialComment

Summary: Ref T2222. A few rendering interfaces rely on fishing the revision ID out of a DifferentialComment, but it will only have the PHID soon. Pass in the revision and use it to determine the ID instead.

Test Plan: Browsed, previewed, examined comments. Clicked anchors.

Reviewers: btrahan, chad

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2222

Differential Revision: https://secure.phabricator.com/D8209
This commit is contained in:
epriestley 2014-02-12 14:34:26 -08:00
parent 143b89286a
commit 3092efdc65
5 changed files with 36 additions and 6 deletions

View file

@ -53,6 +53,7 @@ final class ConduitAPI_differential_getrevisioncomments_Method
}
foreach ($comments as $comment) {
// TODO: Sort this out in the ID -> PHID change.
$revision_id = $comment->getRevisionID();
$result = array(
'revisionID' => $revision_id,

View file

@ -10,14 +10,20 @@ final class DifferentialCommentPreviewController
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$author_phid = $request->getUser()->getPHID();
$revision = id(new DifferentialRevisionQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->executeOne();
if (!$revision) {
return new Aphront404Response();
}
$author_phid = $viewer->getPHID();
$action = $request->getStr('action');
$comment = new DifferentialComment();
$comment->setContent($request->getStr('content'));
$comment->setAction($action);
@ -51,6 +57,7 @@ final class DifferentialCommentPreviewController
$view->setComment($comment);
$view->setHandles($handles);
$view->setMarkupEngine($engine);
$view->setRevision($revision);
$view->setPreview(true);
$view->setTargetDiff(null);

View file

@ -266,6 +266,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$comment_view->setUser($user);
$comment_view->setTargetDiff($target);
$comment_view->setVersusDiffID($diff_vs);
$comment_view->setRevision($revision);
if ($arc_project) {
Javelin::initBehavior(

View file

@ -9,6 +9,16 @@ final class DifferentialRevisionCommentListView extends AphrontView {
private $target;
private $versusDiffID;
private $id;
private $revision;
public function setRevision(DifferentialRevision $revision) {
$this->revision = $revision;
return $this;
}
public function getRevision() {
return $this->revision;
}
public function setComments(array $comments) {
assert_instances_of($comments, 'DifferentialComment');
@ -86,6 +96,7 @@ final class DifferentialRevisionCommentListView extends AphrontView {
$view->setInlineComments(idx($inlines, $comment->getID(), array()));
$view->setChangesets($this->changesets);
$view->setTargetDiff($this->target);
$view->setRevision($this->getRevision());
$view->setVersusDiffID($this->versusDiffID);
if ($comment->getAction() == DifferentialAction::ACTION_SUMMARIZE) {
$view->setAnchorName('summary');

View file

@ -11,6 +11,16 @@ final class DifferentialRevisionCommentView extends AphrontView {
private $target;
private $anchorName;
private $versusDiffID;
private $revision;
public function setRevision(DifferentialRevision $revision) {
$this->revision = $revision;
return $this;
}
public function getRevision() {
return $this->revision;
}
public function setComment($comment) {
$this->comment = $comment;
@ -134,7 +144,7 @@ final class DifferentialRevisionCommentView extends AphrontView {
$diff_link = phutil_tag(
'a',
array(
'href' => '/D'.$comment->getRevisionID().'?id='.$diff_id,
'href' => '/D'.$this->getRevision()->getID().'?id='.$diff_id,
),
'Diff #'.$diff_id);
$actions[] = pht(
@ -190,7 +200,7 @@ final class DifferentialRevisionCommentView extends AphrontView {
$xaction_view->setEpoch($comment->getDateCreated());
if ($this->anchorName) {
$anchor_text =
'D'.$comment->getRevisionID().
'D'.$this->getRevision()->getID().
'#'.preg_replace('/^comment-/', '', $this->anchorName);
$xaction_view->setAnchor($this->anchorName, $anchor_text);
@ -279,7 +289,7 @@ final class DifferentialRevisionCommentView extends AphrontView {
$diff_id = $changeset->getDiffID();
$item['where'] = '(On Diff #'.$diff_id.')';
$item['href'] =
'D'.$this->comment->getRevisionID().
'D'.$this->getRevision()->getID().
'?id='.$diff_id.
'#inline-'.$inline->getID();
}