Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14003822
D12186.id29293.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
17 KB
Referenced Files
None
Subscribers
None
D12186.id29293.diff
View Options
diff --git a/resources/celerity/map.php b/resources/celerity/map.php
--- a/resources/celerity/map.php
+++ b/resources/celerity/map.php
@@ -11,7 +11,7 @@
'core.pkg.js' => '75599122',
'darkconsole.pkg.js' => '8ab24e01',
'differential.pkg.css' => '571b1cc1',
- 'differential.pkg.js' => 'e324301d',
+ 'differential.pkg.js' => 'c0506961',
'diffusion.pkg.css' => '591664fa',
'diffusion.pkg.js' => 'bfc0737b',
'maniphest.pkg.css' => '68d4dd3d',
@@ -57,7 +57,7 @@
'rsrc/css/application/differential/add-comment.css' => 'c47f8c40',
'rsrc/css/application/differential/changeset-view.css' => 'f36406b1',
'rsrc/css/application/differential/core.css' => '7ac3cabc',
- 'rsrc/css/application/differential/phui-inline-comment.css' => '17e89126',
+ 'rsrc/css/application/differential/phui-inline-comment.css' => 'a96c315d',
'rsrc/css/application/differential/results-table.css' => '181aa9d9',
'rsrc/css/application/differential/revision-comment.css' => '024dda6b',
'rsrc/css/application/differential/revision-history.css' => '0e8eb855',
@@ -365,7 +365,7 @@
'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '453c5375',
'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => 'd4eecc63',
'rsrc/js/application/differential/ChangesetViewManager.js' => '58562350',
- 'rsrc/js/application/differential/DifferentialInlineCommentEditor.js' => 'b3412377',
+ 'rsrc/js/application/differential/DifferentialInlineCommentEditor.js' => '2529c82d',
'rsrc/js/application/differential/behavior-add-reviewers-and-ccs.js' => 'e10f8e18',
'rsrc/js/application/differential/behavior-comment-jump.js' => '4fdb476d',
'rsrc/js/application/differential/behavior-comment-preview.js' => '8e1389b5',
@@ -523,7 +523,7 @@
'conpherence-widget-pane-css' => '1979ee8c',
'differential-changeset-view-css' => 'f36406b1',
'differential-core-view-css' => '7ac3cabc',
- 'differential-inline-comment-editor' => 'b3412377',
+ 'differential-inline-comment-editor' => '2529c82d',
'differential-results-table-css' => '181aa9d9',
'differential-revision-add-comment-css' => 'c47f8c40',
'differential-revision-comment-css' => '024dda6b',
@@ -790,7 +790,7 @@
'phui-image-mask-css' => '5a8b09c8',
'phui-info-panel-css' => '27ea50a1',
'phui-info-view-css' => 'c6f0aef8',
- 'phui-inline-comment-view-css' => '17e89126',
+ 'phui-inline-comment-view-css' => 'a96c315d',
'phui-list-view-css' => '2e25ebfb',
'phui-object-box-css' => 'd68ce5dc',
'phui-object-item-list-view-css' => '9db65899',
@@ -995,6 +995,14 @@
'javelin-workflow',
'javelin-util',
),
+ '2529c82d' => array(
+ 'javelin-dom',
+ 'javelin-util',
+ 'javelin-stratcom',
+ 'javelin-install',
+ 'javelin-request',
+ 'javelin-workflow',
+ ),
'2818f5ce' => array(
'javelin-install',
'javelin-util',
@@ -1652,14 +1660,6 @@
'javelin-uri',
'javelin-request',
),
- 'b3412377' => array(
- 'javelin-dom',
- 'javelin-util',
- 'javelin-stratcom',
- 'javelin-install',
- 'javelin-request',
- 'javelin-workflow',
- ),
'b3a4b884' => array(
'javelin-behavior',
'phabricator-prefab',
diff --git a/src/applications/differential/controller/DifferentialInlineCommentEditController.php b/src/applications/differential/controller/DifferentialInlineCommentEditController.php
--- a/src/applications/differential/controller/DifferentialInlineCommentEditController.php
+++ b/src/applications/differential/controller/DifferentialInlineCommentEditController.php
@@ -3,28 +3,31 @@
final class DifferentialInlineCommentEditController
extends PhabricatorInlineCommentController {
- private $revisionID;
-
- public function willProcessRequest(array $data) {
- $this->revisionID = $data['id'];
+ private function getRevisionID() {
+ return $this->getRequest()->getURIData('id');
}
- protected function createComment() {
-
- // Verify revision and changeset correspond to actual objects.
- $revision_id = $this->revisionID;
- $changeset_id = $this->getChangesetID();
+ private function loadRevision() {
+ $viewer = $this->getViewer();
+ $revision_id = $this->getRevisionID();
- $viewer = $this->getRequest()->getUser();
$revision = id(new DifferentialRevisionQuery())
->setViewer($viewer)
->withIDs(array($revision_id))
->executeOne();
-
- if (!$revision) {
- throw new Exception('Invalid revision ID!');
+ if (!$revision) {
+ throw new Exception(pht('Invalid revision ID "%s".', $revision_id));
}
+ return $revision;
+ }
+
+ protected function createComment() {
+ // Verify revision and changeset correspond to actual objects.
+ $changeset_id = $this->getChangesetID();
+
+ $revision = $this->loadRevision();
+
if (!id(new DifferentialChangeset())->load($changeset_id)) {
throw new Exception('Invalid changeset ID!');
}
@@ -113,7 +116,7 @@
}
// Inline must be attached to the active revision.
- if ($inline->getRevisionID() != $this->revisionID) {
+ if ($inline->getRevisionID() != $this->getRevisionID()) {
return false;
}
@@ -139,4 +142,10 @@
$inline->getPHID());
$inline->saveTransaction();
}
+
+ protected function loadObjectOwnerPHID(
+ PhabricatorInlineCommentInterface $inline) {
+ return $this->loadRevision()->getAuthorPHID();
+ }
+
}
diff --git a/src/applications/differential/controller/DifferentialInlineCommentPreviewController.php b/src/applications/differential/controller/DifferentialInlineCommentPreviewController.php
--- a/src/applications/differential/controller/DifferentialInlineCommentPreviewController.php
+++ b/src/applications/differential/controller/DifferentialInlineCommentPreviewController.php
@@ -3,20 +3,30 @@
final class DifferentialInlineCommentPreviewController
extends PhabricatorInlineCommentPreviewController {
- private $revisionID;
+ protected function loadInlineComments() {
+ $viewer = $this->getViewer();
- public function willProcessRequest(array $data) {
- $this->revisionID = $data['id'];
+ return id(new DifferentialInlineCommentQuery())
+ ->withDraftComments($viewer->getPHID(), $this->getRevisionID())
+ ->execute();
}
- protected function loadInlineComments() {
- $user = $this->getRequest()->getUser();
+ protected function loadObjectOwnerPHID() {
+ $viewer = $this->getViewer();
- $inlines = id(new DifferentialInlineCommentQuery())
- ->withDraftComments($user->getPHID(), $this->revisionID)
- ->execute();
+ $revision = id(new DifferentialRevisionQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($this->getRevisionID()))
+ ->executeOne();
+ if (!$revision) {
+ return null;
+ }
- return $inlines;
+ return $revision->getAuthorPHID();
}
+
+ private function getRevisionID() {
+ return $this->getRequest()->getURIData('id');
+ }
}
diff --git a/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php b/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php
--- a/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php
+++ b/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php
@@ -459,6 +459,7 @@
$allow_done = !$comment->isDraft() && $this->getCanMarkDone();
return id(new PHUIDiffInlineCommentDetailView())
+ ->setUser($user)
->setInlineComment($comment)
->setIsOnRight($on_right)
->setHandles($this->getHandles())
diff --git a/src/applications/diffusion/controller/DiffusionBrowseFileController.php b/src/applications/diffusion/controller/DiffusionBrowseFileController.php
--- a/src/applications/diffusion/controller/DiffusionBrowseFileController.php
+++ b/src/applications/diffusion/controller/DiffusionBrowseFileController.php
@@ -845,7 +845,11 @@
$rows = array();
foreach ($inlines as $inline) {
+
+ // TODO: This should use modern scaffolding code.
+
$inline_view = id(new PHUIDiffInlineCommentDetailView())
+ ->setUser($this->getViewer())
->setMarkupEngine($engine)
->setInlineComment($inline)
->render();
diff --git a/src/applications/diffusion/controller/DiffusionInlineCommentController.php b/src/applications/diffusion/controller/DiffusionInlineCommentController.php
--- a/src/applications/diffusion/controller/DiffusionInlineCommentController.php
+++ b/src/applications/diffusion/controller/DiffusionInlineCommentController.php
@@ -3,39 +3,41 @@
final class DiffusionInlineCommentController
extends PhabricatorInlineCommentController {
- private $commitPHID;
-
- public function willProcessRequest(array $data) {
- $this->commitPHID = $data['phid'];
+ private function getCommitPHID() {
+ return $this->getRequest()->getURIData('phid');
}
- protected function createComment() {
+ private function loadCommit() {
+ $viewer = $this->getViewer();
+ $commit_phid = $this->getCommitPHID();
- // Verify commit and path correspond to actual objects.
- $commit_phid = $this->commitPHID;
- $path_id = $this->getChangesetID();
-
- $commit = id(new PhabricatorRepositoryCommit())->loadOneWhere(
- 'phid = %s',
- $commit_phid);
+ $commit = id(new DiffusionCommitQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($commit_phid))
+ ->executeOne();
if (!$commit) {
- throw new Exception('Invalid commit ID!');
+ throw new Exception(pht('Invalid commit PHID "%s"!', $commit_phid));
}
- // TODO: Write a real PathQuery object?
+ return $commit;
+ }
+ protected function createComment() {
+ $commit = $this->loadCommit();
+
+ // TODO: Write a real PathQuery object?
+ $path_id = $this->getChangesetID();
$path = queryfx_one(
id(new PhabricatorRepository())->establishConnection('r'),
'SELECT path FROM %T WHERE id = %d',
PhabricatorRepository::TABLE_PATH,
$path_id);
-
if (!$path) {
throw new Exception('Invalid path ID!');
}
return id(new PhabricatorAuditInlineComment())
- ->setCommitPHID($commit_phid)
+ ->setCommitPHID($commit->getPHID())
->setPathID($path_id);
}
@@ -98,7 +100,7 @@
}
// Inline must be attached to the active revision.
- if ($inline->getCommitPHID() != $this->commitPHID) {
+ if ($inline->getCommitPHID() != $this->getCommitPHID()) {
return false;
}
@@ -113,4 +115,10 @@
return $inline->save();
}
+ protected function loadObjectOwnerPHID(
+ PhabricatorInlineCommentInterface $inline) {
+ return $this->loadCommit()->getAuthorPHID();
+ }
+
+
}
diff --git a/src/applications/diffusion/controller/DiffusionInlineCommentPreviewController.php b/src/applications/diffusion/controller/DiffusionInlineCommentPreviewController.php
--- a/src/applications/diffusion/controller/DiffusionInlineCommentPreviewController.php
+++ b/src/applications/diffusion/controller/DiffusionInlineCommentPreviewController.php
@@ -3,19 +3,30 @@
final class DiffusionInlineCommentPreviewController
extends PhabricatorInlineCommentPreviewController {
- private $commitPHID;
+ protected function loadInlineComments() {
+ $viewer = $this->getViewer();
- public function willProcessRequest(array $data) {
- $this->commitPHID = $data['phid'];
+ return PhabricatorAuditInlineComment::loadDraftComments(
+ $viewer,
+ $this->getCommitPHID());
}
- protected function loadInlineComments() {
- $user = $this->getRequest()->getUser();
+ protected function loadObjectOwnerPHID() {
+ $viewer = $this->getViewer();
- $inlines = PhabricatorAuditInlineComment::loadDraftComments(
- $user,
- $this->commitPHID);
+ $commit = id(new DiffusionCommitQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($this->getCommitPHID()))
+ ->executeOne();
+ if (!$commit) {
+ return null;
+ }
- return $inlines;
+ return $commit->getAuthorPHID();
}
+
+ private function getCommitPHID() {
+ return $this->getRequest()->getURIData('phid');
+ }
+
}
diff --git a/src/infrastructure/diff/PhabricatorInlineCommentController.php b/src/infrastructure/diff/PhabricatorInlineCommentController.php
--- a/src/infrastructure/diff/PhabricatorInlineCommentController.php
+++ b/src/infrastructure/diff/PhabricatorInlineCommentController.php
@@ -8,6 +8,8 @@
abstract protected function loadCommentForEdit($id);
abstract protected function loadCommentForDone($id);
abstract protected function loadCommentByPHID($phid);
+ abstract protected function loadObjectOwnerPHID(
+ PhabricatorInlineCommentInterface $inline);
abstract protected function deleteComment(
PhabricatorInlineCommentInterface $inline);
abstract protected function saveComment(
@@ -88,6 +90,7 @@
}
$inline = $this->loadCommentForDone($this->getCommentID());
+ $is_draft_state = false;
switch ($inline->getFixedState()) {
case PhabricatorInlineCommentInterface::STATE_DRAFT:
$next_state = PhabricatorInlineCommentInterface::STATE_UNDONE;
@@ -97,16 +100,22 @@
break;
case PhabricatorInlineCommentInterface::STATE_DONE:
$next_state = PhabricatorInlineCommentInterface::STATE_UNDRAFT;
+ $is_draft_state = true;
break;
default:
case PhabricatorInlineCommentInterface::STATE_UNDONE:
$next_state = PhabricatorInlineCommentInterface::STATE_DRAFT;
+ $is_draft_state = true;
break;
}
$inline->setFixedState($next_state)->save();
- return $this->buildEmptyResponse();
+ return id(new AphrontAjaxResponse())
+ ->setContent(
+ array(
+ 'draftState' => $is_draft_state,
+ ));
case 'delete':
case 'undelete':
case 'refdelete':
@@ -306,12 +315,10 @@
$phids = array($user->getPHID());
$handles = $this->loadViewerHandles($phids);
-
- // TODO: This is not correct, but figuring it out is a little bit
- // involved and it only affects drafts.
- $object_owner_phid = null;
+ $object_owner_phid = $this->loadObjectOwnerPHID($inline);
$view = id(new PHUIDiffInlineCommentDetailView())
+ ->setUser($user)
->setInlineComment($inline)
->setIsOnRight($on_right)
->setMarkupEngine($engine)
diff --git a/src/infrastructure/diff/PhabricatorInlineCommentPreviewController.php b/src/infrastructure/diff/PhabricatorInlineCommentPreviewController.php
--- a/src/infrastructure/diff/PhabricatorInlineCommentPreviewController.php
+++ b/src/infrastructure/diff/PhabricatorInlineCommentPreviewController.php
@@ -4,6 +4,7 @@
extends PhabricatorController {
abstract protected function loadInlineComments();
+ abstract protected function loadObjectOwnerPHID();
public function processRequest() {
$request = $this->getRequest();
@@ -23,13 +24,12 @@
$phids = array($viewer->getPHID());
$handles = $this->loadViewerHandles($phids);
+ $object_owner_phid = $this->loadObjectOwnerPHID();
$views = array();
foreach ($inlines as $inline) {
- // TODO: This is incorrect, but figuring it out is somewhat involved.
- $object_owner_phid = null;
-
$view = id(new PHUIDiffInlineCommentDetailView())
+ ->setUser($viewer)
->setInlineComment($inline)
->setMarkupEngine($engine)
->setHandles($handles)
diff --git a/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php b/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php
--- a/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php
+++ b/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php
@@ -130,9 +130,14 @@
if ($inline->getReplyToCommentPHID()) {
$classes[] = 'inline-comment-is-reply';
}
- // Might break?
- if ($this->getCanMarkDone()) {
- $classes[] = 'viewer-is-diff-author';
+
+ $viewer_phid = $this->getUser()->getPHID();
+ $owner_phid = $this->getObjectOwnerPHID();
+
+ if ($viewer_phid) {
+ if ($viewer_phid == $owner_phid) {
+ $classes[] = 'viewer-is-object-owner';
+ }
}
$action_buttons = new PHUIButtonBarView();
diff --git a/webroot/rsrc/css/application/differential/phui-inline-comment.css b/webroot/rsrc/css/application/differential/phui-inline-comment.css
--- a/webroot/rsrc/css/application/differential/phui-inline-comment.css
+++ b/webroot/rsrc/css/application/differential/phui-inline-comment.css
@@ -244,6 +244,11 @@
cursor: pointer;
}
+.inline-state-is-draft .differential-inline-done-label {
+ /* TODO: Placeholder style. */
+ border-style: dashed;
+}
+
.differential-inline-done-label .differential-inline-done {
margin: 0 6px 0 0;
display: inline;
diff --git a/webroot/rsrc/js/application/differential/DifferentialInlineCommentEditor.js b/webroot/rsrc/js/application/differential/DifferentialInlineCommentEditor.js
--- a/webroot/rsrc/js/application/differential/DifferentialInlineCommentEditor.js
+++ b/webroot/rsrc/js/application/differential/DifferentialInlineCommentEditor.js
@@ -301,7 +301,7 @@
};
new JX.Workflow(this._uri, data)
- .setHandler(JX.bind(this, function() {
+ .setHandler(JX.bind(this, function(r) {
checkbox.checked = !checkbox.checked;
var comment = JX.DOM.findAbove(
@@ -309,8 +309,7 @@
'div',
'differential-inline-comment');
JX.DOM.alterClass(comment, 'inline-is-done', !!checkbox.checked);
-
- // TODO: Dynamically update the "inline-state-is-draft" class.
+ JX.DOM.alterClass(comment, 'inline-state-is-draft', r.draftState);
this._didUpdate();
}))
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Oct 27, 11:13 AM (3 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6724186
Default Alt Text
D12186.id29293.diff (17 KB)
Attached To
Mode
D12186: Touch up PHP/JS interactions for inline comments
Attached
Detach File
Event Timeline
Log In to Comment