1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

In Applications, always redirect back to the detail page after edits

Summary:
Ref T12685. When you edit an application's policies but don't make any changes, you currently get stuck on the same page. This isn't how other edit screens work, and I think it's a holdover from eras long ago.

Make it consistent with other applications.

Also, fix a missing `pht()`.

Test Plan:
  - Edited an application configuation.
  - Clicked "Save" without making changes.
  - After patch, was redirected back to detail page like in other applications.

Reviewers: chad, amckinley

Reviewed By: chad

Maniphest Tasks: T12685

Differential Revision: https://secure.phabricator.com/D17877
This commit is contained in:
epriestley 2017-05-14 13:39:54 -07:00
parent 95925ad58f
commit d2e1dd0ef0

View file

@ -32,7 +32,6 @@ final class PhabricatorApplicationEditController
if ($request->isFormPost()) { if ($request->isFormPost()) {
$xactions = array(); $xactions = array();
$result = array();
$template = $application->getApplicationTransactionTemplate(); $template = $application->getApplicationTransactionTemplate();
foreach ($application->getCapabilities() as $capability) { foreach ($application->getCapabilities() as $capability) {
if (!$application->isCapabilityEditable($capability)) { if (!$application->isCapabilityEditable($capability)) {
@ -47,8 +46,6 @@ final class PhabricatorApplicationEditController
continue; continue;
} }
$result[$capability] = $new;
$xactions[] = id(clone $template) $xactions[] = id(clone $template)
->setTransactionType( ->setTransactionType(
PhabricatorApplicationPolicyChangeTransaction::TRANSACTIONTYPE) PhabricatorApplicationPolicyChangeTransaction::TRANSACTIONTYPE)
@ -58,25 +55,23 @@ final class PhabricatorApplicationEditController
->setNewValue($new); ->setNewValue($new);
} }
if ($result) { $editor = id(new PhabricatorApplicationEditor())
$editor = id(new PhabricatorApplicationEditor()) ->setActor($user)
->setActor($user) ->setContentSourceFromRequest($request)
->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true)
->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true);
->setContinueOnMissingFields(true);
try { try {
$editor->applyTransactions($application, $xactions); $editor->applyTransactions($application, $xactions);
return id(new AphrontRedirectResponse())->setURI($view_uri); return id(new AphrontRedirectResponse())->setURI($view_uri);
} catch (PhabricatorApplicationTransactionValidationException $ex) { } catch (PhabricatorApplicationTransactionValidationException $ex) {
$validation_exception = $ex; $validation_exception = $ex;
}
return $this->newDialog()
->setTitle('Validation Failed')
->setValidationException($validation_exception)
->addCancelButton($view_uri);
} }
return $this->newDialog()
->setTitle(pht('Validation Failed'))
->setValidationException($validation_exception)
->addCancelButton($view_uri);
} }
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions( $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions(