Page MenuHomePhabricator

D11448.id27520.diff
No OneTemporary

D11448.id27520.diff

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
@@ -1290,6 +1290,7 @@
'PhabricatorApplicationTransactionTransactionPHIDType' => 'applications/transactions/phid/PhabricatorApplicationTransactionTransactionPHIDType.php',
'PhabricatorApplicationTransactionValidationError' => 'applications/transactions/error/PhabricatorApplicationTransactionValidationError.php',
'PhabricatorApplicationTransactionValidationException' => 'applications/transactions/exception/PhabricatorApplicationTransactionValidationException.php',
+ 'PhabricatorApplicationTransactionValidationResponse' => 'applications/transactions/response/PhabricatorApplicationTransactionValidationResponse.php',
'PhabricatorApplicationTransactionValueController' => 'applications/transactions/controller/PhabricatorApplicationTransactionValueController.php',
'PhabricatorApplicationTransactionView' => 'applications/transactions/view/PhabricatorApplicationTransactionView.php',
'PhabricatorApplicationUninstallController' => 'applications/meta/controller/PhabricatorApplicationUninstallController.php',
@@ -4476,6 +4477,7 @@
'PhabricatorApplicationTransactionTransactionPHIDType' => 'PhabricatorPHIDType',
'PhabricatorApplicationTransactionValidationError' => 'Phobject',
'PhabricatorApplicationTransactionValidationException' => 'Exception',
+ 'PhabricatorApplicationTransactionValidationResponse' => 'AphrontProxyResponse',
'PhabricatorApplicationTransactionValueController' => 'PhabricatorApplicationTransactionController',
'PhabricatorApplicationTransactionView' => 'AphrontView',
'PhabricatorApplicationUninstallController' => 'PhabricatorApplicationsController',
diff --git a/src/applications/differential/controller/DifferentialCommentSaveController.php b/src/applications/differential/controller/DifferentialCommentSaveController.php
--- a/src/applications/differential/controller/DifferentialCommentSaveController.php
+++ b/src/applications/differential/controller/DifferentialCommentSaveController.php
@@ -127,8 +127,9 @@
->setCancelURI($revision_uri)
->setException($ex);
} catch (PhabricatorApplicationTransactionValidationException $ex) {
- // TODO: Provide a nice Response for rendering these in a clean way.
- throw $ex;
+ return id(new PhabricatorApplicationTransactionValidationResponse())
+ ->setCancelURI($revision_uri)
+ ->setException($ex);
}
$user = $request->getUser();
diff --git a/src/applications/differential/editor/DifferentialTransactionEditor.php b/src/applications/differential/editor/DifferentialTransactionEditor.php
--- a/src/applications/differential/editor/DifferentialTransactionEditor.php
+++ b/src/applications/differential/editor/DifferentialTransactionEditor.php
@@ -55,7 +55,6 @@
$types = parent::getTransactionTypes();
$types[] = PhabricatorTransactions::TYPE_COMMENT;
- $types[] = PhabricatorTransactions::TYPE_EDGE;
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
diff --git a/src/applications/transactions/response/PhabricatorApplicationTransactionValidationResponse.php b/src/applications/transactions/response/PhabricatorApplicationTransactionValidationResponse.php
new file mode 100644
--- /dev/null
+++ b/src/applications/transactions/response/PhabricatorApplicationTransactionValidationResponse.php
@@ -0,0 +1,49 @@
+<?php
+
+final class PhabricatorApplicationTransactionValidationResponse
+ extends AphrontProxyResponse {
+
+ private $viewer;
+ private $exception;
+ private $cancelURI;
+
+ public function setCancelURI($cancel_uri) {
+ $this->cancelURI = $cancel_uri;
+ return $this;
+ }
+
+ public function setException(
+ PhabricatorApplicationTransactionValidationException $exception) {
+ $this->exception = $exception;
+ return $this;
+ }
+
+ protected function buildProxy() {
+ return new AphrontDialogResponse();
+ }
+
+ public function reduceProxyResponse() {
+ $request = $this->getRequest();
+
+ $ex = $this->exception;
+ $title = pht('Validation Errors');
+
+ $dialog = id(new AphrontDialogView())
+ ->setUser($request->getUser())
+ ->setTitle($title);
+
+ $list = array();
+ foreach ($ex->getErrors() as $error) {
+ $list[] = phutil_tag(
+ 'li',
+ array(),
+ $error->getMessage());
+ }
+
+ $dialog->appendChild(phutil_tag('ul', array(), $list));
+ $dialog->addCancelButton($this->cancelURI);
+
+ return $this->getProxy()->setDialog($dialog);
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Sat, Oct 19, 1:44 PM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6732390
Default Alt Text
D11448.id27520.diff (4 KB)

Event Timeline