From f1f2c5d01df1d8805c0bed033cb0f152a0a61401 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 9 Mar 2015 12:53:40 -0700 Subject: [PATCH] Reduce code duplication in inline right/left side tracking Summary: Ref T2009. These subclasses have a mixture of similar methods, move them all to the base class. Test Plan: Created/edited/undo/submitted comments on the left and right sides of a diff. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T2009 Differential Revision: https://secure.phabricator.com/D12024 --- .../render/DifferentialChangesetHTMLRenderer.php | 2 +- .../diff/PhabricatorInlineCommentController.php | 4 ++-- .../diff/view/PHUIDiffInlineCommentDetailView.php | 12 +----------- .../diff/view/PHUIDiffInlineCommentEditView.php | 10 ---------- .../diff/view/PHUIDiffInlineCommentUndoView.php | 11 ----------- .../diff/view/PHUIDiffInlineCommentView.php | 11 ++++++++++- 6 files changed, 14 insertions(+), 36 deletions(-) diff --git a/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php b/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php index 3bb11ae242..81cbfde914 100644 --- a/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php +++ b/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php @@ -438,7 +438,7 @@ abstract class DifferentialChangesetHTMLRenderer return id(new PHUIDiffInlineCommentDetailView()) ->setInlineComment($comment) - ->setOnRight($on_right) + ->setIsOnRight($on_right) ->setHandles($this->getHandles()) ->setMarkupEngine($this->getMarkupEngine()) ->setEditable($edit) diff --git a/src/infrastructure/diff/PhabricatorInlineCommentController.php b/src/infrastructure/diff/PhabricatorInlineCommentController.php index 749a66098b..a23efbc9a4 100644 --- a/src/infrastructure/diff/PhabricatorInlineCommentController.php +++ b/src/infrastructure/diff/PhabricatorInlineCommentController.php @@ -236,7 +236,7 @@ abstract class PhabricatorInlineCommentController $edit_dialog = id(new PHUIDiffInlineCommentEditView()) ->setUser($user) ->setSubmitURI($request->getRequestURI()) - ->setOnRight($this->getIsOnRight()) + ->setIsOnRight($this->getIsOnRight()) ->setIsNewFile($this->getIsNewFile()) ->setNumber($this->getLineNumber()) ->setLength($this->getLineLength()) @@ -275,7 +275,7 @@ abstract class PhabricatorInlineCommentController $view = id(new PHUIDiffInlineCommentDetailView()) ->setInlineComment($inline) - ->setOnRight($on_right) + ->setIsOnRight($on_right) ->setMarkupEngine($engine) ->setHandles($handles) ->setEditable(true); diff --git a/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php b/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php index de85a44a93..1a11fd295c 100644 --- a/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php +++ b/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php @@ -4,7 +4,6 @@ final class PHUIDiffInlineCommentDetailView extends PHUIDiffInlineCommentView { private $inlineComment; - private $onRight; private $handles; private $markupEngine; private $editable; @@ -12,20 +11,11 @@ final class PHUIDiffInlineCommentDetailView private $allowReply; private $renderer; - public function getIsOnRight() { - return $this->onRight; - } - public function setInlineComment(PhabricatorInlineCommentInterface $comment) { $this->inlineComment = $comment; return $this; } - public function setOnRight($on_right) { - $this->onRight = $on_right; - return $this; - } - public function setHandles(array $handles) { assert_instances_of($handles, 'PhabricatorObjectHandle'); $this->handles = $handles; @@ -81,7 +71,7 @@ final class PHUIDiffInlineCommentDetailView 'number' => $inline->getLineNumber(), 'length' => $inline->getLineLength(), 'isNewFile' => (bool)$inline->getIsNewFile(), - 'on_right' => $this->onRight, + 'on_right' => $this->getIsOnRight(), 'original' => $inline->getContent(), 'replyToCommentPHID' => $inline->getReplyToCommentPHID(), ); diff --git a/src/infrastructure/diff/view/PHUIDiffInlineCommentEditView.php b/src/infrastructure/diff/view/PHUIDiffInlineCommentEditView.php index da89f79079..320d18b32c 100644 --- a/src/infrastructure/diff/view/PHUIDiffInlineCommentEditView.php +++ b/src/infrastructure/diff/view/PHUIDiffInlineCommentEditView.php @@ -6,7 +6,6 @@ final class PHUIDiffInlineCommentEditView private $inputs = array(); private $uri; private $title; - private $onRight; private $number; private $length; private $renderer; @@ -23,10 +22,6 @@ final class PHUIDiffInlineCommentEditView return $this->isNewFile; } - public function getIsOnRight() { - return $this->onRight; - } - public function setRenderer($renderer) { $this->renderer = $renderer; return $this; @@ -69,11 +64,6 @@ final class PHUIDiffInlineCommentEditView return $this->changesetID; } - public function setOnRight($on_right) { - $this->onRight = $on_right; - return $this; - } - public function setNumber($number) { $this->number = $number; return $this; diff --git a/src/infrastructure/diff/view/PHUIDiffInlineCommentUndoView.php b/src/infrastructure/diff/view/PHUIDiffInlineCommentUndoView.php index 1001661341..4d398ca0ce 100644 --- a/src/infrastructure/diff/view/PHUIDiffInlineCommentUndoView.php +++ b/src/infrastructure/diff/view/PHUIDiffInlineCommentUndoView.php @@ -9,17 +9,6 @@ final class PHUIDiffInlineCommentUndoView extends PHUIDiffInlineCommentView { - private $isOnRight; - - public function setIsOnRight($is_on_right) { - $this->isOnRight = $is_on_right; - return $this; - } - - public function getIsOnRight() { - return $this->isOnRight; - } - public function render() { $link = javelin_tag( 'a', diff --git a/src/infrastructure/diff/view/PHUIDiffInlineCommentView.php b/src/infrastructure/diff/view/PHUIDiffInlineCommentView.php index 71b328ba60..63d9aa5e45 100644 --- a/src/infrastructure/diff/view/PHUIDiffInlineCommentView.php +++ b/src/infrastructure/diff/view/PHUIDiffInlineCommentView.php @@ -2,6 +2,15 @@ abstract class PHUIDiffInlineCommentView extends AphrontView { - abstract public function getIsOnRight(); + private $isOnRight; + + public function getIsOnRight() { + return $this->isOnRight; + } + + public function setIsOnRight($on_right) { + $this->isOnRight = $on_right; + return $this; + } }