mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 14:00:56 +01:00
Update Macro comment form
Summary: Moves over to transaction commenting. Test Plan: Leave a comment (tested with TYPE_COMMENT still present). Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D17823
This commit is contained in:
parent
60a19e3646
commit
5307f51170
4 changed files with 13 additions and 83 deletions
|
@ -2975,7 +2975,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorMacroAudioBehaviorTransaction' => 'applications/macro/xaction/PhabricatorMacroAudioBehaviorTransaction.php',
|
||||
'PhabricatorMacroAudioController' => 'applications/macro/controller/PhabricatorMacroAudioController.php',
|
||||
'PhabricatorMacroAudioTransaction' => 'applications/macro/xaction/PhabricatorMacroAudioTransaction.php',
|
||||
'PhabricatorMacroCommentController' => 'applications/macro/controller/PhabricatorMacroCommentController.php',
|
||||
'PhabricatorMacroConfigOptions' => 'applications/macro/config/PhabricatorMacroConfigOptions.php',
|
||||
'PhabricatorMacroController' => 'applications/macro/controller/PhabricatorMacroController.php',
|
||||
'PhabricatorMacroDatasource' => 'applications/macro/typeahead/PhabricatorMacroDatasource.php',
|
||||
|
@ -8190,7 +8189,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorMacroAudioBehaviorTransaction' => 'PhabricatorMacroTransactionType',
|
||||
'PhabricatorMacroAudioController' => 'PhabricatorMacroController',
|
||||
'PhabricatorMacroAudioTransaction' => 'PhabricatorMacroTransactionType',
|
||||
'PhabricatorMacroCommentController' => 'PhabricatorMacroController',
|
||||
'PhabricatorMacroConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||
'PhabricatorMacroController' => 'PhabricatorController',
|
||||
'PhabricatorMacroDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||
|
|
|
@ -32,7 +32,6 @@ final class PhabricatorMacroApplication extends PhabricatorApplication {
|
|||
'(query/(?P<key>[^/]+)/)?' => 'PhabricatorMacroListController',
|
||||
'create/' => 'PhabricatorMacroEditController',
|
||||
'view/(?P<id>[1-9]\d*)/' => 'PhabricatorMacroViewController',
|
||||
'comment/(?P<id>[1-9]\d*)/' => 'PhabricatorMacroCommentController',
|
||||
$this->getEditRoutePattern('edit/')
|
||||
=> 'PhabricatorMacroEditController',
|
||||
'audio/(?P<id>[1-9]\d*)/' => 'PhabricatorMacroAudioController',
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorMacroCommentController
|
||||
extends PhabricatorMacroController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $request->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
if (!$request->isFormPost()) {
|
||||
return new Aphront400Response();
|
||||
}
|
||||
|
||||
$macro = id(new PhabricatorMacroQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->executeOne();
|
||||
if (!$macro) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$is_preview = $request->isPreviewRequest();
|
||||
$draft = PhabricatorDraft::buildFromRequest($request);
|
||||
|
||||
$view_uri = $this->getApplicationURI('/view/'.$macro->getID().'/');
|
||||
|
||||
$xactions = array();
|
||||
$xactions[] = id(new PhabricatorMacroTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
||||
->attachComment(
|
||||
id(new PhabricatorMacroTransactionComment())
|
||||
->setContent($request->getStr('comment')));
|
||||
|
||||
$editor = id(new PhabricatorMacroEditor())
|
||||
->setActor($viewer)
|
||||
->setContinueOnNoEffect($request->isContinueRequest())
|
||||
->setContentSourceFromRequest($request)
|
||||
->setIsPreview($is_preview);
|
||||
|
||||
try {
|
||||
$xactions = $editor->applyTransactions($macro, $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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -36,6 +36,8 @@ final class PhabricatorMacroViewController
|
|||
$macro,
|
||||
new PhabricatorMacroTransactionQuery());
|
||||
|
||||
$comment_form = $this->buildCommentForm($macro, $timeline);
|
||||
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setUser($viewer)
|
||||
->setPolicyObject($macro)
|
||||
|
@ -48,29 +50,13 @@ final class PhabricatorMacroViewController
|
|||
$header->setStatus('fa-ban', 'indigo', pht('Archived'));
|
||||
}
|
||||
|
||||
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
|
||||
|
||||
$comment_header = $is_serious
|
||||
? pht('Add Comment')
|
||||
: pht('Grovel in Awe');
|
||||
|
||||
$draft = PhabricatorDraft::newFromUserAndKey($viewer, $macro->getPHID());
|
||||
|
||||
$add_comment_form = id(new PhabricatorApplicationTransactionCommentView())
|
||||
->setUser($viewer)
|
||||
->setObjectPHID($macro->getPHID())
|
||||
->setDraft($draft)
|
||||
->setHeaderText($comment_header)
|
||||
->setAction($this->getApplicationURI('/comment/'.$macro->getID().'/'))
|
||||
->setSubmitButtonName(pht('Add Comment'));
|
||||
|
||||
$view = id(new PHUITwoColumnView())
|
||||
->setHeader($header)
|
||||
->setSubheader($subheader)
|
||||
->setCurtain($curtain)
|
||||
->setMainColumn(array(
|
||||
$timeline,
|
||||
$add_comment_form,
|
||||
$comment_form,
|
||||
))
|
||||
->addPropertySection(pht('Macro'), $file)
|
||||
->addPropertySection(pht('Details'), $details);
|
||||
|
@ -82,6 +68,16 @@ final class PhabricatorMacroViewController
|
|||
->appendChild($view);
|
||||
}
|
||||
|
||||
private function buildCommentForm(
|
||||
PhabricatorFileImageMacro $macro, $timeline) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
return id(new PhabricatorMacroEditEngine())
|
||||
->setViewer($viewer)
|
||||
->buildEditEngineCommentView($macro)
|
||||
->setTransactionTimeline($timeline);
|
||||
}
|
||||
|
||||
private function buildCurtain(
|
||||
PhabricatorFileImageMacro $macro) {
|
||||
$can_manage = $this->hasApplicationCapability(
|
||||
|
|
Loading…
Reference in a new issue