1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-07 20:38:32 +01:00

Modernize transaction comment editor

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
This commit is contained in:
epriestley 2015-06-29 11:30:27 -07:00
parent ae00d08b88
commit b39f5d651c

View file

@ -3,21 +3,13 @@
final class PhabricatorApplicationTransactionCommentEditController final class PhabricatorApplicationTransactionCommentEditController
extends PhabricatorApplicationTransactionController { extends PhabricatorApplicationTransactionController {
private $phid; public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
public function willProcessRequest(array $data) {
$this->phid = $data['phid'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$xaction = id(new PhabricatorObjectQuery()) $xaction = id(new PhabricatorObjectQuery())
->withPHIDs(array($this->phid)) ->setViewer($viewer)
->setViewer($user) ->withPHIDs(array($request->getURIData('phid')))
->executeOne(); ->executeOne();
if (!$xaction) { if (!$xaction) {
return new Aphront404Response(); return new Aphront404Response();
} }
@ -33,11 +25,9 @@ final class PhabricatorApplicationTransactionCommentEditController
return new Aphront400Response(); return new Aphront400Response();
} }
$obj_phid = $xaction->getObjectPHID(); $phid = $xaction->getObjectPHID();
$obj_handle = id(new PhabricatorHandleQuery()) $handles = $viewer->loadHandles(array($phid));
->setViewer($user) $obj_handle = $handles[$phid];
->withPHIDs(array($obj_phid))
->executeOne();
if ($request->isDialogFormPost()) { if ($request->isDialogFormPost()) {
$text = $request->getStr('text'); $text = $request->getStr('text');
@ -49,7 +39,7 @@ final class PhabricatorApplicationTransactionCommentEditController
} }
$editor = id(new PhabricatorApplicationTransactionCommentEditor()) $editor = id(new PhabricatorApplicationTransactionCommentEditor())
->setActor($user) ->setActor($viewer)
->setContentSource(PhabricatorContentSource::newFromRequest($request)) ->setContentSource(PhabricatorContentSource::newFromRequest($request))
->applyEdit($xaction, $comment); ->applyEdit($xaction, $comment);
@ -60,28 +50,20 @@ final class PhabricatorApplicationTransactionCommentEditController
} }
} }
$dialog = id(new AphrontDialogView()) $form = id(new AphrontFormView())
->setUser($user) ->setUser($viewer)
->setSubmitURI( ->setFullWidth(true)
$this->getApplicationURI('/transactions/edit/'.$xaction->getPHID().'/')) ->appendControl(
->setTitle(pht('Edit Comment')); id(new PhabricatorRemarkupControl())
->setName('text')
->setValue($xaction->getComment()->getContent()));
$dialog return $this->newDialog()
->setTitle(pht('Edit Comment'))
->addHiddenInput('anchor', $request->getStr('anchor')) ->addHiddenInput('anchor', $request->getStr('anchor'))
->appendChild( ->appendForm($form)
id(new PHUIFormLayoutView())
->setFullWidth(true)
->appendChild(
id(new PhabricatorRemarkupControl())
->setUser($user)
->setName('text')
->setValue($xaction->getComment()->getContent())));
$dialog
->addSubmitButton(pht('Save Changes')) ->addSubmitButton(pht('Save Changes'))
->addCancelButton($obj_handle->getURI()); ->addCancelButton($obj_handle->getURI());
return id(new AphrontDialogResponse())->setDialog($dialog);
} }
} }