From 174cf8239802d5581450429021d01cc367a8bf17 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 27 Mar 2015 11:23:10 -0700 Subject: [PATCH] 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 --- .../DifferentialChangesetViewController.php | 3 +++ .../parser/DifferentialChangesetParser.php | 11 +++++++++++ .../render/DifferentialChangesetHTMLRenderer.php | 3 ++- .../render/DifferentialChangesetRenderer.php | 10 ++++++++++ .../diffusion/controller/DiffusionDiffController.php | 1 + .../diff/PhabricatorInlineCommentController.php | 7 ++++++- .../PhabricatorInlineCommentPreviewController.php | 6 +++++- .../diff/view/PHUIDiffInlineCommentDetailView.php | 12 ++++++++++++ 8 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/applications/differential/controller/DifferentialChangesetViewController.php b/src/applications/differential/controller/DifferentialChangesetViewController.php index f8ca82b111..981688b22a 100644 --- a/src/applications/differential/controller/DifferentialChangesetViewController.php +++ b/src/applications/differential/controller/DifferentialChangesetViewController.php @@ -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); diff --git a/src/applications/differential/parser/DifferentialChangesetParser.php b/src/applications/differential/parser/DifferentialChangesetParser.php index 4c53891c36..bf1b5e3d35 100644 --- a/src/applications/differential/parser/DifferentialChangesetParser.php +++ b/src/applications/differential/parser/DifferentialChangesetParser.php @@ -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; diff --git a/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php b/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php index f8c9b5592e..0e797ef103 100644 --- a/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php +++ b/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php @@ -465,7 +465,8 @@ abstract class DifferentialChangesetHTMLRenderer ->setMarkupEngine($this->getMarkupEngine()) ->setEditable($edit) ->setAllowReply($allow_reply) - ->setCanMarkDone($allow_done); + ->setCanMarkDone($allow_done) + ->setObjectOwnerPHID($this->getObjectOwnerPHID()); } diff --git a/src/applications/differential/render/DifferentialChangesetRenderer.php b/src/applications/differential/render/DifferentialChangesetRenderer.php index 1960d4906a..22255ece7e 100644 --- a/src/applications/differential/render/DifferentialChangesetRenderer.php +++ b/src/applications/differential/render/DifferentialChangesetRenderer.php @@ -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()) { diff --git a/src/applications/diffusion/controller/DiffusionDiffController.php b/src/applications/diffusion/controller/DiffusionDiffController.php index 502c85c098..bb9354c0f9 100644 --- a/src/applications/diffusion/controller/DiffusionDiffController.php +++ b/src/applications/diffusion/controller/DiffusionDiffController.php @@ -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); diff --git a/src/infrastructure/diff/PhabricatorInlineCommentController.php b/src/infrastructure/diff/PhabricatorInlineCommentController.php index 3176a72c86..e1ce9ab254 100644 --- a/src/infrastructure/diff/PhabricatorInlineCommentController.php +++ b/src/infrastructure/diff/PhabricatorInlineCommentController.php @@ -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); diff --git a/src/infrastructure/diff/PhabricatorInlineCommentPreviewController.php b/src/infrastructure/diff/PhabricatorInlineCommentPreviewController.php index 21f8a1daa1..f26446f9e4 100644 --- a/src/infrastructure/diff/PhabricatorInlineCommentPreviewController.php +++ b/src/infrastructure/diff/PhabricatorInlineCommentPreviewController.php @@ -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); diff --git a/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php b/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php index f9edca67db..cb490390f2 100644 --- a/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php +++ b/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php @@ -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;