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

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
This commit is contained in:
epriestley 2015-03-09 12:53:40 -07:00
parent 9b9a8001fa
commit f1f2c5d01d
6 changed files with 14 additions and 36 deletions

View file

@ -438,7 +438,7 @@ abstract class DifferentialChangesetHTMLRenderer
return id(new PHUIDiffInlineCommentDetailView()) return id(new PHUIDiffInlineCommentDetailView())
->setInlineComment($comment) ->setInlineComment($comment)
->setOnRight($on_right) ->setIsOnRight($on_right)
->setHandles($this->getHandles()) ->setHandles($this->getHandles())
->setMarkupEngine($this->getMarkupEngine()) ->setMarkupEngine($this->getMarkupEngine())
->setEditable($edit) ->setEditable($edit)

View file

@ -236,7 +236,7 @@ abstract class PhabricatorInlineCommentController
$edit_dialog = id(new PHUIDiffInlineCommentEditView()) $edit_dialog = id(new PHUIDiffInlineCommentEditView())
->setUser($user) ->setUser($user)
->setSubmitURI($request->getRequestURI()) ->setSubmitURI($request->getRequestURI())
->setOnRight($this->getIsOnRight()) ->setIsOnRight($this->getIsOnRight())
->setIsNewFile($this->getIsNewFile()) ->setIsNewFile($this->getIsNewFile())
->setNumber($this->getLineNumber()) ->setNumber($this->getLineNumber())
->setLength($this->getLineLength()) ->setLength($this->getLineLength())
@ -275,7 +275,7 @@ abstract class PhabricatorInlineCommentController
$view = id(new PHUIDiffInlineCommentDetailView()) $view = id(new PHUIDiffInlineCommentDetailView())
->setInlineComment($inline) ->setInlineComment($inline)
->setOnRight($on_right) ->setIsOnRight($on_right)
->setMarkupEngine($engine) ->setMarkupEngine($engine)
->setHandles($handles) ->setHandles($handles)
->setEditable(true); ->setEditable(true);

View file

@ -4,7 +4,6 @@ final class PHUIDiffInlineCommentDetailView
extends PHUIDiffInlineCommentView { extends PHUIDiffInlineCommentView {
private $inlineComment; private $inlineComment;
private $onRight;
private $handles; private $handles;
private $markupEngine; private $markupEngine;
private $editable; private $editable;
@ -12,20 +11,11 @@ final class PHUIDiffInlineCommentDetailView
private $allowReply; private $allowReply;
private $renderer; private $renderer;
public function getIsOnRight() {
return $this->onRight;
}
public function setInlineComment(PhabricatorInlineCommentInterface $comment) { public function setInlineComment(PhabricatorInlineCommentInterface $comment) {
$this->inlineComment = $comment; $this->inlineComment = $comment;
return $this; return $this;
} }
public function setOnRight($on_right) {
$this->onRight = $on_right;
return $this;
}
public function setHandles(array $handles) { public function setHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle'); assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles; $this->handles = $handles;
@ -81,7 +71,7 @@ final class PHUIDiffInlineCommentDetailView
'number' => $inline->getLineNumber(), 'number' => $inline->getLineNumber(),
'length' => $inline->getLineLength(), 'length' => $inline->getLineLength(),
'isNewFile' => (bool)$inline->getIsNewFile(), 'isNewFile' => (bool)$inline->getIsNewFile(),
'on_right' => $this->onRight, 'on_right' => $this->getIsOnRight(),
'original' => $inline->getContent(), 'original' => $inline->getContent(),
'replyToCommentPHID' => $inline->getReplyToCommentPHID(), 'replyToCommentPHID' => $inline->getReplyToCommentPHID(),
); );

View file

@ -6,7 +6,6 @@ final class PHUIDiffInlineCommentEditView
private $inputs = array(); private $inputs = array();
private $uri; private $uri;
private $title; private $title;
private $onRight;
private $number; private $number;
private $length; private $length;
private $renderer; private $renderer;
@ -23,10 +22,6 @@ final class PHUIDiffInlineCommentEditView
return $this->isNewFile; return $this->isNewFile;
} }
public function getIsOnRight() {
return $this->onRight;
}
public function setRenderer($renderer) { public function setRenderer($renderer) {
$this->renderer = $renderer; $this->renderer = $renderer;
return $this; return $this;
@ -69,11 +64,6 @@ final class PHUIDiffInlineCommentEditView
return $this->changesetID; return $this->changesetID;
} }
public function setOnRight($on_right) {
$this->onRight = $on_right;
return $this;
}
public function setNumber($number) { public function setNumber($number) {
$this->number = $number; $this->number = $number;
return $this; return $this;

View file

@ -9,17 +9,6 @@
final class PHUIDiffInlineCommentUndoView final class PHUIDiffInlineCommentUndoView
extends PHUIDiffInlineCommentView { 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() { public function render() {
$link = javelin_tag( $link = javelin_tag(
'a', 'a',

View file

@ -2,6 +2,15 @@
abstract class PHUIDiffInlineCommentView extends AphrontView { 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;
}
} }