mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +01:00
Change PhabricatorPhurlURLViewController to use EditEngine for commenting
Test Plan: Created a phurl, added some comments, confirmed that "Change Subscribers" and "Change Project Tags" are now available in the comment form. Reviewers: epriestley Reviewed By: epriestley Subscribers: chad, Korvin Maniphest Tasks: T11661 Differential Revision: https://secure.phabricator.com/D17686
This commit is contained in:
parent
b08b4cf0b5
commit
f801c7ae29
4 changed files with 11 additions and 81 deletions
|
@ -3445,7 +3445,6 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorPhurlURL' => 'applications/phurl/storage/PhabricatorPhurlURL.php',
|
'PhabricatorPhurlURL' => 'applications/phurl/storage/PhabricatorPhurlURL.php',
|
||||||
'PhabricatorPhurlURLAccessController' => 'applications/phurl/controller/PhabricatorPhurlURLAccessController.php',
|
'PhabricatorPhurlURLAccessController' => 'applications/phurl/controller/PhabricatorPhurlURLAccessController.php',
|
||||||
'PhabricatorPhurlURLAliasTransaction' => 'applications/phurl/xaction/PhabricatorPhurlURLAliasTransaction.php',
|
'PhabricatorPhurlURLAliasTransaction' => 'applications/phurl/xaction/PhabricatorPhurlURLAliasTransaction.php',
|
||||||
'PhabricatorPhurlURLCommentController' => 'applications/phurl/controller/PhabricatorPhurlURLCommentController.php',
|
|
||||||
'PhabricatorPhurlURLCreateCapability' => 'applications/phurl/capability/PhabricatorPhurlURLCreateCapability.php',
|
'PhabricatorPhurlURLCreateCapability' => 'applications/phurl/capability/PhabricatorPhurlURLCreateCapability.php',
|
||||||
'PhabricatorPhurlURLDatasource' => 'applications/phurl/typeahead/PhabricatorPhurlURLDatasource.php',
|
'PhabricatorPhurlURLDatasource' => 'applications/phurl/typeahead/PhabricatorPhurlURLDatasource.php',
|
||||||
'PhabricatorPhurlURLDescriptionTransaction' => 'applications/phurl/xaction/PhabricatorPhurlURLDescriptionTransaction.php',
|
'PhabricatorPhurlURLDescriptionTransaction' => 'applications/phurl/xaction/PhabricatorPhurlURLDescriptionTransaction.php',
|
||||||
|
@ -8711,7 +8710,6 @@ phutil_register_library_map(array(
|
||||||
),
|
),
|
||||||
'PhabricatorPhurlURLAccessController' => 'PhabricatorPhurlController',
|
'PhabricatorPhurlURLAccessController' => 'PhabricatorPhurlController',
|
||||||
'PhabricatorPhurlURLAliasTransaction' => 'PhabricatorPhurlURLTransactionType',
|
'PhabricatorPhurlURLAliasTransaction' => 'PhabricatorPhurlURLTransactionType',
|
||||||
'PhabricatorPhurlURLCommentController' => 'PhabricatorPhurlController',
|
|
||||||
'PhabricatorPhurlURLCreateCapability' => 'PhabricatorPolicyCapability',
|
'PhabricatorPhurlURLCreateCapability' => 'PhabricatorPolicyCapability',
|
||||||
'PhabricatorPhurlURLDatasource' => 'PhabricatorTypeaheadDatasource',
|
'PhabricatorPhurlURLDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||||
'PhabricatorPhurlURLDescriptionTransaction' => 'PhabricatorPhurlURLTransactionType',
|
'PhabricatorPhurlURLDescriptionTransaction' => 'PhabricatorPhurlURLTransactionType',
|
||||||
|
|
|
@ -48,8 +48,6 @@ final class PhabricatorPhurlApplication extends PhabricatorApplication {
|
||||||
'url/' => array(
|
'url/' => array(
|
||||||
$this->getEditRoutePattern('edit/')
|
$this->getEditRoutePattern('edit/')
|
||||||
=> 'PhabricatorPhurlURLEditController',
|
=> 'PhabricatorPhurlURLEditController',
|
||||||
'comment/(?P<id>[1-9]\d*)/'
|
|
||||||
=> 'PhabricatorPhurlURLCommentController',
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class PhabricatorPhurlURLCommentController
|
|
||||||
extends PhabricatorPhurlController {
|
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
|
||||||
if (!$request->isFormPost()) {
|
|
||||||
return new Aphront400Response();
|
|
||||||
}
|
|
||||||
|
|
||||||
$viewer = $request->getViewer();
|
|
||||||
$id = $request->getURIData('id');
|
|
||||||
|
|
||||||
$is_preview = $request->isPreviewRequest();
|
|
||||||
$draft = PhabricatorDraft::buildFromRequest($request);
|
|
||||||
|
|
||||||
$phurl = id(new PhabricatorPhurlURLQuery())
|
|
||||||
->setViewer($viewer)
|
|
||||||
->withIDs(array($id))
|
|
||||||
->executeOne();
|
|
||||||
if (!$phurl) {
|
|
||||||
return new Aphront404Response();
|
|
||||||
}
|
|
||||||
|
|
||||||
$view_uri = '/'.$phurl->getMonogram();
|
|
||||||
|
|
||||||
$xactions = array();
|
|
||||||
$xactions[] = id(new PhabricatorPhurlURLTransaction())
|
|
||||||
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
|
||||||
->attachComment(
|
|
||||||
id(new PhabricatorPhurlURLTransactionComment())
|
|
||||||
->setContent($request->getStr('comment')));
|
|
||||||
|
|
||||||
$editor = id(new PhabricatorPhurlURLEditor())
|
|
||||||
->setActor($viewer)
|
|
||||||
->setContinueOnNoEffect($request->isContinueRequest())
|
|
||||||
->setContentSourceFromRequest($request)
|
|
||||||
->setIsPreview($is_preview);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$xactions = $editor->applyTransactions($phurl, $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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -30,6 +30,7 @@ final class PhabricatorPhurlURLViewController
|
||||||
$timeline = $this->buildTransactionTimeline(
|
$timeline = $this->buildTransactionTimeline(
|
||||||
$url,
|
$url,
|
||||||
new PhabricatorPhurlURLTransactionQuery());
|
new PhabricatorPhurlURLTransactionQuery());
|
||||||
|
$timeline->setQuoteRef($url->getMonogram());
|
||||||
|
|
||||||
$header = $this->buildHeaderView($url);
|
$header = $this->buildHeaderView($url);
|
||||||
$curtain = $this->buildCurtain($url);
|
$curtain = $this->buildCurtain($url);
|
||||||
|
@ -39,20 +40,7 @@ final class PhabricatorPhurlURLViewController
|
||||||
->setErrors(array(pht('This URL is invalid due to a bad protocol.')))
|
->setErrors(array(pht('This URL is invalid due to a bad protocol.')))
|
||||||
->setIsHidden($url->isValid());
|
->setIsHidden($url->isValid());
|
||||||
|
|
||||||
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
|
$add_comment_form = $this->buildCommentForm($url, $timeline);
|
||||||
$add_comment_header = $is_serious
|
|
||||||
? pht('Add Comment')
|
|
||||||
: pht('More Cowbell');
|
|
||||||
$draft = PhabricatorDraft::newFromUserAndKey($viewer, $url->getPHID());
|
|
||||||
$comment_uri = $this->getApplicationURI(
|
|
||||||
'/url/comment/'.$url->getID().'/');
|
|
||||||
$add_comment_form = id(new PhabricatorApplicationTransactionCommentView())
|
|
||||||
->setUser($viewer)
|
|
||||||
->setObjectPHID($url->getPHID())
|
|
||||||
->setDraft($draft)
|
|
||||||
->setHeaderText($add_comment_header)
|
|
||||||
->setAction($comment_uri)
|
|
||||||
->setSubmitButtonName(pht('Add Comment'));
|
|
||||||
|
|
||||||
$view = id(new PHUITwoColumnView())
|
$view = id(new PHUITwoColumnView())
|
||||||
->setHeader($header)
|
->setHeader($header)
|
||||||
|
@ -72,7 +60,16 @@ final class PhabricatorPhurlURLViewController
|
||||||
array(
|
array(
|
||||||
$view,
|
$view,
|
||||||
));
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildCommentForm(PhabricatorPhurlURL $url, $timeline) {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
$box = id(new PhabricatorPhurlURLEditEngine())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->buildEditEngineCommentView($url)
|
||||||
|
->setTransactionTimeline($timeline);
|
||||||
|
|
||||||
|
return $box;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildHeaderView(PhabricatorPhurlURL $url) {
|
private function buildHeaderView(PhabricatorPhurlURL $url) {
|
||||||
|
|
Loading…
Reference in a new issue