From 3e3f73235c4cd73daa2a6ceeab1df506386a0d8b Mon Sep 17 00:00:00 2001 From: vrana Date: Tue, 7 Feb 2012 14:36:17 -0800 Subject: [PATCH] Break all old differential comment anchors Test Plan: Display revision, verify text, click on links. Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Maniphest Tasks: T845 Differential Revision: https://secure.phabricator.com/D1591 --- .../DifferentialRevisionCommentView.php | 13 ++++++------- .../DifferentialRevisionCommentListView.php | 9 ++++++++- .../view/revisioncommentlist/__init__.php | 1 + .../ManiphestTransactionDetailView.php | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php b/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php index 559d7b1bfa..1a32f2585d 100644 --- a/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php +++ b/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php @@ -25,7 +25,7 @@ final class DifferentialRevisionCommentView extends AphrontView { private $inlines; private $changesets; private $target; - private $commentNumber; + private $anchorName; private $user; private $versusDiffID; @@ -70,8 +70,8 @@ final class DifferentialRevisionCommentView extends AphrontView { return $this; } - public function setCommentNumber($comment_number) { - $this->commentNumber = $comment_number; + public function setAnchorName($anchor_name) { + $this->anchorName = $anchor_name; return $this; } @@ -111,10 +111,9 @@ final class DifferentialRevisionCommentView extends AphrontView { $info[] = $date; $comment_anchor = null; - $num = $this->commentNumber; - if ($num && !$this->preview) { + $anchor_name = $this->anchorName; + if ($anchor_name != '' && !$this->preview) { Javelin::initBehavior('phabricator-watch-anchor'); - $anchor_name = 'comment-'.$num; $info[] = phutil_render_tag( 'a', array( @@ -122,7 +121,7 @@ final class DifferentialRevisionCommentView extends AphrontView { 'id' => $anchor_name, 'href' => '#'.$anchor_name, ), - 'Comment D'.$comment->getRevisionID().'#'.$num); + 'D'.$comment->getRevisionID().'#'.$anchor_name); $comment_anchor = 'anchor-'.$anchor_name; } diff --git a/src/applications/differential/view/revisioncommentlist/DifferentialRevisionCommentListView.php b/src/applications/differential/view/revisioncommentlist/DifferentialRevisionCommentListView.php index 7cd331ce06..ece96a750d 100644 --- a/src/applications/differential/view/revisioncommentlist/DifferentialRevisionCommentListView.php +++ b/src/applications/differential/view/revisioncommentlist/DifferentialRevisionCommentListView.php @@ -83,7 +83,14 @@ final class DifferentialRevisionCommentListView extends AphrontView { $view->setChangesets($this->changesets); $view->setTargetDiff($this->target); $view->setVersusDiffID($this->versusDiffID); - $view->setCommentNumber($num++); + if ($comment->getAction() == DifferentialAction::ACTION_SUMMARIZE) { + $view->setAnchorName('summary'); + } elseif ($comment->getAction() == DifferentialAction::ACTION_TESTPLAN) { + $view->setAnchorName('test-plan'); + } else { + $view->setAnchorName('comment-'.$num); + $num++; + } $html[] = $view->render(); } diff --git a/src/applications/differential/view/revisioncommentlist/__init__.php b/src/applications/differential/view/revisioncommentlist/__init__.php index c92b2aa36f..e8f99eaf92 100644 --- a/src/applications/differential/view/revisioncommentlist/__init__.php +++ b/src/applications/differential/view/revisioncommentlist/__init__.php @@ -6,6 +6,7 @@ +phutil_require_module('phabricator', 'applications/differential/constants/action'); phutil_require_module('phabricator', 'applications/differential/view/revisioncomment'); phutil_require_module('phabricator', 'applications/markup/engine'); phutil_require_module('phabricator', 'infrastructure/celerity/api'); diff --git a/src/applications/maniphest/view/transactiondetail/ManiphestTransactionDetailView.php b/src/applications/maniphest/view/transactiondetail/ManiphestTransactionDetailView.php index 195b9baaaa..37c8a66b5b 100644 --- a/src/applications/maniphest/view/transactiondetail/ManiphestTransactionDetailView.php +++ b/src/applications/maniphest/view/transactiondetail/ManiphestTransactionDetailView.php @@ -233,7 +233,7 @@ class ManiphestTransactionDetailView extends ManiphestView { 'id' => $anchor_name, 'href' => '#'.$anchor_name, ), - 'Comment T'.$any_transaction->getTaskID().'#'.$num); + 'T'.$any_transaction->getTaskID().'#'.$anchor_name); $comment_anchor = 'anchor-'.$anchor_name; }