1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Update Fund for EditEngine commenting

Summary: Ref T12685. Moves Fund to EditEngine commenting.

Test Plan: View an old Fund, leave a comment, add a subscriber.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T12685

Differential Revision: https://secure.phabricator.com/D17857
This commit is contained in:
Chad Little 2017-05-09 09:00:24 -07:00
parent 86f9318052
commit b2cbb8f2ee
5 changed files with 10 additions and 87 deletions

View file

@ -1138,7 +1138,6 @@ phutil_register_library_map(array(
'FundInitiativeBackController' => 'applications/fund/controller/FundInitiativeBackController.php',
'FundInitiativeBackerTransaction' => 'applications/fund/xaction/FundInitiativeBackerTransaction.php',
'FundInitiativeCloseController' => 'applications/fund/controller/FundInitiativeCloseController.php',
'FundInitiativeCommentController' => 'applications/fund/controller/FundInitiativeCommentController.php',
'FundInitiativeDescriptionTransaction' => 'applications/fund/xaction/FundInitiativeDescriptionTransaction.php',
'FundInitiativeEditController' => 'applications/fund/controller/FundInitiativeEditController.php',
'FundInitiativeEditEngine' => 'applications/fund/editor/FundInitiativeEditEngine.php',
@ -6103,7 +6102,6 @@ phutil_register_library_map(array(
'FundInitiativeBackController' => 'FundController',
'FundInitiativeBackerTransaction' => 'FundInitiativeTransactionType',
'FundInitiativeCloseController' => 'FundController',
'FundInitiativeCommentController' => 'FundController',
'FundInitiativeDescriptionTransaction' => 'FundInitiativeTransactionType',
'FundInitiativeEditController' => 'FundController',
'FundInitiativeEditEngine' => 'PhabricatorEditEngine',

View file

@ -42,7 +42,6 @@ final class PhabricatorFundApplication extends PhabricatorApplication {
'/fund/' => array(
'(?:query/(?P<queryKey>[^/]+)/)?' => 'FundInitiativeListController',
'create/' => 'FundInitiativeEditController',
'comment/(?P<id>[1-9]\d*)/' => 'FundInitiativeCommentController',
$this->getEditRoutePattern('edit/')
=> 'FundInitiativeEditController',
'close/(?P<id>\d+)/' => 'FundInitiativeCloseController',

View file

@ -1,63 +0,0 @@
<?php
final class FundInitiativeCommentController
extends FundController {
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
if (!$request->isFormPost()) {
return new Aphront400Response();
}
$initiative = id(new FundInitiativeQuery())
->setViewer($viewer)
->withIDs(array($id))
->executeOne();
if (!$initiative) {
return new Aphront404Response();
}
$is_preview = $request->isPreviewRequest();
$draft = PhabricatorDraft::buildFromRequest($request);
$view_uri = '/'.$initiative->getMonogram();
$xactions = array();
$xactions[] = id(new FundInitiativeTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
->attachComment(
id(new FundInitiativeTransactionComment())
->setContent($request->getStr('comment')));
$editor = id(new FundInitiativeEditor())
->setActor($viewer)
->setContinueOnNoEffect($request->isContinueRequest())
->setContentSourceFromRequest($request)
->setIsPreview($is_preview);
try {
$xactions = $editor->applyTransactions($initiative, $xactions);
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
return id(new PhabricatorApplicationTransactionNoEffectResponse())
->setCancelURI($view_uri)
->setException($ex);
}
if ($draft) {
$draft->replaceOrDelete();
}
if ($request->isAjax() && $is_preview) {
return id(new PhabricatorApplicationTransactionResponse())
->setViewer($viewer)
->setTransactions($xactions)
->setIsPreview($is_preview);
} else {
return id(new AphrontRedirectResponse())
->setURI($view_uri);
}
}
}

View file

@ -52,15 +52,16 @@ final class FundInitiativeViewController
$timeline = $this->buildTransactionTimeline(
$initiative,
new FundInitiativeTransactionQuery());
$timeline->setQuoteRef($initiative->getMonogram());
$add_comment = $this->buildCommentForm($initiative);
$comment_view = $this->buildCommentForm($initiative, $timeline);
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setCurtain($curtain)
->setMainColumn(array(
$timeline,
$add_comment,
$comment_view,
))
->addPropertySection(pht('Details'), $details);
@ -164,26 +165,14 @@ final class FundInitiativeViewController
return $curtain;
}
private function buildCommentForm(FundInitiative $initiative) {
private function buildCommentForm(FundInitiative $initiative, $timeline) {
$viewer = $this->getViewer();
$box = id(new FundInitiativeEditEngine())
->setViewer($viewer)
->buildEditEngineCommentView($initiative)
->setTransactionTimeline($timeline);
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$add_comment_header = $is_serious
? pht('Add Comment')
: pht('Add Liquidity');
$draft = PhabricatorDraft::newFromUserAndKey(
$viewer, $initiative->getPHID());
return id(new PhabricatorApplicationTransactionCommentView())
->setUser($viewer)
->setObjectPHID($initiative->getPHID())
->setDraft($draft)
->setHeaderText($add_comment_header)
->setAction(
$this->getApplicationURI('/comment/'.$initiative->getID().'/'))
->setSubmitButtonName(pht('Add Comment'));
return $box;
}

View file

@ -45,7 +45,7 @@ final class FundInitiativeMerchantTransaction
return pht(
'%s changed the merchant receiving funds from %s '.
'initiative from %s to %s.',
'from %s to %s.',
$this->renderAuthor(),
$this->renderObject(),
$old_merchant,