1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 10:12:41 +01:00

Inline comment-related fixes.

This commit is contained in:
epriestley 2011-02-02 19:38:43 -08:00
parent 223ac18287
commit 4aa72aa5ff
27 changed files with 368 additions and 51 deletions

View file

@ -100,7 +100,7 @@ celerity_register_resource_map(array(
), ),
'differential-revision-add-comment-css' => 'differential-revision-add-comment-css' =>
array( array(
'uri' => '/res/623fef21/rsrc/css/application/differential/add-comment.css', 'uri' => '/res/d7f8719e/rsrc/css/application/differential/add-comment.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(
@ -109,7 +109,7 @@ celerity_register_resource_map(array(
), ),
'differential-changeset-view-css' => 'differential-changeset-view-css' =>
array( array(
'uri' => '/res/11e7232a/rsrc/css/application/differential/changeset-view.css', 'uri' => '/res/4e0295a9/rsrc/css/application/differential/changeset-view.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(
@ -136,7 +136,7 @@ celerity_register_resource_map(array(
), ),
'differential-revision-comment-css' => 'differential-revision-comment-css' =>
array( array(
'uri' => '/res/bf6369c6/rsrc/css/application/differential/revision-comment.css', 'uri' => '/res/368bd612/rsrc/css/application/differential/revision-comment.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(
@ -245,7 +245,7 @@ celerity_register_resource_map(array(
), ),
'javelin-behavior-differential-feedback-preview' => 'javelin-behavior-differential-feedback-preview' =>
array( array(
'uri' => '/res/34fbb670/rsrc/js/application/differential/behavior-comment-preview.js', 'uri' => '/res/8695d8b8/rsrc/js/application/differential/behavior-comment-preview.js',
'type' => 'js', 'type' => 'js',
'requires' => 'requires' =>
array( array(
@ -255,7 +255,7 @@ celerity_register_resource_map(array(
), ),
'javelin-behavior-differential-edit-inline-comments' => 'javelin-behavior-differential-edit-inline-comments' =>
array( array(
'uri' => '/res/f5b54891/rsrc/js/application/differential/behavior-edit-inline-comments.js', 'uri' => '/res/74747b2e/rsrc/js/application/differential/behavior-edit-inline-comments.js',
'type' => 'js', 'type' => 'js',
'requires' => 'requires' =>
array( array(
@ -275,7 +275,7 @@ celerity_register_resource_map(array(
), ),
'javelin-behavior-differential-show-more' => 'javelin-behavior-differential-show-more' =>
array( array(
'uri' => '/res/d26ebcae/rsrc/js/application/differential/behavior-show-more.js', 'uri' => '/res/ea998002/rsrc/js/application/differential/behavior-show-more.js',
'type' => 'js', 'type' => 'js',
'requires' => 'requires' =>
array( array(
@ -303,7 +303,7 @@ celerity_register_resource_map(array(
), ),
'javelin-lib-dev' => 'javelin-lib-dev' =>
array( array(
'uri' => '/res/53784c9a/rsrc/js/javelin/javelin.dev.js', 'uri' => '/res/a0e7a5e9/rsrc/js/javelin/javelin.dev.js',
'type' => 'js', 'type' => 'js',
'requires' => 'requires' =>
array( array(
@ -378,7 +378,7 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/c5efa388/core.pkg.css', 'uri' => '/res/pkg/c5efa388/core.pkg.css',
'type' => 'css', 'type' => 'css',
), ),
'f399aad7' => '9d9c881c' =>
array ( array (
'name' => 'differential.pkg.css', 'name' => 'differential.pkg.css',
'symbols' => 'symbols' =>
@ -389,7 +389,7 @@ celerity_register_resource_map(array(
3 => 'differential-revision-history-css', 3 => 'differential-revision-history-css',
4 => 'differential-table-of-contents-css', 4 => 'differential-table-of-contents-css',
), ),
'uri' => '/res/pkg/f399aad7/differential.pkg.css', 'uri' => '/res/pkg/9d9c881c/differential.pkg.css',
'type' => 'css', 'type' => 'css',
), ),
), ),
@ -406,10 +406,10 @@ celerity_register_resource_map(array(
'aphront-tokenizer-control-css' => 'c5efa388', 'aphront-tokenizer-control-css' => 'c5efa388',
'aphront-typeahead-control-css' => 'c5efa388', 'aphront-typeahead-control-css' => 'c5efa388',
'phabricator-directory-css' => 'c5efa388', 'phabricator-directory-css' => 'c5efa388',
'differential-core-view-css' => 'f399aad7', 'differential-core-view-css' => '9d9c881c',
'differential-changeset-view-css' => 'f399aad7', 'differential-changeset-view-css' => '9d9c881c',
'differential-revision-detail-css' => 'f399aad7', 'differential-revision-detail-css' => '9d9c881c',
'differential-revision-history-css' => 'f399aad7', 'differential-revision-history-css' => '9d9c881c',
'differential-table-of-contents-css' => 'f399aad7', 'differential-table-of-contents-css' => '9d9c881c',
), ),
)); ));

View file

@ -101,6 +101,7 @@ phutil_register_library_map(array(
'DifferentialHunk' => 'applications/differential/storage/hunk', 'DifferentialHunk' => 'applications/differential/storage/hunk',
'DifferentialInlineComment' => 'applications/differential/storage/inlinecomment', 'DifferentialInlineComment' => 'applications/differential/storage/inlinecomment',
'DifferentialInlineCommentEditController' => 'applications/differential/controller/inlinecommentedit', 'DifferentialInlineCommentEditController' => 'applications/differential/controller/inlinecommentedit',
'DifferentialInlineCommentPreviewController' => 'applications/differential/controller/inlinecommentpreview',
'DifferentialInlineCommentView' => 'applications/differential/view/inlinecomment', 'DifferentialInlineCommentView' => 'applications/differential/view/inlinecomment',
'DifferentialLintStatus' => 'applications/differential/constants/lintstatus', 'DifferentialLintStatus' => 'applications/differential/constants/lintstatus',
'DifferentialMail' => 'applications/differential/mail/base', 'DifferentialMail' => 'applications/differential/mail/base',
@ -287,6 +288,7 @@ phutil_register_library_map(array(
'DifferentialHunk' => 'DifferentialDAO', 'DifferentialHunk' => 'DifferentialDAO',
'DifferentialInlineComment' => 'DifferentialDAO', 'DifferentialInlineComment' => 'DifferentialDAO',
'DifferentialInlineCommentEditController' => 'DifferentialController', 'DifferentialInlineCommentEditController' => 'DifferentialController',
'DifferentialInlineCommentPreviewController' => 'DifferentialController',
'DifferentialInlineCommentView' => 'AphrontView', 'DifferentialInlineCommentView' => 'AphrontView',
'DifferentialNewDiffMail' => 'DifferentialReviewRequestMail', 'DifferentialNewDiffMail' => 'DifferentialReviewRequestMail',
'DifferentialReviewRequestMail' => 'DifferentialMail', 'DifferentialReviewRequestMail' => 'DifferentialMail',

View file

@ -90,7 +90,8 @@ class AphrontDefaultApplicationConfiguration
'preview/(?<id>\d+)/$' => 'DifferentialCommentPreviewController', 'preview/(?<id>\d+)/$' => 'DifferentialCommentPreviewController',
'save/$' => 'DifferentialCommentSaveController', 'save/$' => 'DifferentialCommentSaveController',
'inline/' => array( 'inline/' => array(
'preview/$' => 'DifferentialInlineCommentPreviewController', 'preview/(?<id>\d+)/$' =>
'DifferentialInlineCommentPreviewController',
'edit/(?<id>\d+)/$' => 'DifferentialInlineCommentEditController', 'edit/(?<id>\d+)/$' => 'DifferentialInlineCommentEditController',
), ),
), ),

View file

@ -88,6 +88,7 @@ class DifferentialInlineCommentEditController extends DifferentialController {
if ($request->isFormPost()) { if ($request->isFormPost()) {
if (strlen($text)) { if (strlen($text)) {
$inline->setContent($text); $inline->setContent($text);
$inline->setCache(null);
$inline->save(); $inline->save();
return $this->buildRenderedCommentResponse( return $this->buildRenderedCommentResponse(
$inline, $inline,

View file

@ -0,0 +1,65 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class DifferentialInlineCommentPreviewController
extends DifferentialController {
private $revisionID;
public function willProcessRequest(array $data) {
$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.
$inlines = id(new DifferentialInlineComment())->loadAllWhere(
'authorPHID = %s AND revisionID = %d AND commentID IS NULL',
$user->getPHID(),
$this->revisionID);
$factory = new DifferentialMarkupEngineFactory();
$engine = $factory->newDifferentialCommentMarkupEngine();
$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);
$views[] = $view->render();
}
$views = implode("\n", $views);
return id(new AphrontAjaxResponse())
->setContent($views);
}
}

View file

@ -0,0 +1,19 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'aphront/response/ajax');
phutil_require_module('phabricator', 'applications/differential/controller/base');
phutil_require_module('phabricator', 'applications/differential/parser/markup');
phutil_require_module('phabricator', 'applications/differential/storage/inlinecomment');
phutil_require_module('phabricator', 'applications/differential/view/inlinecomment');
phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phutil', 'utils');
phutil_require_source('DifferentialInlineCommentPreviewController.php');

View file

@ -53,10 +53,10 @@ class DifferentialRevisionEditController extends DifferentialController {
$e_title = true; $e_title = true;
$e_testplan = true; $e_testplan = true;
$errors = array(); $errors = array();
$revision->loadRelationships(); $revision->loadRelationships();
if ($request->isFormPost() && !$request->getStr('viaDiffView')) { if ($request->isFormPost() && !$request->getStr('viaDiffView')) {
$revision->setTitle($request->getStr('title')); $revision->setTitle($request->getStr('title'));
$revision->setSummary($request->getStr('summary')); $revision->setSummary($request->getStr('summary'));
$revision->setTestPlan($request->getStr('testplan')); $revision->setTestPlan($request->getStr('testplan'));
@ -98,14 +98,14 @@ class DifferentialRevisionEditController extends DifferentialController {
$reviewer_phids = $revision->getReviewers(); $reviewer_phids = $revision->getReviewers();
$cc_phids = $revision->getCCPHIDs(); $cc_phids = $revision->getCCPHIDs();
} }
$phids = array_merge($reviewer_phids, $cc_phids); $phids = array_merge($reviewer_phids, $cc_phids);
$phids = array_unique($phids); $phids = array_unique($phids);
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorObjectHandleData($phids))
->loadHandles(); ->loadHandles();
$handles = mpull($handles, 'getFullName', 'getPHID'); $handles = mpull($handles, 'getFullName', 'getPHID');
$reviewer_map = array_select_keys($handles, $reviewer_phids); $reviewer_map = array_select_keys($handles, $reviewer_phids);
$cc_map = array_select_keys($handles, $cc_phids); $cc_map = array_select_keys($handles, $cc_phids);

View file

@ -12,6 +12,7 @@ phutil_require_module('phabricator', 'applications/differential/controller/base'
phutil_require_module('phabricator', 'applications/differential/editor/revision'); phutil_require_module('phabricator', 'applications/differential/editor/revision');
phutil_require_module('phabricator', 'applications/differential/storage/diff'); phutil_require_module('phabricator', 'applications/differential/storage/diff');
phutil_require_module('phabricator', 'applications/differential/storage/revision'); phutil_require_module('phabricator', 'applications/differential/storage/revision');
phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'view/form/base'); phutil_require_module('phabricator', 'view/form/base');
phutil_require_module('phabricator', 'view/form/control/submit'); phutil_require_module('phabricator', 'view/form/control/submit');
phutil_require_module('phabricator', 'view/form/control/textarea'); phutil_require_module('phabricator', 'view/form/control/textarea');

View file

@ -133,7 +133,6 @@ class DifferentialRevisionListController extends DifferentialController {
ON revision.id = relationship.revisionID ON revision.id = relationship.revisionID
WHERE revision.id IN (%Ld) WHERE revision.id IN (%Ld)
AND relationship.relation = %s AND relationship.relation = %s
AND relationship.forbidden = 0
ORDER BY sequence', ORDER BY sequence',
$rev->getTableName(), $rev->getTableName(),
DifferentialRevision::RELATIONSHIP_TABLE, DifferentialRevision::RELATIONSHIP_TABLE,

View file

@ -46,6 +46,8 @@ class DifferentialRevisionViewController extends DifferentialController {
$this->getImplicitComments($revision), $this->getImplicitComments($revision),
$comments); $comments);
$inlines = $this->loadInlineComments($comments, $changesets);
$object_phids = array_merge( $object_phids = array_merge(
$revision->getReviewers(), $revision->getReviewers(),
$revision->getCCPHIDs(), $revision->getCCPHIDs(),
@ -54,6 +56,7 @@ class DifferentialRevisionViewController extends DifferentialController {
$request->getUser()->getPHID(), $request->getUser()->getPHID(),
), ),
mpull($comments, 'getAuthorPHID')); mpull($comments, 'getAuthorPHID'));
$object_phids = array_unique($object_phids);
$handles = id(new PhabricatorObjectHandleData($object_phids)) $handles = id(new PhabricatorObjectHandleData($object_phids))
->loadHandles(); ->loadHandles();
@ -70,6 +73,8 @@ class DifferentialRevisionViewController extends DifferentialController {
$comment_view = new DifferentialRevisionCommentListView(); $comment_view = new DifferentialRevisionCommentListView();
$comment_view->setComments($comments); $comment_view->setComments($comments);
$comment_view->setHandles($handles); $comment_view->setHandles($handles);
$comment_view->setInlineComments($inlines);
$comment_view->setChangesets($changesets);
$diff_history = new DifferentialRevisionUpdateHistoryView(); $diff_history = new DifferentialRevisionUpdateHistoryView();
$diff_history->setDiffs($diffs); $diff_history->setDiffs($diffs);
@ -267,6 +272,46 @@ class DifferentialRevisionViewController extends DifferentialController {
return array_keys($actions); return array_keys($actions);
} }
private function loadInlineComments(array $comments, array &$changesets) {
$inline_comments = array();
$comment_ids = array_filter(mpull($comments, 'getID'));
if (!$comment_ids) {
return $inline_comments;
}
$inline_comments = id(new DifferentialInlineComment())
->loadAllWhere(
'commentID in (%Ld)',
$comment_ids);
$load_changesets = array();
foreach ($inline_comments as $inline) {
$changeset_id = $inline->getChangesetID();
if (isset($changesets[$changeset_id])) {
continue;
}
$load_changesets[$changeset_id] = true;
}
$more_changesets = array();
if ($load_changesets) {
$changeset_ids = array_keys($load_changesets);
$more_changesets += id(new DifferentialChangeset())
->loadAllWhere(
'id IN (%Ld)',
$changeset_ids);
}
if ($more_changesets) {
$changesets += $more_changesets;
$changesets = msort($changesets, 'getSortKey');
}
return $inline_comments;
}
} }
/* /*

View file

@ -10,7 +10,9 @@ phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'applications/differential/constants/action'); phutil_require_module('phabricator', 'applications/differential/constants/action');
phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus'); phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus');
phutil_require_module('phabricator', 'applications/differential/controller/base'); phutil_require_module('phabricator', 'applications/differential/controller/base');
phutil_require_module('phabricator', 'applications/differential/storage/changeset');
phutil_require_module('phabricator', 'applications/differential/storage/comment'); phutil_require_module('phabricator', 'applications/differential/storage/comment');
phutil_require_module('phabricator', 'applications/differential/storage/inlinecomment');
phutil_require_module('phabricator', 'applications/differential/storage/revision'); phutil_require_module('phabricator', 'applications/differential/storage/revision');
phutil_require_module('phabricator', 'applications/differential/view/addcomment'); phutil_require_module('phabricator', 'applications/differential/view/addcomment');
phutil_require_module('phabricator', 'applications/differential/view/changesetlistview'); phutil_require_module('phabricator', 'applications/differential/view/changesetlistview');

View file

@ -107,7 +107,6 @@ class DifferentialRevisionListData {
SELECT revision.* FROM %T revision JOIN %T relationship SELECT revision.* FROM %T revision JOIN %T relationship
ON relationship.revisionID = revision.id ON relationship.revisionID = revision.id
AND relationship.relation = %s AND relationship.relation = %s
AND relationship.forbidden = 0
WHERE relationship.objectPHID IN (%Ls) WHERE relationship.objectPHID IN (%Ls)
AND revision.status in (%Ld) AND revision.status in (%Ld)
@ -143,7 +142,6 @@ class DifferentialRevisionListData {
SELECT revision.* FROM %T revision JOIN %T relationship SELECT revision.* FROM %T revision JOIN %T relationship
ON relationship.revisionID = revision.id ON relationship.revisionID = revision.id
AND relationship.relation = %s AND relationship.relation = %s
AND relationship.forbidden = 0
WHERE relationship.objectPHID IN (%Ls) WHERE relationship.objectPHID IN (%Ls)
AND revision.status in (%Ld) AND revision.status in (%Ld)
@ -202,7 +200,6 @@ class DifferentialRevisionListData {
FROM %T revision LEFT JOIN %T relationship FROM %T revision LEFT JOIN %T relationship
ON revision.id = relationship.revisionID ON revision.id = relationship.revisionID
AND relationship.relation = %s AND relationship.relation = %s
AND relationship.forbidden = 0
WHERE '.$pattern.' WHERE '.$pattern.'
GROUP BY revision.id '.$this->getOrderClause(); GROUP BY revision.id '.$this->getOrderClause();
@ -241,7 +238,6 @@ class DifferentialRevisionListData {
'SELECT revision.* FROM %T revision 'SELECT revision.* FROM %T revision
JOIN %T relationship ON relationship.revisionID = revision.id JOIN %T relationship ON relationship.revisionID = revision.id
AND relationship.relation = %s AND relationship.relation = %s
AND relationship.forbidden = 0
AND relationship.objectPHID in (%Ls) AND relationship.objectPHID in (%Ls)
WHERE revision.status in (%Ld) %Q', WHERE revision.status in (%Ld) %Q',
$revision->getTableName(), $revision->getTableName(),

View file

@ -241,15 +241,13 @@ class DifferentialCommentEditor {
// Reload relationships to pick up any reviewer changes. // Reload relationships to pick up any reviewer changes.
$revision->loadRelationships(); $revision->loadRelationships();
/*
TODO
$inline_comments = array(); $inline_comments = array();
if ($this->attachInlineComments) { if ($this->attachInlineComments) {
$inline_comments = id(new DifferentialInlineComment()) $inline_comments = id(new DifferentialInlineComment())->loadAllWhere(
->loadAllUnsaved($revision, $this->actorPHID); 'authorPHID = %s AND revisionID = %d AND commentID IS NULL',
$this->actorPHID,
$revision->getID());
} }
*/
$comment = id(new DifferentialComment()) $comment = id(new DifferentialComment())
->setAuthorPHID($this->actorPHID) ->setAuthorPHID($this->actorPHID)
@ -258,11 +256,11 @@ class DifferentialCommentEditor {
->setContent((string)$this->message) ->setContent((string)$this->message)
->save(); ->save();
/* // $diff = id(new Diff())->loadActiveWithRevision($revision);
$diff = id(new Diff())->loadActiveWithRevision($revision); // $changesets = id(new DifferentialChangeset())->loadAllWithDiff($diff);
$changesets = id(new DifferentialChangeset())->loadAllWithDiff($diff);
if ($inline_comments) { if ($inline_comments) {
/*
// We may have feedback on non-current changesets. Rather than orphaning // We may have feedback on non-current changesets. Rather than orphaning
// it, just submit it. This is non-ideal but not horrible. // it, just submit it. This is non-ideal but not horrible.
$inline_changeset_ids = array_pull($inline_comments, 'getChangesetID'); $inline_changeset_ids = array_pull($inline_comments, 'getChangesetID');
@ -275,12 +273,12 @@ class DifferentialCommentEditor {
if ($load) { if ($load) {
$changesets += id(new DifferentialChangeset())->loadAllWithIDs($load); $changesets += id(new DifferentialChangeset())->loadAllWithIDs($load);
} }
*/
foreach ($inline_comments as $inline) { foreach ($inline_comments as $inline) {
$inline->setFeedbackID($feedback->getID()); $inline->setCommentID($comment->getID());
$inline->save(); $inline->save();
} }
} }
*/
id(new DifferentialCommentMail( id(new DifferentialCommentMail(
$revision, $revision,

View file

@ -11,6 +11,7 @@ phutil_require_module('phabricator', 'applications/differential/constants/revisi
phutil_require_module('phabricator', 'applications/differential/editor/revision'); phutil_require_module('phabricator', 'applications/differential/editor/revision');
phutil_require_module('phabricator', 'applications/differential/mail/comment'); phutil_require_module('phabricator', 'applications/differential/mail/comment');
phutil_require_module('phabricator', 'applications/differential/storage/comment'); phutil_require_module('phabricator', 'applications/differential/storage/comment');
phutil_require_module('phabricator', 'applications/differential/storage/inlinecomment');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');

View file

@ -497,7 +497,7 @@ class DifferentialRevisionEditor {
array $rem_phids, array $rem_phids,
array $add_phids, array $add_phids,
$reason_phid) { $reason_phid) {
$rem_map = array_fill_keys($rem_phids, true); $rem_map = array_fill_keys($rem_phids, true);
$add_map = array_fill_keys($add_phids, true); $add_map = array_fill_keys($add_phids, true);
@ -516,7 +516,7 @@ class DifferentialRevisionEditor {
$raw = $revision->getRawRelations(DifferentialRevision::RELATION_REVIEWER); $raw = $revision->getRawRelations(DifferentialRevision::RELATION_REVIEWER);
$raw = ipull($raw, null, 'objectPHID'); $raw = ipull($raw, null, 'objectPHID');
$sequence = count($seq_map); $sequence = count($seq_map);
foreach ($raw as $phid => $relation) { foreach ($raw as $phid => $relation) {
if (isset($seq_map[$phid])) { if (isset($seq_map[$phid])) {
@ -540,7 +540,7 @@ class DifferentialRevisionEditor {
'reasonPHID' => $reason_phid, 'reasonPHID' => $reason_phid,
); );
} }
$conn_w = $revision->establishConnection('w'); $conn_w = $revision->establishConnection('w');
$sql = array(); $sql = array();

View file

@ -104,7 +104,7 @@ class DifferentialRevision extends DifferentialDAO {
if ($this->relationships === null) { if ($this->relationships === null) {
throw new Exception("Must load relationships!"); throw new Exception("Must load relationships!");
} }
return ipull($this->getRawRelations($relation), 'objectPHID'); return ipull($this->getRawRelations($relation), 'objectPHID');
} }

View file

@ -10,7 +10,6 @@ phutil_require_module('phabricator', 'applications/differential/storage/base');
phutil_require_module('phabricator', 'applications/differential/storage/comment'); phutil_require_module('phabricator', 'applications/differential/storage/comment');
phutil_require_module('phabricator', 'applications/differential/storage/diff'); phutil_require_module('phabricator', 'applications/differential/storage/diff');
phutil_require_module('phabricator', 'applications/phid/storage/phid'); phutil_require_module('phabricator', 'applications/phid/storage/phid');
phutil_require_module('phabricator', 'storage/qsprintf');
phutil_require_module('phabricator', 'storage/queryfx'); phutil_require_module('phabricator', 'storage/queryfx');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');

View file

@ -72,13 +72,18 @@ final class DifferentialAddCommentView extends AphrontView {
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue('Comment')); ->setValue('Comment'));
$rev_id = $revision->getID();
Javelin::initBehavior( Javelin::initBehavior(
'differential-feedback-preview', 'differential-feedback-preview',
array( array(
'uri' => '/differential/comment/preview/'.$revision->getID().'/', 'uri' => '/differential/comment/preview/'.$rev_id.'/',
'preview' => 'comment-preview', 'preview' => 'comment-preview',
'action' => 'comment-action', 'action' => 'comment-action',
'content' => 'comment-content', 'content' => 'comment-content',
'inlineuri' => '/differential/comment/inline/preview/'.$rev_id.'/',
'inline' => 'inline-comment-preview',
)); ));
return return
@ -93,6 +98,8 @@ final class DifferentialAddCommentView extends AphrontView {
'Loading comment preview...'. 'Loading comment preview...'.
'</span>'. '</span>'.
'</div>'. '</div>'.
'<div id="inline-comment-preview">'.
'</div>'.
'</div>'. '</div>'.
'</div>'; '</div>';
} }

View file

@ -109,7 +109,16 @@ final class DifferentialInlineCommentView extends AphrontView {
$links = null; $links = null;
} }
$content = $this->markupEngine->markupText($content); $cache = $inline->getCache();
if (strlen($cache)) {
$content = $cache;
} else {
$content = $this->markupEngine->markupText($content);
if ($inline->getID()) {
$inline->setCache($content);
$inline->save();
}
}
$markup = javelin_render_tag( $markup = javelin_render_tag(
'div', 'div',

View file

@ -22,6 +22,8 @@ final class DifferentialRevisionCommentView extends AphrontView {
private $handles; private $handles;
private $markupEngine; private $markupEngine;
private $preview; private $preview;
private $inlines;
private $changesets;
public function setComment($comment) { public function setComment($comment) {
$this->comment = $comment; $this->comment = $comment;
@ -43,6 +45,17 @@ final class DifferentialRevisionCommentView extends AphrontView {
return $this; return $this;
} }
public function setInlineComments(array $inline_comments) {
$this->inlines = $inline_comments;
return $this;
}
public function setChangesets(array $changesets) {
// Ship these in sorted by getSortKey() and keyed by ID... or else!
$this->changesets = $changesets;
return $this;
}
public function render() { public function render() {
require_celerity_resource('phabricator-remarkup-css'); require_celerity_resource('phabricator-remarkup-css');
@ -91,6 +104,67 @@ final class DifferentialRevisionCommentView extends AphrontView {
'</div>'; '</div>';
} }
if ($this->inlines) {
$inline_render = array();
$inlines = $this->inlines;
$changesets = $this->changesets;
$inlines_by_changeset = mgroup($inlines, 'getChangesetID');
$inlines_by_changeset = array_select_keys(
$inlines_by_changeset,
array_keys($this->changesets));
$inline_render[] = '<table class="differential-inline-summary">';
foreach ($inlines_by_changeset as $changeset_id => $inlines) {
$changeset = $changesets[$changeset_id];
$inlines = msort($inlines, 'getLineNumber');
$inline_render[] =
'<tr>'.
'<th colspan="2">'.
$changeset->getFileName().
'</th>'.
'</tr>';
foreach ($inlines as $inline) {
if (!$inline->getLineLength()) {
$lines = $inline->getLineNumber();
} else {
$lines = $inline->getLineNumber()."\xE2\x80\x93".
($inline->getLineNumber() + $inline->getLineLength());
}
$lines = phutil_render_tag(
'a',
array(
'href' => '#',
'class' => 'num',
),
$lines);
$content = $inline->getCache();
if (!strlen($content)) {
$content = $this->markupEngine->markupText($content);
if ($inline->getID()) {
$inline->setCache($content);
$inline->save();
}
}
$inline_render[] =
'<tr>'.
'<td class="inline-line-number">'.$lines.'</td>'.
'<td>'.$content.'</td>'.
'</tr>';
}
}
$inline_render[] = '</table>';
$inline_render = implode("\n", $inline_render);
$inline_render =
'<div class="differential-inline-summary-section">'.
'Inline Comments'.
'</div>'.
$inline_render;
} else {
$inline_render = null;
}
$background = null; $background = null;
$uri = $author->getImageURI(); $uri = $author->getImageURI();
if ($uri) { if ($uri) {
@ -104,10 +178,11 @@ final class DifferentialRevisionCommentView extends AphrontView {
'<div class="differential-comment-title">'.$title.'</div>'. '<div class="differential-comment-title">'.$title.'</div>'.
'</div>'. '</div>'.
'<div class="differential-comment-body" style="'.$background.'">'. '<div class="differential-comment-body" style="'.$background.'">'.
'<div class="differential-comment-core">'. '<div class="differential-comment-content">'.
'<div class="differential-comment-content">'. '<div class="differential-comment-core">'.
$content. $content.
'</div>'. '</div>'.
$inline_render.
'</div>'. '</div>'.
'</div>'. '</div>'.
'</div>'; '</div>';

View file

@ -11,6 +11,7 @@ phutil_require_module('phabricator', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'view/base'); phutil_require_module('phabricator', 'view/base');
phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'utils');
phutil_require_source('DifferentialRevisionCommentView.php'); phutil_require_source('DifferentialRevisionCommentView.php');

View file

@ -20,17 +20,29 @@ final class DifferentialRevisionCommentListView extends AphrontView {
private $comments; private $comments;
private $handles; private $handles;
private $inlines;
private $changesets;
public function setComments($comments) { public function setComments(array $comments) {
$this->comments = $comments; $this->comments = $comments;
return $this; return $this;
} }
public function setInlineComments(array $inline_comments) {
$this->inlines = $inline_comments;
return $this;
}
public function setHandles(array $handles) { public function setHandles(array $handles) {
$this->handles = $handles; $this->handles = $handles;
return $this; return $this;
} }
public function setChangesets(array $changesets) {
$this->changesets = $changesets;
return $this;
}
public function render() { public function render() {
require_celerity_resource('differential-revision-comment-list-css'); require_celerity_resource('differential-revision-comment-list-css');
@ -38,12 +50,17 @@ final class DifferentialRevisionCommentListView extends AphrontView {
$factory = new DifferentialMarkupEngineFactory(); $factory = new DifferentialMarkupEngineFactory();
$engine = $factory->newDifferentialCommentMarkupEngine(); $engine = $factory->newDifferentialCommentMarkupEngine();
$inlines = mgroup($this->inlines, 'getCommentID');
$comments = array(); $comments = array();
foreach ($this->comments as $comment) { foreach ($this->comments as $comment) {
$view = new DifferentialRevisionCommentView(); $view = new DifferentialRevisionCommentView();
$view->setComment($comment); $view->setComment($comment);
$view->setHandles($this->handles); $view->setHandles($this->handles);
$view->setMarkupEngine($engine); $view->setMarkupEngine($engine);
$view->setInlineComments(idx($inlines, $comment->getID(), array()));
$view->setChangesets($this->changesets);
$comments[] = $view->render(); $comments[] = $view->render();
} }

View file

@ -11,5 +11,7 @@ phutil_require_module('phabricator', 'applications/differential/view/revisioncom
phutil_require_module('phabricator', 'infrastructure/celerity/api'); phutil_require_module('phabricator', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'view/base'); phutil_require_module('phabricator', 'view/base');
phutil_require_module('phutil', 'utils');
phutil_require_source('DifferentialRevisionCommentListView.php'); phutil_require_source('DifferentialRevisionCommentListView.php');

View file

@ -57,7 +57,7 @@ class PhabricatorObjectHandle {
$this->fullName = $full_name; $this->fullName = $full_name;
return $this; return $this;
} }
public function getFullName() { public function getFullName() {
return $this->fullName; return $this->fullName;
} }

View file

@ -21,3 +21,10 @@
.differential-comment-preview .differential-loading-text { .differential-comment-preview .differential-loading-text {
color: #aaaaaa; color: #aaaaaa;
} }
#inline-comment-preview {
margin-left: 60px;
width: 88ex;
width: 81ch;
}

View file

@ -38,7 +38,11 @@
padding: .3em 5px .4em 1.25em; padding: .3em 5px .4em 1.25em;
} }
.differential-comment-content code { .differential-comment-core p {
margin: 0.35em 0;
}
.differential-comment-core code {
width: 88ex; width: 88ex;
width: 81ch; width: 81ch;
} }
@ -92,3 +96,53 @@
border-color: #cc9966; border-color: #cc9966;
background: #fff9f3; background: #fff9f3;
} }
.differential-inline-summary th,
.differential-inline-summary td {
vertical-align: top;
padding: 0 0 6px;
}
.differential-inline-summary th {
padding-top: 16px;
color: #666666;
font-weight: bold;
}
.differential-inline-summary tr > th:first-child {
padding-top: 2px;
}
.differential-inline-summary td.inline-line-number {
color: #444444;
white-space: nowrap;
text-align: left;
font-weight: bold;
padding: 0 4px;
width: 90px;
}
.differential-inline-summary td.inline-line-number .num {
display: block;
position: relative;
padding-left: 15px;
padding-right: 5px;
width: 70px; /* Need lots of width for 23,950-23,951 */
}
.differential-inline-summary td.inline-line-number a:hover {
background: #3b5998;
color: white;
text-decoration: none;
}
.differential-inline-summary-section {
margin: 1em 0 .5em;
font-size: 11px;
border-bottom: 1px solid #dddddd;
color: #666666;
}

View file

@ -47,4 +47,20 @@ JX.behavior('differential-feedback-preview', function(config) {
JX.DOM.listen(action, 'change', null, check); JX.DOM.listen(action, 'change', null, check);
check(); check();
function refreshInlinePreview() {
new JX.Request(config.inlineuri, function(r) {
JX.DOM.setContent(JX.$(config.inline), JX.HTML(r));
})
.setTimeout(5000)
.send();
}
JX.Stratcom.listen(
'differential-inline-comment-update',
null,
refreshInlinePreview);
refreshInlinePreview();
}); });