1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Differential - return a better response for validation error cases

Summary: Fixes T6989. Basically return a nice dialogue like we do for "NoEffect" transactions. This is a little prettier than the other dialogue was. Also, stop adding TYPE_EDGE as a transaction type as we end up having it 2x, which then makes the error get validated 2x.

Test Plan: tried to add myself as a reviewer and got a nice error message.

Reviewers: chad, epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T6989

Differential Revision: https://secure.phabricator.com/D11448
This commit is contained in:
Bob Trahan 2015-01-20 13:59:17 -08:00
parent 77bcbed9f9
commit 847ff549ce
4 changed files with 54 additions and 3 deletions

View file

@ -1290,6 +1290,7 @@ phutil_register_library_map(array(
'PhabricatorApplicationTransactionTransactionPHIDType' => 'applications/transactions/phid/PhabricatorApplicationTransactionTransactionPHIDType.php', 'PhabricatorApplicationTransactionTransactionPHIDType' => 'applications/transactions/phid/PhabricatorApplicationTransactionTransactionPHIDType.php',
'PhabricatorApplicationTransactionValidationError' => 'applications/transactions/error/PhabricatorApplicationTransactionValidationError.php', 'PhabricatorApplicationTransactionValidationError' => 'applications/transactions/error/PhabricatorApplicationTransactionValidationError.php',
'PhabricatorApplicationTransactionValidationException' => 'applications/transactions/exception/PhabricatorApplicationTransactionValidationException.php', 'PhabricatorApplicationTransactionValidationException' => 'applications/transactions/exception/PhabricatorApplicationTransactionValidationException.php',
'PhabricatorApplicationTransactionValidationResponse' => 'applications/transactions/response/PhabricatorApplicationTransactionValidationResponse.php',
'PhabricatorApplicationTransactionValueController' => 'applications/transactions/controller/PhabricatorApplicationTransactionValueController.php', 'PhabricatorApplicationTransactionValueController' => 'applications/transactions/controller/PhabricatorApplicationTransactionValueController.php',
'PhabricatorApplicationTransactionView' => 'applications/transactions/view/PhabricatorApplicationTransactionView.php', 'PhabricatorApplicationTransactionView' => 'applications/transactions/view/PhabricatorApplicationTransactionView.php',
'PhabricatorApplicationUninstallController' => 'applications/meta/controller/PhabricatorApplicationUninstallController.php', 'PhabricatorApplicationUninstallController' => 'applications/meta/controller/PhabricatorApplicationUninstallController.php',
@ -4476,6 +4477,7 @@ phutil_register_library_map(array(
'PhabricatorApplicationTransactionTransactionPHIDType' => 'PhabricatorPHIDType', 'PhabricatorApplicationTransactionTransactionPHIDType' => 'PhabricatorPHIDType',
'PhabricatorApplicationTransactionValidationError' => 'Phobject', 'PhabricatorApplicationTransactionValidationError' => 'Phobject',
'PhabricatorApplicationTransactionValidationException' => 'Exception', 'PhabricatorApplicationTransactionValidationException' => 'Exception',
'PhabricatorApplicationTransactionValidationResponse' => 'AphrontProxyResponse',
'PhabricatorApplicationTransactionValueController' => 'PhabricatorApplicationTransactionController', 'PhabricatorApplicationTransactionValueController' => 'PhabricatorApplicationTransactionController',
'PhabricatorApplicationTransactionView' => 'AphrontView', 'PhabricatorApplicationTransactionView' => 'AphrontView',
'PhabricatorApplicationUninstallController' => 'PhabricatorApplicationsController', 'PhabricatorApplicationUninstallController' => 'PhabricatorApplicationsController',

View file

@ -127,8 +127,9 @@ final class DifferentialCommentSaveController
->setCancelURI($revision_uri) ->setCancelURI($revision_uri)
->setException($ex); ->setException($ex);
} catch (PhabricatorApplicationTransactionValidationException $ex) { } catch (PhabricatorApplicationTransactionValidationException $ex) {
// TODO: Provide a nice Response for rendering these in a clean way. return id(new PhabricatorApplicationTransactionValidationResponse())
throw $ex; ->setCancelURI($revision_uri)
->setException($ex);
} }
$user = $request->getUser(); $user = $request->getUser();

View file

@ -55,7 +55,6 @@ final class DifferentialTransactionEditor
$types = parent::getTransactionTypes(); $types = parent::getTransactionTypes();
$types[] = PhabricatorTransactions::TYPE_COMMENT; $types[] = PhabricatorTransactions::TYPE_COMMENT;
$types[] = PhabricatorTransactions::TYPE_EDGE;
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;

View file

@ -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);
}
}