Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14043656
D14637.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D14637.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2605,7 +2605,6 @@
'PhabricatorPasswordSettingsPanel' => 'applications/settings/panel/PhabricatorPasswordSettingsPanel.php',
'PhabricatorPaste' => 'applications/paste/storage/PhabricatorPaste.php',
'PhabricatorPasteApplication' => 'applications/paste/application/PhabricatorPasteApplication.php',
- 'PhabricatorPasteCommentController' => 'applications/paste/controller/PhabricatorPasteCommentController.php',
'PhabricatorPasteConfigOptions' => 'applications/paste/config/PhabricatorPasteConfigOptions.php',
'PhabricatorPasteController' => 'applications/paste/controller/PhabricatorPasteController.php',
'PhabricatorPasteDAO' => 'applications/paste/storage/PhabricatorPasteDAO.php',
@@ -6800,7 +6799,6 @@
'PhabricatorSpacesInterface',
),
'PhabricatorPasteApplication' => 'PhabricatorApplication',
- 'PhabricatorPasteCommentController' => 'PhabricatorPasteController',
'PhabricatorPasteConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorPasteController' => 'PhabricatorController',
'PhabricatorPasteDAO' => 'PhabricatorLiskDAO',
diff --git a/src/applications/base/PhabricatorApplication.php b/src/applications/base/PhabricatorApplication.php
--- a/src/applications/base/PhabricatorApplication.php
+++ b/src/applications/base/PhabricatorApplication.php
@@ -640,7 +640,7 @@
'(?P<id>[0-9]\d*)/)?'.
'(?:'.
'(?:'.
- '(?P<editAction>parameters|nodefault)'.
+ '(?P<editAction>parameters|nodefault|comment)'.
'|'.
'(?:form/(?P<formKey>[^/]+))'.
')'.
diff --git a/src/applications/paste/application/PhabricatorPasteApplication.php b/src/applications/paste/application/PhabricatorPasteApplication.php
--- a/src/applications/paste/application/PhabricatorPasteApplication.php
+++ b/src/applications/paste/application/PhabricatorPasteApplication.php
@@ -41,7 +41,6 @@
'create/' => 'PhabricatorPasteEditController',
$this->getEditRoutePattern('edit/') => 'PhabricatorPasteEditController',
'raw/(?P<id>[1-9]\d*)/' => 'PhabricatorPasteRawController',
- 'comment/(?P<id>[1-9]\d*)/' => 'PhabricatorPasteCommentController',
),
);
}
diff --git a/src/applications/paste/controller/PhabricatorPasteCommentController.php b/src/applications/paste/controller/PhabricatorPasteCommentController.php
deleted file mode 100644
--- a/src/applications/paste/controller/PhabricatorPasteCommentController.php
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-
-final class PhabricatorPasteCommentController
- extends PhabricatorPasteController {
-
- public function handleRequest(AphrontRequest $request) {
- $viewer = $request->getViewer();
- $id = $request->getURIData('id');
-
- if (!$request->isFormPost()) {
- return new Aphront400Response();
- }
-
- $paste = id(new PhabricatorPasteQuery())
- ->setViewer($viewer)
- ->withIDs(array($id))
- ->executeOne();
- if (!$paste) {
- return new Aphront404Response();
- }
-
- $is_preview = $request->isPreviewRequest();
- $draft = PhabricatorDraft::buildFromRequest($request);
-
- $view_uri = $paste->getURI();
-
- $xactions = array();
- $xactions[] = id(new PhabricatorPasteTransaction())
- ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
- ->attachComment(
- id(new PhabricatorPasteTransactionComment())
- ->setContent($request->getStr('comment')));
-
- $editor = id(new PhabricatorPasteEditor())
- ->setActor($viewer)
- ->setContinueOnNoEffect($request->isContinueRequest())
- ->setContentSourceFromRequest($request)
- ->setIsPreview($is_preview);
-
- try {
- $xactions = $editor->applyTransactions($paste, $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);
- }
- }
-
-}
diff --git a/src/applications/paste/controller/PhabricatorPasteViewController.php b/src/applications/paste/controller/PhabricatorPasteViewController.php
--- a/src/applications/paste/controller/PhabricatorPasteViewController.php
+++ b/src/applications/paste/controller/PhabricatorPasteViewController.php
@@ -1,8 +1,5 @@
<?php
-/**
- * group paste
- */
final class PhabricatorPasteViewController extends PhabricatorPasteController {
private $highlightMap;
@@ -73,21 +70,9 @@
$paste,
new PhabricatorPasteTransactionQuery());
- $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
-
- $add_comment_header = $is_serious
- ? pht('Add Comment')
- : pht('Eat Paste');
-
- $draft = PhabricatorDraft::newFromUserAndKey($viewer, $paste->getPHID());
-
- $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())
- ->setUser($viewer)
- ->setObjectPHID($paste->getPHID())
- ->setDraft($draft)
- ->setHeaderText($add_comment_header)
- ->setAction($this->getApplicationURI('/comment/'.$paste->getID().'/'))
- ->setSubmitButtonName(pht('Add Comment'));
+ $comment_view = id(new PhabricatorPasteEditEngine())
+ ->setViewer($viewer)
+ ->buildEditEngineCommentView($paste);
return $this->newPage()
->setTitle($paste->getFullName())
@@ -101,7 +86,7 @@
$object_box,
$source_code,
$timeline,
- $add_comment_form,
+ $comment_view,
));
}
diff --git a/src/applications/paste/editor/PhabricatorPasteEditEngine.php b/src/applications/paste/editor/PhabricatorPasteEditEngine.php
--- a/src/applications/paste/editor/PhabricatorPasteEditEngine.php
+++ b/src/applications/paste/editor/PhabricatorPasteEditEngine.php
@@ -38,6 +38,15 @@
return pht('Create Paste');
}
+ protected function getCommentViewHeaderText($object) {
+ $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
+ if (!$is_serious) {
+ return pht('Eat Paste');
+ }
+
+ return parent::getCommentViewHeaderText($object);
+ }
+
protected function getObjectViewURI($object) {
return '/P'.$object->getID();
}
diff --git a/src/applications/transactions/editengine/PhabricatorEditEngine.php b/src/applications/transactions/editengine/PhabricatorEditEngine.php
--- a/src/applications/transactions/editengine/PhabricatorEditEngine.php
+++ b/src/applications/transactions/editengine/PhabricatorEditEngine.php
@@ -163,6 +163,22 @@
}
+ /**
+ * @task text
+ */
+ protected function getCommentViewHeaderText($object) {
+ return pht('Add Comment');
+ }
+
+
+ /**
+ * @task text
+ */
+ protected function getCommentViewButtonText($object) {
+ return pht('Add Comment');
+ }
+
+
/* -( Edit Engine Configuration )------------------------------------------ */
@@ -574,6 +590,8 @@
return $this->buildParametersResponse($object);
case 'nodefault':
return $this->buildNoDefaultResponse($object);
+ case 'comment':
+ return $this->buildCommentResponse($object);
default:
return $this->buildEditResponse($object);
}
@@ -854,6 +872,27 @@
$crumbs->addAction($action);
}
+ final public function buildEditEngineCommentView($object) {
+ $viewer = $this->getViewer();
+ $object_phid = $object->getPHID();
+
+ $header_text = $this->getCommentViewHeaderText($object);
+ $button_text = $this->getCommentViewButtonText($object);
+
+ // TODO: Drafts.
+ // $draft = PhabricatorDraft::newFromUserAndKey(
+ // $viewer,
+ // $object_phid);
+
+ $comment_uri = $this->getEditURI($object, 'comment/');
+
+ return id(new PhabricatorApplicationTransactionCommentView())
+ ->setUser($viewer)
+ ->setObjectPHID($object_phid)
+ ->setHeaderText($header_text)
+ ->setAction($comment_uri)
+ ->setSubmitButtonName($button_text);
+ }
/* -( Responding to HTTP Parameter Requests )------------------------------ */
@@ -911,6 +950,60 @@
->addCancelButton($cancel_uri);
}
+ private function buildCommentResponse($object) {
+ $viewer = $this->getViewer();
+
+ if ($this->getIsCreate()) {
+ return new Aphront404Response();
+ }
+
+ $controller = $this->getController();
+ $request = $controller->getRequest();
+
+ if (!$request->isFormPost()) {
+ return new Aphront400Response();
+ }
+
+ $is_preview = $request->isPreviewRequest();
+ $view_uri = $this->getObjectViewURI($object);
+
+ $template = $object->getApplicationTransactionTemplate();
+ $comment_template = $template->getApplicationTransactionCommentObject();
+
+ $xactions = array();
+
+ $xactions[] = id(clone $template)
+ ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
+ ->attachComment(
+ id(clone $comment_template)
+ ->setContent($request->getStr('comment')));
+
+ $editor = $object->getApplicationTransactionEditor()
+ ->setActor($viewer)
+ ->setContinueOnNoEffect($request->isContinueRequest())
+ ->setContentSourceFromRequest($request)
+ ->setIsPreview($is_preview);
+
+ try {
+ $xactions = $editor->applyTransactions($object, $xactions);
+ } catch (PhabricatorApplicationTransactionNoEffectException $ex) {
+ return id(new PhabricatorApplicationTransactionNoEffectResponse())
+ ->setCancelURI($view_uri)
+ ->setException($ex);
+ }
+
+ if ($request->isAjax() && $is_preview) {
+ return id(new PhabricatorApplicationTransactionResponse())
+ ->setViewer($viewer)
+ ->setTransactions($xactions)
+ ->setIsPreview($is_preview);
+ } else {
+ return id(new AphrontRedirectResponse())
+ ->setURI($view_uri);
+ }
+ }
+
+
/* -( Conduit )------------------------------------------------------------ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 13, 12:00 PM (5 d, 22 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6728737
Default Alt Text
D14637.diff (10 KB)
Attached To
Mode
D14637: Initial support for comments/append-edits in EditEngine
Attached
Detach File
Event Timeline
Log In to Comment