1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-20 05:42:40 +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) { foreach ($comments as $comment) {
// TODO: Sort this out in the ID -> PHID change.
$revision_id = $comment->getRevisionID(); $revision_id = $comment->getRevisionID();
$result = array( $result = array(
'revisionID' => $revision_id, 'revisionID' => $revision_id,

View file

@ -10,14 +10,20 @@ final class DifferentialCommentPreviewController
} }
public function processRequest() { public function processRequest() {
$request = $this->getRequest(); $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'); $action = $request->getStr('action');
$comment = new DifferentialComment(); $comment = new DifferentialComment();
$comment->setContent($request->getStr('content')); $comment->setContent($request->getStr('content'));
$comment->setAction($action); $comment->setAction($action);
@ -51,6 +57,7 @@ final class DifferentialCommentPreviewController
$view->setComment($comment); $view->setComment($comment);
$view->setHandles($handles); $view->setHandles($handles);
$view->setMarkupEngine($engine); $view->setMarkupEngine($engine);
$view->setRevision($revision);
$view->setPreview(true); $view->setPreview(true);
$view->setTargetDiff(null); $view->setTargetDiff(null);

View file

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

View file

@ -9,6 +9,16 @@ final class DifferentialRevisionCommentListView extends AphrontView {
private $target; private $target;
private $versusDiffID; private $versusDiffID;
private $id; 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) { public function setComments(array $comments) {
assert_instances_of($comments, 'DifferentialComment'); assert_instances_of($comments, 'DifferentialComment');
@ -86,6 +96,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->setRevision($this->getRevision());
$view->setVersusDiffID($this->versusDiffID); $view->setVersusDiffID($this->versusDiffID);
if ($comment->getAction() == DifferentialAction::ACTION_SUMMARIZE) { if ($comment->getAction() == DifferentialAction::ACTION_SUMMARIZE) {
$view->setAnchorName('summary'); $view->setAnchorName('summary');

View file

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