mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 04:20:55 +01:00
Provide getObjectOwnerPHID() on inline comment views
Summary: This returns the PHID of the current revision owner, or the commit author, if one exists. NOTE: For drafts, we currently return `null`; I'll fix that in a future change. Should be correct for submitted comments. Test Plan: Added an inline, nothing seemed broken. Reviewers: chad Reviewed By: chad Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D12185
This commit is contained in:
parent
90ccd37a8c
commit
174cf82398
8 changed files with 50 additions and 3 deletions
|
@ -206,6 +206,7 @@ final class DifferentialChangesetViewController extends DifferentialController {
|
||||||
$revision_id = $diff->getRevisionID();
|
$revision_id = $diff->getRevisionID();
|
||||||
|
|
||||||
$can_mark = false;
|
$can_mark = false;
|
||||||
|
$object_owner_phid = null;
|
||||||
if ($revision_id) {
|
if ($revision_id) {
|
||||||
$revision = id(new DifferentialRevisionQuery())
|
$revision = id(new DifferentialRevisionQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
|
@ -213,6 +214,7 @@ final class DifferentialChangesetViewController extends DifferentialController {
|
||||||
->executeOne();
|
->executeOne();
|
||||||
if ($revision) {
|
if ($revision) {
|
||||||
$can_mark = ($revision->getAuthorPHID() == $viewer->getPHID());
|
$can_mark = ($revision->getAuthorPHID() == $viewer->getPHID());
|
||||||
|
$object_owner_phid = $revision->getAuthorPHID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,6 +223,7 @@ final class DifferentialChangesetViewController extends DifferentialController {
|
||||||
->setMarkupEngine($engine)
|
->setMarkupEngine($engine)
|
||||||
->setShowEditAndReplyLinks(true)
|
->setShowEditAndReplyLinks(true)
|
||||||
->setCanMarkDone($can_mark)
|
->setCanMarkDone($can_mark)
|
||||||
|
->setObjectOwnerPHID($object_owner_phid)
|
||||||
->setRange($range_s, $range_e)
|
->setRange($range_s, $range_e)
|
||||||
->setMask($mask);
|
->setMask($mask);
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ final class DifferentialChangesetParser {
|
||||||
private $highlightingDisabled;
|
private $highlightingDisabled;
|
||||||
private $showEditAndReplyLinks = true;
|
private $showEditAndReplyLinks = true;
|
||||||
private $canMarkDone;
|
private $canMarkDone;
|
||||||
|
private $objectOwnerPHID;
|
||||||
|
|
||||||
private $rangeStart;
|
private $rangeStart;
|
||||||
private $rangeEnd;
|
private $rangeEnd;
|
||||||
|
@ -126,6 +127,15 @@ final class DifferentialChangesetParser {
|
||||||
return $this->canMarkDone;
|
return $this->canMarkDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setObjectOwnerPHID($phid) {
|
||||||
|
$this->objectOwnerPHID = $phid;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getObjectOwnerPHID() {
|
||||||
|
return $this->objectOwnerPHID;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getDefaultRendererForViewer(PhabricatorUser $viewer) {
|
public static function getDefaultRendererForViewer(PhabricatorUser $viewer) {
|
||||||
$prefs = $viewer->loadPreferences();
|
$prefs = $viewer->loadPreferences();
|
||||||
$pref_unified = PhabricatorUserPreferences::PREFERENCE_DIFF_UNIFIED;
|
$pref_unified = PhabricatorUserPreferences::PREFERENCE_DIFF_UNIFIED;
|
||||||
|
@ -843,6 +853,7 @@ final class DifferentialChangesetParser {
|
||||||
->setOriginalCharacterEncoding($encoding)
|
->setOriginalCharacterEncoding($encoding)
|
||||||
->setShowEditAndReplyLinks($this->getShowEditAndReplyLinks())
|
->setShowEditAndReplyLinks($this->getShowEditAndReplyLinks())
|
||||||
->setCanMarkDone($this->getCanMarkDone())
|
->setCanMarkDone($this->getCanMarkDone())
|
||||||
|
->setObjectOwnerPHID($this->getObjectOwnerPHID())
|
||||||
->setHighlightingDisabled($this->highlightingDisabled);
|
->setHighlightingDisabled($this->highlightingDisabled);
|
||||||
|
|
||||||
$shield = null;
|
$shield = null;
|
||||||
|
|
|
@ -465,7 +465,8 @@ abstract class DifferentialChangesetHTMLRenderer
|
||||||
->setMarkupEngine($this->getMarkupEngine())
|
->setMarkupEngine($this->getMarkupEngine())
|
||||||
->setEditable($edit)
|
->setEditable($edit)
|
||||||
->setAllowReply($allow_reply)
|
->setAllowReply($allow_reply)
|
||||||
->setCanMarkDone($allow_done);
|
->setCanMarkDone($allow_done)
|
||||||
|
->setObjectOwnerPHID($this->getObjectOwnerPHID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ abstract class DifferentialChangesetRenderer {
|
||||||
private $originalCharacterEncoding;
|
private $originalCharacterEncoding;
|
||||||
private $showEditAndReplyLinks;
|
private $showEditAndReplyLinks;
|
||||||
private $canMarkDone;
|
private $canMarkDone;
|
||||||
|
private $objectOwnerPHID;
|
||||||
private $highlightingDisabled;
|
private $highlightingDisabled;
|
||||||
|
|
||||||
private $oldFile = false;
|
private $oldFile = false;
|
||||||
|
@ -334,6 +335,15 @@ abstract class DifferentialChangesetRenderer {
|
||||||
return $this->canMarkDone;
|
return $this->canMarkDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setObjectOwnerPHID($phid) {
|
||||||
|
$this->objectOwnerPHID = $phid;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getObjectOwnerPHID() {
|
||||||
|
return $this->objectOwnerPHID;
|
||||||
|
}
|
||||||
|
|
||||||
final public function renderChangesetTable($content) {
|
final public function renderChangesetTable($content) {
|
||||||
$props = null;
|
$props = null;
|
||||||
if ($this->shouldRenderPropertyChangeHeader()) {
|
if ($this->shouldRenderPropertyChangeHeader()) {
|
||||||
|
|
|
@ -95,6 +95,7 @@ final class DiffusionDiffController extends DiffusionController {
|
||||||
$parser->setCanMarkDone(
|
$parser->setCanMarkDone(
|
||||||
($commit->getAuthorPHID()) &&
|
($commit->getAuthorPHID()) &&
|
||||||
($viewer->getPHID() == $commit->getAuthorPHID()));
|
($viewer->getPHID() == $commit->getAuthorPHID()));
|
||||||
|
$parser->setObjectOwnerPHID($commit->getAuthorPHID());
|
||||||
|
|
||||||
$parser->setWhitespaceMode(
|
$parser->setWhitespaceMode(
|
||||||
DifferentialChangesetParser::WHITESPACE_SHOW_ALL);
|
DifferentialChangesetParser::WHITESPACE_SHOW_ALL);
|
||||||
|
|
|
@ -307,13 +307,18 @@ abstract class PhabricatorInlineCommentController
|
||||||
|
|
||||||
$handles = $this->loadViewerHandles($phids);
|
$handles = $this->loadViewerHandles($phids);
|
||||||
|
|
||||||
|
// TODO: This is not correct, but figuring it out is a little bit
|
||||||
|
// involved and it only affects drafts.
|
||||||
|
$object_owner_phid = null;
|
||||||
|
|
||||||
$view = id(new PHUIDiffInlineCommentDetailView())
|
$view = id(new PHUIDiffInlineCommentDetailView())
|
||||||
->setInlineComment($inline)
|
->setInlineComment($inline)
|
||||||
->setIsOnRight($on_right)
|
->setIsOnRight($on_right)
|
||||||
->setMarkupEngine($engine)
|
->setMarkupEngine($engine)
|
||||||
->setHandles($handles)
|
->setHandles($handles)
|
||||||
->setEditable(true)
|
->setEditable(true)
|
||||||
->setCanMarkDone(false);
|
->setCanMarkDone(false)
|
||||||
|
->setObjectOwnerPHID($object_owner_phid);
|
||||||
|
|
||||||
$view = $this->buildScaffoldForView($view);
|
$view = $this->buildScaffoldForView($view);
|
||||||
|
|
||||||
|
|
|
@ -26,13 +26,17 @@ abstract class PhabricatorInlineCommentPreviewController
|
||||||
|
|
||||||
$views = array();
|
$views = array();
|
||||||
foreach ($inlines as $inline) {
|
foreach ($inlines as $inline) {
|
||||||
|
// TODO: This is incorrect, but figuring it out is somewhat involved.
|
||||||
|
$object_owner_phid = null;
|
||||||
|
|
||||||
$view = id(new PHUIDiffInlineCommentDetailView())
|
$view = id(new PHUIDiffInlineCommentDetailView())
|
||||||
->setInlineComment($inline)
|
->setInlineComment($inline)
|
||||||
->setMarkupEngine($engine)
|
->setMarkupEngine($engine)
|
||||||
->setHandles($handles)
|
->setHandles($handles)
|
||||||
->setEditable(false)
|
->setEditable(false)
|
||||||
->setPreview(true)
|
->setPreview(true)
|
||||||
->setCanMarkDone(false);
|
->setCanMarkDone(false)
|
||||||
|
->setObjectOwnerPHID($object_owner_phid);
|
||||||
$views[] = $view->render();
|
$views[] = $view->render();
|
||||||
}
|
}
|
||||||
$views = phutil_implode_html("\n", $views);
|
$views = phutil_implode_html("\n", $views);
|
||||||
|
|
|
@ -11,6 +11,7 @@ final class PHUIDiffInlineCommentDetailView
|
||||||
private $allowReply;
|
private $allowReply;
|
||||||
private $renderer;
|
private $renderer;
|
||||||
private $canMarkDone;
|
private $canMarkDone;
|
||||||
|
private $objectOwnerPHID;
|
||||||
|
|
||||||
public function setInlineComment(PhabricatorInlineCommentInterface $comment) {
|
public function setInlineComment(PhabricatorInlineCommentInterface $comment) {
|
||||||
$this->inlineComment = $comment;
|
$this->inlineComment = $comment;
|
||||||
|
@ -61,6 +62,17 @@ final class PHUIDiffInlineCommentDetailView
|
||||||
return $this->canMarkDone;
|
return $this->canMarkDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setObjectOwnerPHID($phid) {
|
||||||
|
$this->objectOwnerPHID = $phid;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getObjectOwnerPHID() {
|
||||||
|
return $this->objectOwnerPHID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
|
|
||||||
$inline = $this->inlineComment;
|
$inline = $this->inlineComment;
|
||||||
|
|
Loading…
Reference in a new issue