From 51c52f50fdda3f2a9c5b4223779371ee5735610e Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 31 Aug 2015 10:17:30 -0700 Subject: [PATCH] Prevent users from hiding unpublished inlines Summary: Fixes T9135. This is (probably) never intended and can be confusing. Test Plan: Saw no hide button on unpublished inlines. Saw hide button on published inlines. Clicked hide button. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9135 Differential Revision: https://secure.phabricator.com/D14014 --- .../view/PHUIDiffInlineCommentDetailView.php | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php b/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php index 80d93a7486..99ac7e1194 100644 --- a/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php +++ b/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php @@ -211,14 +211,14 @@ final class PHUIDiffInlineCommentDetailView ->addSigil('differential-inline-next') ->setMustCapture(true); - $hide = id(new PHUIButtonView()) - ->setTag('a') - ->setTooltip(pht('Hide Comment')) - ->setIconFont('fa-times') - ->addSigil('hide-inline') - ->setMustCapture(true); + if ($this->canHide()) { + $hide = id(new PHUIButtonView()) + ->setTag('a') + ->setTooltip(pht('Hide Comment')) + ->setIconFont('fa-times') + ->addSigil('hide-inline') + ->setMustCapture(true); - if ($viewer_phid && $inline->getID() && $inline->supportsHiding()) { $nextprev->addButton($hide); } @@ -456,4 +456,27 @@ final class PHUIDiffInlineCommentDetailView return $markup; } + private function canHide() { + $inline = $this->inlineComment; + + if ($inline->isDraft()) { + return false; + } + + if (!$inline->getID()) { + return false; + } + + $viewer = $this->getUser(); + if (!$viewer->isLoggedIn()) { + return false; + } + + if (!$inline->supportsHiding()) { + return false; + } + + return true; + } + }