Skip to content

Commit

Permalink
Modernize transaction comment editor
Browse files Browse the repository at this point in the history
Summary: Fixes T8703. The URI handling here was a little unusual.

Test Plan:
  - Edited and deleted comments in several applications, including Macro.
  - As an admin, deleted others' comments.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8703

Differential Revision: https://secure.phabricator.com/D13469
  • Loading branch information
epriestley committed Jun 29, 2015
1 parent ae00d08 commit b39f5d6
Showing 1 changed file with 18 additions and 36 deletions.
Expand Up @@ -3,21 +3,13 @@
final class PhabricatorApplicationTransactionCommentEditController
extends PhabricatorApplicationTransactionController {

private $phid;

public function willProcessRequest(array $data) {
$this->phid = $data['phid'];
}

public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();

$xaction = id(new PhabricatorObjectQuery())
->withPHIDs(array($this->phid))
->setViewer($user)
->setViewer($viewer)
->withPHIDs(array($request->getURIData('phid')))
->executeOne();

if (!$xaction) {
return new Aphront404Response();
}
Expand All @@ -33,11 +25,9 @@ public function processRequest() {
return new Aphront400Response();
}

$obj_phid = $xaction->getObjectPHID();
$obj_handle = id(new PhabricatorHandleQuery())
->setViewer($user)
->withPHIDs(array($obj_phid))
->executeOne();
$phid = $xaction->getObjectPHID();
$handles = $viewer->loadHandles(array($phid));
$obj_handle = $handles[$phid];

if ($request->isDialogFormPost()) {
$text = $request->getStr('text');
Expand All @@ -49,7 +39,7 @@ public function processRequest() {
}

$editor = id(new PhabricatorApplicationTransactionCommentEditor())
->setActor($user)
->setActor($viewer)
->setContentSource(PhabricatorContentSource::newFromRequest($request))
->applyEdit($xaction, $comment);

Expand All @@ -60,28 +50,20 @@ public function processRequest() {
}
}

$dialog = id(new AphrontDialogView())
->setUser($user)
->setSubmitURI(
$this->getApplicationURI('/transactions/edit/'.$xaction->getPHID().'/'))
->setTitle(pht('Edit Comment'));
$form = id(new AphrontFormView())
->setUser($viewer)
->setFullWidth(true)
->appendControl(
id(new PhabricatorRemarkupControl())
->setName('text')
->setValue($xaction->getComment()->getContent()));

$dialog
return $this->newDialog()
->setTitle(pht('Edit Comment'))
->addHiddenInput('anchor', $request->getStr('anchor'))
->appendChild(
id(new PHUIFormLayoutView())
->setFullWidth(true)
->appendChild(
id(new PhabricatorRemarkupControl())
->setUser($user)
->setName('text')
->setValue($xaction->getComment()->getContent())));

$dialog
->appendForm($form)
->addSubmitButton(pht('Save Changes'))
->addCancelButton($obj_handle->getURI());

return id(new AphrontDialogResponse())->setDialog($dialog);
}

}

0 comments on commit b39f5d6

Please sign in to comment.