From 8512f9358e60573011d935b4ae2310c4743db496 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 9 May 2016 07:01:37 -0700 Subject: [PATCH] Update redirect/cancel URIs for repository dialogs Summary: Ref T10923. Some of the dialogs ("Deactivate Repository", "Test Automation", etc.) had cancel or redirect URIs which I missed originally. Go through them and make sure they all point to the right places. Also removed one unused controller which I missed the first time around. Test Plan: - Opened all these dialogs in a new tab with Command-Click. - Clicked every "cancel" and "submit" button on all of these dialogs. - Got consistently sent to the place I came from. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10923 Differential Revision: https://secure.phabricator.com/D15867 --- src/__phutil_library_map__.php | 2 - ...fusionRepositoryEditActivateController.php | 30 +++-- ...usionRepositoryEditDangerousController.php | 48 +++---- ...iffusionRepositoryEditDeleteController.php | 6 +- ...iffusionRepositoryEditUpdateController.php | 8 +- .../DiffusionRepositorySymbolsController.php | 120 ------------------ ...sionRepositoryTestAutomationController.php | 8 +- 7 files changed, 55 insertions(+), 167 deletions(-) delete mode 100644 src/applications/diffusion/controller/DiffusionRepositorySymbolsController.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 380ed6b3ac..6b71b47c43 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -774,7 +774,6 @@ phutil_register_library_map(array( 'DiffusionRepositoryStagingManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryStagingManagementPanel.php', 'DiffusionRepositoryStatusManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryStatusManagementPanel.php', 'DiffusionRepositoryStorageManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryStorageManagementPanel.php', - 'DiffusionRepositorySymbolsController' => 'applications/diffusion/controller/DiffusionRepositorySymbolsController.php', 'DiffusionRepositorySymbolsManagementPanel' => 'applications/diffusion/management/DiffusionRepositorySymbolsManagementPanel.php', 'DiffusionRepositoryTag' => 'applications/diffusion/data/DiffusionRepositoryTag.php', 'DiffusionRepositoryTestAutomationController' => 'applications/diffusion/controller/DiffusionRepositoryTestAutomationController.php', @@ -4994,7 +4993,6 @@ phutil_register_library_map(array( 'DiffusionRepositoryStagingManagementPanel' => 'DiffusionRepositoryManagementPanel', 'DiffusionRepositoryStatusManagementPanel' => 'DiffusionRepositoryManagementPanel', 'DiffusionRepositoryStorageManagementPanel' => 'DiffusionRepositoryManagementPanel', - 'DiffusionRepositorySymbolsController' => 'DiffusionRepositoryEditController', 'DiffusionRepositorySymbolsManagementPanel' => 'DiffusionRepositoryManagementPanel', 'DiffusionRepositoryTag' => 'Phobject', 'DiffusionRepositoryTestAutomationController' => 'DiffusionRepositoryEditController', diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditActivateController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditActivateController.php index 55caaa59b9..5105ff6ee8 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryEditActivateController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryEditActivateController.php @@ -13,7 +13,9 @@ final class DiffusionRepositoryEditActivateController $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); - $edit_uri = $this->getRepositoryControllerURI($repository, 'edit/'); + $panel_uri = id(new DiffusionRepositoryBasicsManagementPanel()) + ->setRepository($repository) + ->getPanelURI(); if ($request->isFormPost()) { if (!$repository->isTracked()) { @@ -33,24 +35,24 @@ final class DiffusionRepositoryEditActivateController ->setActor($viewer) ->applyTransactions($repository, array($xaction)); - return id(new AphrontReloadResponse())->setURI($edit_uri); + return id(new AphrontReloadResponse())->setURI($panel_uri); } if ($repository->isTracked()) { - return $this->newDialog() - ->setTitle(pht('Deactivate Repository?')) - ->appendChild( - pht('Deactivate this repository?')) - ->addSubmitButton(pht('Deactivate Repository')) - ->addCancelButton($edit_uri); + $title = pht('Deactivate Repository'); + $body = pht('Deactivate this repository?'); + $submit = pht('Deactivate Repository'); } else { - return $this->newDialog() - ->setTitle(pht('Activate Repository?')) - ->appendChild( - pht('Activate this repository?')) - ->addSubmitButton(pht('Activate Repository')) - ->addCancelButton($edit_uri); + $title = pht('Activate Repository'); + $body = pht('Activate this repository?'); + $submit = pht('Activate Repository'); } + + return $this->newDialog() + ->setTitle($title) + ->appendChild($body) + ->addSubmitButton($submit) + ->addCancelButton($panel_uri); } } diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditDangerousController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditDangerousController.php index f2a49f820a..f24a23bb8e 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryEditDangerousController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryEditDangerousController.php @@ -13,7 +13,9 @@ final class DiffusionRepositoryEditDangerousController $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); - $edit_uri = $this->getRepositoryControllerURI($repository, 'edit/'); + $panel_uri = id(new DiffusionRepositoryBasicsManagementPanel()) + ->setRepository($repository) + ->getPanelURI(); if (!$repository->canAllowDangerousChanges()) { if ($repository->isSVN()) { @@ -24,7 +26,7 @@ final class DiffusionRepositoryEditDangerousController 'It is not possible for users to push any dangerous changes '. 'to a Subversion repository. Pushes to a Subversion repository '. 'can always be reverted and never destroy data.')) - ->addCancelButton($edit_uri); + ->addCancelButton($panel_uri); } else { return $this->newDialog() ->setTitle(pht('Unprotectable Repository')) @@ -33,7 +35,7 @@ final class DiffusionRepositoryEditDangerousController 'This repository can not be protected from dangerous changes '. 'because Phabricator does not control what users are allowed '. 'to push to it.')) - ->addCancelButton($edit_uri); + ->addCancelButton($panel_uri); } } @@ -48,33 +50,33 @@ final class DiffusionRepositoryEditDangerousController ->setActor($viewer) ->applyTransactions($repository, array($xaction)); - return id(new AphrontReloadResponse())->setURI($edit_uri); + return id(new AphrontReloadResponse())->setURI($panel_uri); } $force = phutil_tag('tt', array(), '--force'); if ($repository->shouldAllowDangerousChanges()) { - return $this->newDialog() - ->setTitle(pht('Prevent Dangerous changes?')) - ->appendChild( - pht( - 'It will no longer be possible to delete branches from this '. - 'repository, or %s push to this repository.', - $force)) - ->addSubmitButton(pht('Prevent Dangerous Changes')) - ->addCancelButton($edit_uri); + $title = pht('Prevent Dangerous Changes'); + $body = pht( + 'It will no longer be possible to delete branches from this '. + 'repository, or %s push to this repository.', + $force); + $submit = pht('Prevent Dangerous Changes'); } else { - return $this->newDialog() - ->setTitle(pht('Allow Dangerous Changes?')) - ->appendChild( - pht( - 'If you allow dangerous changes, it will be possible to delete '. - 'branches and %s push this repository. These operations can '. - 'alter a repository in a way that is difficult to recover from.', - $force)) - ->addSubmitButton(pht('Allow Dangerous Changes')) - ->addCancelButton($edit_uri); + $title = pht('Allow Dangerous Changes'); + $body = pht( + 'If you allow dangerous changes, it will be possible to delete '. + 'branches and %s push this repository. These operations can '. + 'alter a repository in a way that is difficult to recover from.', + $force); + $submit = pht('Allow Dangerous Changes'); } + + return $this->newDialog() + ->setTitle($title) + ->appendParagraph($body) + ->addSubmitButton($submit) + ->addCancelButton($panel_uri); } } diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditDeleteController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditDeleteController.php index 074e79445b..48207fd7d3 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryEditDeleteController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryEditDeleteController.php @@ -13,7 +13,9 @@ final class DiffusionRepositoryEditDeleteController $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); - $edit_uri = $this->getRepositoryControllerURI($repository, 'edit/'); + $panel_uri = id(new DiffusionRepositoryBasicsManagementPanel()) + ->setRepository($repository) + ->getPanelURI(); $dialog = new AphrontDialogView(); $text_1 = pht( @@ -40,7 +42,7 @@ final class DiffusionRepositoryEditDeleteController return $this->newDialog() ->setTitle(pht('Really want to delete the repository?')) ->appendChild($body) - ->addCancelButton($edit_uri, pht('Okay')); + ->addCancelButton($panel_uri, pht('Okay')); } } diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditUpdateController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditUpdateController.php index 303959d098..2aa2f6d474 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryEditUpdateController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryEditUpdateController.php @@ -13,7 +13,9 @@ final class DiffusionRepositoryEditUpdateController $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); - $edit_uri = $this->getRepositoryControllerURI($repository, 'edit/'); + $panel_uri = id(new DiffusionRepositoryStatusManagementPanel()) + ->setRepository($repository) + ->getPanelURI(); if ($request->isFormPost()) { $params = array( @@ -26,7 +28,7 @@ final class DiffusionRepositoryEditUpdateController ->setUser($viewer) ->execute(); - return id(new AphrontRedirectResponse())->setURI($edit_uri); + return id(new AphrontRedirectResponse())->setURI($panel_uri); } $doc_name = 'Diffusion User Guide: Repository Updates'; @@ -58,7 +60,7 @@ final class DiffusionRepositoryEditUpdateController 'To learn more about how Phabricator updates repositories, '. 'read %s in the documentation.', $doc_link)) - ->addCancelButton($edit_uri) + ->addCancelButton($panel_uri) ->addSubmitButton(pht('Schedule Update')); } diff --git a/src/applications/diffusion/controller/DiffusionRepositorySymbolsController.php b/src/applications/diffusion/controller/DiffusionRepositorySymbolsController.php deleted file mode 100644 index 06ce23032a..0000000000 --- a/src/applications/diffusion/controller/DiffusionRepositorySymbolsController.php +++ /dev/null @@ -1,120 +0,0 @@ -loadDiffusionContextForEdit(); - if ($response) { - return $response; - } - - $viewer = $this->getViewer(); - $drequest = $this->getDiffusionRequest(); - $repository = $drequest->getRepository(); - - $edit_uri = $this->getRepositoryControllerURI($repository, 'edit/'); - - $v_sources = $repository->getSymbolSources(); - $v_languages = $repository->getSymbolLanguages(); - if ($v_languages) { - $v_languages = implode(', ', $v_languages); - } - $errors = array(); - - if ($request->isFormPost()) { - $v_sources = $request->getArr('sources'); - $v_languages = $request->getStrList('languages'); - $v_languages = array_map('phutil_utf8_strtolower', $v_languages); - - if (!$errors) { - $xactions = array(); - $template = id(new PhabricatorRepositoryTransaction()); - - $type_sources = PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES; - $type_lang = PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE; - - $xactions[] = id(clone $template) - ->setTransactionType($type_sources) - ->setNewValue($v_sources); - - $xactions[] = id(clone $template) - ->setTransactionType($type_lang) - ->setNewValue($v_languages); - - try { - id(new PhabricatorRepositoryEditor()) - ->setContinueOnNoEffect(true) - ->setContentSourceFromRequest($request) - ->setActor($viewer) - ->applyTransactions($repository, $xactions); - - return id(new AphrontRedirectResponse())->setURI($edit_uri); - } catch (Exception $ex) { - $errors[] = $ex->getMessage(); - } - } - } - - $crumbs = $this->buildApplicationCrumbs(); - $crumbs->addTextCrumb(pht('Edit Symbols')); - - $title = pht('Edit Symbols (%s)', $repository->getName()); - $header = id(new PHUIHeaderView()) - ->setHeader($title) - ->setHeaderIcon('fa-pencil'); - - $form = id(new AphrontFormView()) - ->setUser($viewer) - ->appendRemarkupInstructions($this->getInstructions()) - ->appendChild( - id(new AphrontFormTextControl()) - ->setName('languages') - ->setLabel(pht('Indexed Languages')) - ->setCaption(pht( - 'File extensions, separate with commas, for example: php, py. '. - 'Leave blank for "any".')) - ->setValue($v_languages)) - - ->appendControl( - id(new AphrontFormTokenizerControl()) - ->setName('sources') - ->setLabel(pht('Uses Symbols From')) - ->setDatasource(new DiffusionRepositoryDatasource()) - ->setValue($v_sources)) - - ->appendChild( - id(new AphrontFormSubmitControl()) - ->setValue(pht('Save')) - ->addCancelButton($edit_uri)); - - $form_box = id(new PHUIObjectBoxView()) - ->setHeaderText(pht('Symbols')) - ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) - ->setForm($form) - ->setFormErrors($errors); - - $view = id(new PHUITwoColumnView()) - ->setHeader($header) - ->setFooter(array( - $form_box, - )); - - return $this->newPage() - ->setTitle($title) - ->setCrumbs($crumbs) - ->appendChild($view); - } - - private function getInstructions() { - return pht(<<getDiffusionRequest(); $repository = $drequest->getRepository(); - $edit_uri = $this->getRepositoryControllerURI($repository, 'edit/'); + $panel_uri = id(new DiffusionRepositoryAutomationManagementPanel()) + ->setRepository($repository) + ->getPanelURI(); if (!$repository->canPerformAutomation()) { return $this->newDialog() @@ -23,7 +25,7 @@ final class DiffusionRepositoryTestAutomationController 'You can not run a configuration test for this repository '. 'because you have not configured repository automation yet. '. 'Configure it first, then test the configuration.')) - ->addCancelButton($edit_uri); + ->addCancelButton($panel_uri); } if ($request->isFormPost()) { @@ -63,7 +65,7 @@ final class DiffusionRepositoryTestAutomationController 'If you run into write failures despite passing this test, '. 'it suggests that your setup is nearly correct but authentication '. 'is probably not fully configured.')) - ->addCancelButton($edit_uri) + ->addCancelButton($panel_uri) ->addSubmitButton(pht('Start Test')); }