From d2e1dd0ef092bf455666fd2894ae7e7ac3f2e9e7 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 14 May 2017 13:39:54 -0700 Subject: [PATCH] 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 --- .../PhabricatorApplicationEditController.php | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/applications/meta/controller/PhabricatorApplicationEditController.php b/src/applications/meta/controller/PhabricatorApplicationEditController.php index c9f6a2cafb..f7c2eac81e 100644 --- a/src/applications/meta/controller/PhabricatorApplicationEditController.php +++ b/src/applications/meta/controller/PhabricatorApplicationEditController.php @@ -32,7 +32,6 @@ final class PhabricatorApplicationEditController if ($request->isFormPost()) { $xactions = array(); - $result = array(); $template = $application->getApplicationTransactionTemplate(); foreach ($application->getCapabilities() as $capability) { if (!$application->isCapabilityEditable($capability)) { @@ -47,8 +46,6 @@ final class PhabricatorApplicationEditController continue; } - $result[$capability] = $new; - $xactions[] = id(clone $template) ->setTransactionType( PhabricatorApplicationPolicyChangeTransaction::TRANSACTIONTYPE) @@ -58,25 +55,23 @@ final class PhabricatorApplicationEditController ->setNewValue($new); } - if ($result) { - $editor = id(new PhabricatorApplicationEditor()) - ->setActor($user) - ->setContentSourceFromRequest($request) - ->setContinueOnNoEffect(true) - ->setContinueOnMissingFields(true); + $editor = id(new PhabricatorApplicationEditor()) + ->setActor($user) + ->setContentSourceFromRequest($request) + ->setContinueOnNoEffect(true) + ->setContinueOnMissingFields(true); - try { - $editor->applyTransactions($application, $xactions); - return id(new AphrontRedirectResponse())->setURI($view_uri); - } catch (PhabricatorApplicationTransactionValidationException $ex) { - $validation_exception = $ex; - } - - return $this->newDialog() - ->setTitle('Validation Failed') - ->setValidationException($validation_exception) - ->addCancelButton($view_uri); + try { + $editor->applyTransactions($application, $xactions); + return id(new AphrontRedirectResponse())->setURI($view_uri); + } catch (PhabricatorApplicationTransactionValidationException $ex) { + $validation_exception = $ex; } + + return $this->newDialog() + ->setTitle(pht('Validation Failed')) + ->setValidationException($validation_exception) + ->addCancelButton($view_uri); } $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions(