From 40554e2d8aefdeb7145f7cc459a3b6a947c59986 Mon Sep 17 00:00:00 2001 From: tuomaspelkonen Date: Thu, 14 Apr 2011 17:22:57 -0700 Subject: [PATCH] Removed broken inline comment anchors. Summary: Inline comment anchros were present for all different diffs inside a revision. They were only working for the current diff. Removed the links that were for different diffs. I couldn't get the automatic linking to other diffs working, probably because the anchors didn't work when the page was reloaded. This is also a bit confusing if the diff changes when clicking on anchor. We might want to carry all the comments along in the future, but I don't think it's needed at the moment. Test Plan: Tested on a revision, which had inline comments for differerent diffs that only the comments for the latest diff had anchors when the page was loaded. Changed the diff manually on the page and made sure the anchors for that diff were working correctly and the anchors for the latest diff were not available. Reviewed By: epriestley Reviewers: epriestley CC: jungejason, epriestley Differential Revision: 142 --- .../DifferentialCommentPreviewController.php | 1 + .../DifferentialRevisionViewController.php | 1 + .../DifferentialRevisionCommentView.php | 22 +++++++++++++------ .../DifferentialRevisionCommentListView.php | 6 +++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/applications/differential/controller/commentpreview/DifferentialCommentPreviewController.php b/src/applications/differential/controller/commentpreview/DifferentialCommentPreviewController.php index 138e45af1e..96b04844ab 100644 --- a/src/applications/differential/controller/commentpreview/DifferentialCommentPreviewController.php +++ b/src/applications/differential/controller/commentpreview/DifferentialCommentPreviewController.php @@ -46,6 +46,7 @@ class DifferentialCommentPreviewController extends DifferentialController { $view->setHandles($handles); $view->setMarkupEngine($engine); $view->setPreview(true); + $view->setTargetDiff(null); $draft = new PhabricatorDraft(); $draft diff --git a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php index 4f4778375c..4ca1045f4a 100644 --- a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php @@ -167,6 +167,7 @@ class DifferentialRevisionViewController extends DifferentialController { $comment_view->setInlineComments($inlines); $comment_view->setChangesets($all_changesets); $comment_view->setUser($user); + $comment_view->setTargetDiff($target); $diff_history = new DifferentialRevisionUpdateHistoryView(); $diff_history->setDiffs($diffs); diff --git a/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php b/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php index 1d0691d1f9..f037912c05 100644 --- a/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php +++ b/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php @@ -24,6 +24,7 @@ final class DifferentialRevisionCommentView extends AphrontView { private $preview; private $inlines; private $changesets; + private $target; public function setComment($comment) { $this->comment = $comment; @@ -56,6 +57,10 @@ final class DifferentialRevisionCommentView extends AphrontView { return $this; } + public function setTargetDiff($target) { + $this->target = $target; + } + public function render() { require_celerity_resource('phabricator-remarkup-css'); @@ -130,13 +135,16 @@ final class DifferentialRevisionCommentView extends AphrontView { ($inline->getLineNumber() + $inline->getLineLength()); } - $lines = phutil_render_tag( - 'a', - array( - 'href' => '#inline-'.$inline->getID(), - 'class' => 'num', - ), - $lines); + if (!$this->target || + $changeset->getDiffID() === $this->target->getID()) { + $lines = phutil_render_tag( + 'a', + array( + 'href' => '#inline-'.$inline->getID(), + 'class' => 'num', + ), + $lines); + } $inline_content = $inline->getContent(); if (strlen($inline_content)) { diff --git a/src/applications/differential/view/revisioncommentlist/DifferentialRevisionCommentListView.php b/src/applications/differential/view/revisioncommentlist/DifferentialRevisionCommentListView.php index 6c167e362e..de1ded72a2 100644 --- a/src/applications/differential/view/revisioncommentlist/DifferentialRevisionCommentListView.php +++ b/src/applications/differential/view/revisioncommentlist/DifferentialRevisionCommentListView.php @@ -23,6 +23,7 @@ final class DifferentialRevisionCommentListView extends AphrontView { private $inlines; private $changesets; private $user; + private $target; public function setComments(array $comments) { $this->comments = $comments; @@ -49,6 +50,10 @@ final class DifferentialRevisionCommentListView extends AphrontView { return $this; } + public function setTargetDiff(DifferentialDiff $target) { + $this->target = $target; + } + public function render() { require_celerity_resource('differential-revision-comment-list-css'); @@ -67,6 +72,7 @@ final class DifferentialRevisionCommentListView extends AphrontView { $view->setMarkupEngine($engine); $view->setInlineComments(idx($inlines, $comment->getID(), array())); $view->setChangesets($this->changesets); + $view->setTargetDiff($this->target); $html[] = $view->render(); }