mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 20:10: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();
|
||||
|
||||
$can_mark = false;
|
||||
$object_owner_phid = null;
|
||||
if ($revision_id) {
|
||||
$revision = id(new DifferentialRevisionQuery())
|
||||
->setViewer($viewer)
|
||||
|
@ -213,6 +214,7 @@ final class DifferentialChangesetViewController extends DifferentialController {
|
|||
->executeOne();
|
||||
if ($revision) {
|
||||
$can_mark = ($revision->getAuthorPHID() == $viewer->getPHID());
|
||||
$object_owner_phid = $revision->getAuthorPHID();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,6 +223,7 @@ final class DifferentialChangesetViewController extends DifferentialController {
|
|||
->setMarkupEngine($engine)
|
||||
->setShowEditAndReplyLinks(true)
|
||||
->setCanMarkDone($can_mark)
|
||||
->setObjectOwnerPHID($object_owner_phid)
|
||||
->setRange($range_s, $range_e)
|
||||
->setMask($mask);
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ final class DifferentialChangesetParser {
|
|||
private $highlightingDisabled;
|
||||
private $showEditAndReplyLinks = true;
|
||||
private $canMarkDone;
|
||||
private $objectOwnerPHID;
|
||||
|
||||
private $rangeStart;
|
||||
private $rangeEnd;
|
||||
|
@ -126,6 +127,15 @@ final class DifferentialChangesetParser {
|
|||
return $this->canMarkDone;
|
||||
}
|
||||
|
||||
public function setObjectOwnerPHID($phid) {
|
||||
$this->objectOwnerPHID = $phid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getObjectOwnerPHID() {
|
||||
return $this->objectOwnerPHID;
|
||||
}
|
||||
|
||||
public static function getDefaultRendererForViewer(PhabricatorUser $viewer) {
|
||||
$prefs = $viewer->loadPreferences();
|
||||
$pref_unified = PhabricatorUserPreferences::PREFERENCE_DIFF_UNIFIED;
|
||||
|
@ -843,6 +853,7 @@ final class DifferentialChangesetParser {
|
|||
->setOriginalCharacterEncoding($encoding)
|
||||
->setShowEditAndReplyLinks($this->getShowEditAndReplyLinks())
|
||||
->setCanMarkDone($this->getCanMarkDone())
|
||||
->setObjectOwnerPHID($this->getObjectOwnerPHID())
|
||||
->setHighlightingDisabled($this->highlightingDisabled);
|
||||
|
||||
$shield = null;
|
||||
|
|
|
@ -465,7 +465,8 @@ abstract class DifferentialChangesetHTMLRenderer
|
|||
->setMarkupEngine($this->getMarkupEngine())
|
||||
->setEditable($edit)
|
||||
->setAllowReply($allow_reply)
|
||||
->setCanMarkDone($allow_done);
|
||||
->setCanMarkDone($allow_done)
|
||||
->setObjectOwnerPHID($this->getObjectOwnerPHID());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ abstract class DifferentialChangesetRenderer {
|
|||
private $originalCharacterEncoding;
|
||||
private $showEditAndReplyLinks;
|
||||
private $canMarkDone;
|
||||
private $objectOwnerPHID;
|
||||
private $highlightingDisabled;
|
||||
|
||||
private $oldFile = false;
|
||||
|
@ -334,6 +335,15 @@ abstract class DifferentialChangesetRenderer {
|
|||
return $this->canMarkDone;
|
||||
}
|
||||
|
||||
public function setObjectOwnerPHID($phid) {
|
||||
$this->objectOwnerPHID = $phid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getObjectOwnerPHID() {
|
||||
return $this->objectOwnerPHID;
|
||||
}
|
||||
|
||||
final public function renderChangesetTable($content) {
|
||||
$props = null;
|
||||
if ($this->shouldRenderPropertyChangeHeader()) {
|
||||
|
|
|
@ -95,6 +95,7 @@ final class DiffusionDiffController extends DiffusionController {
|
|||
$parser->setCanMarkDone(
|
||||
($commit->getAuthorPHID()) &&
|
||||
($viewer->getPHID() == $commit->getAuthorPHID()));
|
||||
$parser->setObjectOwnerPHID($commit->getAuthorPHID());
|
||||
|
||||
$parser->setWhitespaceMode(
|
||||
DifferentialChangesetParser::WHITESPACE_SHOW_ALL);
|
||||
|
|
|
@ -307,13 +307,18 @@ abstract class PhabricatorInlineCommentController
|
|||
|
||||
$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())
|
||||
->setInlineComment($inline)
|
||||
->setIsOnRight($on_right)
|
||||
->setMarkupEngine($engine)
|
||||
->setHandles($handles)
|
||||
->setEditable(true)
|
||||
->setCanMarkDone(false);
|
||||
->setCanMarkDone(false)
|
||||
->setObjectOwnerPHID($object_owner_phid);
|
||||
|
||||
$view = $this->buildScaffoldForView($view);
|
||||
|
||||
|
|
|
@ -26,13 +26,17 @@ abstract class PhabricatorInlineCommentPreviewController
|
|||
|
||||
$views = array();
|
||||
foreach ($inlines as $inline) {
|
||||
// TODO: This is incorrect, but figuring it out is somewhat involved.
|
||||
$object_owner_phid = null;
|
||||
|
||||
$view = id(new PHUIDiffInlineCommentDetailView())
|
||||
->setInlineComment($inline)
|
||||
->setMarkupEngine($engine)
|
||||
->setHandles($handles)
|
||||
->setEditable(false)
|
||||
->setPreview(true)
|
||||
->setCanMarkDone(false);
|
||||
->setCanMarkDone(false)
|
||||
->setObjectOwnerPHID($object_owner_phid);
|
||||
$views[] = $view->render();
|
||||
}
|
||||
$views = phutil_implode_html("\n", $views);
|
||||
|
|
|
@ -11,6 +11,7 @@ final class PHUIDiffInlineCommentDetailView
|
|||
private $allowReply;
|
||||
private $renderer;
|
||||
private $canMarkDone;
|
||||
private $objectOwnerPHID;
|
||||
|
||||
public function setInlineComment(PhabricatorInlineCommentInterface $comment) {
|
||||
$this->inlineComment = $comment;
|
||||
|
@ -61,6 +62,17 @@ final class PHUIDiffInlineCommentDetailView
|
|||
return $this->canMarkDone;
|
||||
}
|
||||
|
||||
public function setObjectOwnerPHID($phid) {
|
||||
$this->objectOwnerPHID = $phid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getObjectOwnerPHID() {
|
||||
return $this->objectOwnerPHID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function render() {
|
||||
|
||||
$inline = $this->inlineComment;
|
||||
|
|
Loading…
Reference in a new issue