Touch up PHP/JS interactions for inline comments
Summary: Ref T1460. Overall: - Pass `objectOwnerPHID` consistently. - Pass viewer consistently. - Set the correct draft state for checkboxes on the client. Test Plan: - Made inline comments in Differential. - Made inline comments in Diffusion. Reviewers: chad Reviewed By: chad Subscribers: epriestley Maniphest Tasks: T1460 Differential Revision: https://secure.phabricator.com/D12186
This commit is contained in:
@@ -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() {
|
||||
private function loadRevision() {
|
||||
$viewer = $this->getViewer();
|
||||
$revision_id = $this->getRevisionID();
|
||||
|
||||
// Verify revision and changeset correspond to actual objects.
|
||||
$revision_id = $this->revisionID;
|
||||
$changeset_id = $this->getChangesetID();
|
||||
|
||||
$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 @@ final class DifferentialInlineCommentEditController
|
||||
}
|
||||
|
||||
// Inline must be attached to the active revision.
|
||||
if ($inline->getRevisionID() != $this->revisionID) {
|
||||
if ($inline->getRevisionID() != $this->getRevisionID()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -139,4 +142,10 @@ final class DifferentialInlineCommentEditController
|
||||
$inline->getPHID());
|
||||
$inline->saveTransaction();
|
||||
}
|
||||
|
||||
protected function loadObjectOwnerPHID(
|
||||
PhabricatorInlineCommentInterface $inline) {
|
||||
return $this->loadRevision()->getAuthorPHID();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,20 +3,30 @@
|
||||
final class DifferentialInlineCommentPreviewController
|
||||
extends PhabricatorInlineCommentPreviewController {
|
||||
|
||||
private $revisionID;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->revisionID = $data['id'];
|
||||
}
|
||||
|
||||
protected function loadInlineComments() {
|
||||
$user = $this->getRequest()->getUser();
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$inlines = id(new DifferentialInlineCommentQuery())
|
||||
->withDraftComments($user->getPHID(), $this->revisionID)
|
||||
return id(new DifferentialInlineCommentQuery())
|
||||
->withDraftComments($viewer->getPHID(), $this->getRevisionID())
|
||||
->execute();
|
||||
|
||||
return $inlines;
|
||||
}
|
||||
|
||||
protected function loadObjectOwnerPHID() {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$revision = id(new DifferentialRevisionQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($this->getRevisionID()))
|
||||
->executeOne();
|
||||
if (!$revision) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $revision->getAuthorPHID();
|
||||
}
|
||||
|
||||
|
||||
private function getRevisionID() {
|
||||
return $this->getRequest()->getURIData('id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user