diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index f9f2b9758c..9ff434381e 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -360,6 +360,7 @@ phutil_register_library_map(array( 'DiffusionHistoryTableView' => 'applications/diffusion/view/DiffusionHistoryTableView.php', 'DiffusionHomeController' => 'applications/diffusion/controller/DiffusionHomeController.php', 'DiffusionInlineCommentController' => 'applications/diffusion/controller/DiffusionInlineCommentController.php', + 'DiffusionInlineCommentPreviewController' => 'applications/diffusion/controller/DiffusionInlineCommentPreviewController.php', 'DiffusionLastModifiedController' => 'applications/diffusion/controller/DiffusionLastModifiedController.php', 'DiffusionLastModifiedQuery' => 'applications/diffusion/query/lastmodified/DiffusionLastModifiedQuery.php', 'DiffusionMercurialBranchQuery' => 'applications/diffusion/query/branch/DiffusionMercurialBranchQuery.php', @@ -721,6 +722,7 @@ phutil_register_library_map(array( 'PhabricatorInfrastructureTestCase' => 'infrastructure/__tests__/PhabricatorInfrastructureTestCase.php', 'PhabricatorInlineCommentController' => 'infrastructure/diff/PhabricatorInlineCommentController.php', 'PhabricatorInlineCommentInterface' => 'infrastructure/diff/interface/PhabricatorInlineCommentInterface.php', + 'PhabricatorInlineCommentPreviewController' => 'infrastructure/diff/PhabricatorInlineCommentPreviewController.php', 'PhabricatorInlineSummaryView' => 'infrastructure/diff/view/PhabricatorInlineSummaryView.php', 'PhabricatorJavelinLinter' => 'infrastructure/lint/linter/PhabricatorJavelinLinter.php', 'PhabricatorJumpNavHandler' => 'applications/search/engine/PhabricatorJumpNavHandler.php', @@ -1369,7 +1371,7 @@ phutil_register_library_map(array( ), 'DifferentialInlineCommentEditController' => 'PhabricatorInlineCommentController', 'DifferentialInlineCommentEditView' => 'AphrontView', - 'DifferentialInlineCommentPreviewController' => 'DifferentialController', + 'DifferentialInlineCommentPreviewController' => 'PhabricatorInlineCommentPreviewController', 'DifferentialInlineCommentView' => 'AphrontView', 'DifferentialLinesFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialLintFieldSpecification' => 'DifferentialFieldSpecification', @@ -1442,6 +1444,7 @@ phutil_register_library_map(array( 'DiffusionHistoryTableView' => 'DiffusionView', 'DiffusionHomeController' => 'DiffusionController', 'DiffusionInlineCommentController' => 'PhabricatorInlineCommentController', + 'DiffusionInlineCommentPreviewController' => 'PhabricatorInlineCommentPreviewController', 'DiffusionLastModifiedController' => 'DiffusionController', 'DiffusionLastModifiedQuery' => 'DiffusionQuery', 'DiffusionMercurialBranchQuery' => 'DiffusionBranchQuery', @@ -1753,6 +1756,7 @@ phutil_register_library_map(array( 'PhabricatorIRCWhatsNewHandler' => 'PhabricatorIRCHandler', 'PhabricatorInfrastructureTestCase' => 'PhabricatorTestCase', 'PhabricatorInlineCommentController' => 'PhabricatorController', + 'PhabricatorInlineCommentPreviewController' => 'PhabricatorController', 'PhabricatorInlineSummaryView' => 'AphrontView', 'PhabricatorJavelinLinter' => 'ArcanistLinter', 'PhabricatorLDAPLoginController' => 'PhabricatorAuthController', diff --git a/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php index 8b0b348000..ed1ac6bcb2 100644 --- a/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php +++ b/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php @@ -257,7 +257,11 @@ class AphrontDefaultApplicationConfiguration 'tags/(?P.*)' => 'DiffusionTagListController', 'branches/(?P.*)' => 'DiffusionBranchTableController', ), - 'inline/(?P[^/]+)/' => 'DiffusionInlineCommentController', + 'inline/' => array( + 'edit/(?P[^/]+)/' => 'DiffusionInlineCommentController', + 'preview/(?P[^/]+)/' => + 'DiffusionInlineCommentPreviewController', + ), 'services/' => array( 'path/' => array( 'complete/' => 'DiffusionPathCompleteController', diff --git a/src/applications/differential/controller/DifferentialInlineCommentPreviewController.php b/src/applications/differential/controller/DifferentialInlineCommentPreviewController.php index 03bb1ea64d..8ffc741202 100644 --- a/src/applications/differential/controller/DifferentialInlineCommentPreviewController.php +++ b/src/applications/differential/controller/DifferentialInlineCommentPreviewController.php @@ -17,7 +17,7 @@ */ final class DifferentialInlineCommentPreviewController - extends DifferentialController { +extends PhabricatorInlineCommentPreviewController { private $revisionID; @@ -25,41 +25,15 @@ final class DifferentialInlineCommentPreviewController $this->revisionID = $data['id']; } - public function processRequest() { - - $request = $this->getRequest(); - $user = $request->getUser(); - - // TODO: This is a reasonable approximation of the feature as it exists - // in Facebook trunk but we should probably pull filename data, sort these, - // figure out next/prev/edit/delete, deal with out-of-date inlines, etc. + protected function loadInlineComments() { + $user = $this->getRequest()->getUser(); $inlines = id(new DifferentialInlineComment())->loadAllWhere( 'authorPHID = %s AND revisionID = %d AND commentID IS NULL', $user->getPHID(), $this->revisionID); - $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine(); - - $phids = array($user->getPHID()); - $handles = id(new PhabricatorObjectHandleData($phids)) - ->loadHandles(); - - $views = array(); - foreach ($inlines as $inline) { - $view = new DifferentialInlineCommentView(); - $view->setInlineComment($inline); - $view->setMarkupEngine($engine); - $view->setHandles($handles); - $view->setEditable(false); - $view->setPreview(true); - $views[] = $view->render(); - } - $views = implode("\n", $views); - - return id(new AphrontAjaxResponse()) - ->setContent($views); + return $inlines; } - } diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php index a28f87f395..f5e15e5239 100644 --- a/src/applications/diffusion/controller/DiffusionCommitController.php +++ b/src/applications/diffusion/controller/DiffusionCommitController.php @@ -264,7 +264,7 @@ final class DiffusionCommitController extends DiffusionController { '/diffusion/'.$callsign.'/diff/?view=r'); $change_list->setInlineCommentControllerURI( - '/diffusion/inline/'.phutil_escape_uri($commit->getPHID()).'/'); + '/diffusion/inline/edit/'.phutil_escape_uri($commit->getPHID()).'/'); // TODO: This is pretty awkward, unify the CSS between Diffusion and // Differential better. @@ -580,6 +580,8 @@ final class DiffusionCommitController extends DiffusionController { 'auditors' => 'add-auditors-tokenizer', 'ccs' => 'add-ccs-tokenizer', ), + 'inline' => 'inline-comment-preview', + 'inlineuri' => '/diffusion/inline/preview/'.$commit->getPHID().'/', )); $preview_panel = @@ -589,6 +591,8 @@ final class DiffusionCommitController extends DiffusionController { Loading preview... +
+
'; return diff --git a/src/applications/diffusion/controller/DiffusionDiffController.php b/src/applications/diffusion/controller/DiffusionDiffController.php index f9f73b2d78..60ff4a8c00 100644 --- a/src/applications/diffusion/controller/DiffusionDiffController.php +++ b/src/applications/diffusion/controller/DiffusionDiffController.php @@ -65,6 +65,7 @@ final class DiffusionDiffController extends DiffusionController { } $parser = new DifferentialChangesetParser(); + $parser->setUser($user); $parser->setChangeset($changeset); $parser->setRenderingReference($diff_query->getRenderingReference()); $parser->setMarkupEngine( diff --git a/src/applications/diffusion/controller/DiffusionInlineCommentPreviewController.php b/src/applications/diffusion/controller/DiffusionInlineCommentPreviewController.php new file mode 100644 index 0000000000..ed6ecdb2e6 --- /dev/null +++ b/src/applications/diffusion/controller/DiffusionInlineCommentPreviewController.php @@ -0,0 +1,38 @@ +commitPHID = $data['phid']; + } + + protected function loadInlineComments() { + $user = $this->getRequest()->getUser(); + + $inlines = id(new PhabricatorAuditInlineComment())->loadAllWhere( + 'authorPHID = %s AND commitPHID = %s AND auditCommentID IS NULL', + $user->getPHID(), + $this->commitPHID); + + return $inlines; + } +} diff --git a/src/infrastructure/diff/PhabricatorInlineCommentPreviewController.php b/src/infrastructure/diff/PhabricatorInlineCommentPreviewController.php new file mode 100644 index 0000000000..cbbfeafe83 --- /dev/null +++ b/src/infrastructure/diff/PhabricatorInlineCommentPreviewController.php @@ -0,0 +1,51 @@ +getRequest(); + $user = $request->getUser(); + + $inlines = $this->loadInlineComments(); + assert_instances_of($inlines, 'PhabricatorInlineCommentInterface'); + $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine(); + + $phids = array($user->getPHID()); + $handles = id(new PhabricatorObjectHandleData($phids)) + ->loadHandles(); + + $views = array(); + foreach ($inlines as $inline) { + $view = new DifferentialInlineCommentView(); + $view->setInlineComment($inline); + $view->setMarkupEngine($engine); + $view->setHandles($handles); + $view->setEditable(false); + $view->setPreview(true); + $views[] = $view->render(); + } + $views = implode("\n", $views); + + return id(new AphrontAjaxResponse()) + ->setContent($views); + } +}