From d1ed816e618b8742dc618fa49ff1eee5da90e5ca Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 29 Oct 2013 12:26:07 -0700 Subject: [PATCH] Move "Delete Repository" stuff to Diffusion Summary: Ref T2231. This just moves the "Delete" dialog from Repositories to Diffusion. This dialog just shows instructions and isn't interesting. Test Plan: {F75093} Reviewers: btrahan, chad Reviewed By: chad CC: aran Maniphest Tasks: T2231 Differential Revision: https://secure.phabricator.com/D7412 --- src/__phutil_library_map__.php | 6 +-- .../PhabricatorApplicationDiffusion.php | 1 + ...ffusionRepositoryEditDeleteController.php} | 43 ++++++++++--------- .../DiffusionRepositoryEditMainController.php | 8 ++++ .../PhabricatorRepositoryListController.php | 11 ----- 5 files changed, 34 insertions(+), 35 deletions(-) rename src/applications/{repository/controller/PhabricatorRepositoryDeleteController.php => diffusion/controller/DiffusionRepositoryEditDeleteController.php} (53%) diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 526ac8dc43..9511bceb1f 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -509,6 +509,7 @@ phutil_register_library_map(array( 'DiffusionRepositoryEditBasicController' => 'applications/diffusion/controller/DiffusionRepositoryEditBasicController.php', 'DiffusionRepositoryEditBranchesController' => 'applications/diffusion/controller/DiffusionRepositoryEditBranchesController.php', 'DiffusionRepositoryEditController' => 'applications/diffusion/controller/DiffusionRepositoryEditController.php', + 'DiffusionRepositoryEditDeleteController' => 'applications/diffusion/controller/DiffusionRepositoryEditDeleteControler.php', 'DiffusionRepositoryEditEncodingController' => 'applications/diffusion/controller/DiffusionRepositoryEditEncodingController.php', 'DiffusionRepositoryEditLocalController' => 'applications/diffusion/controller/DiffusionRepositoryEditLocalController.php', 'DiffusionRepositoryEditMainController' => 'applications/diffusion/controller/DiffusionRepositoryEditMainController.php', @@ -1629,9 +1630,7 @@ phutil_register_library_map(array( 'PhabricatorRepositoryController' => 'applications/repository/controller/PhabricatorRepositoryController.php', 'PhabricatorRepositoryCreateController' => 'applications/repository/controller/PhabricatorRepositoryCreateController.php', 'PhabricatorRepositoryDAO' => 'applications/repository/storage/PhabricatorRepositoryDAO.php', - 'PhabricatorRepositoryDeleteController' => 'applications/repository/controller/PhabricatorRepositoryDeleteController.php', 'PhabricatorRepositoryDiscoveryEngine' => 'applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php', - 'PhabricatorRepositoryEditController' => 'applications/repository/controller/PhabricatorRepositoryEditController.php', 'PhabricatorRepositoryEditor' => 'applications/repository/editor/PhabricatorRepositoryEditor.php', 'PhabricatorRepositoryEngine' => 'applications/repository/engine/PhabricatorRepositoryEngine.php', 'PhabricatorRepositoryGitCommitChangeParserWorker' => 'applications/repository/worker/commitchangeparser/PhabricatorRepositoryGitCommitChangeParserWorker.php', @@ -2686,6 +2685,7 @@ phutil_register_library_map(array( 'DiffusionRepositoryEditBasicController' => 'DiffusionRepositoryEditController', 'DiffusionRepositoryEditBranchesController' => 'DiffusionRepositoryEditController', 'DiffusionRepositoryEditController' => 'DiffusionController', + 'DiffusionRepositoryEditDeleteController' => 'DiffusionRepositoryEditController', 'DiffusionRepositoryEditEncodingController' => 'DiffusionRepositoryEditController', 'DiffusionRepositoryEditLocalController' => 'DiffusionRepositoryEditController', 'DiffusionRepositoryEditMainController' => 'DiffusionRepositoryEditController', @@ -3956,9 +3956,7 @@ phutil_register_library_map(array( 'PhabricatorRepositoryController' => 'PhabricatorController', 'PhabricatorRepositoryCreateController' => 'PhabricatorRepositoryController', 'PhabricatorRepositoryDAO' => 'PhabricatorLiskDAO', - 'PhabricatorRepositoryDeleteController' => 'PhabricatorRepositoryController', 'PhabricatorRepositoryDiscoveryEngine' => 'PhabricatorRepositoryEngine', - 'PhabricatorRepositoryEditController' => 'PhabricatorRepositoryController', 'PhabricatorRepositoryEditor' => 'PhabricatorApplicationTransactionEditor', 'PhabricatorRepositoryGitCommitChangeParserWorker' => 'PhabricatorRepositoryCommitChangeParserWorker', 'PhabricatorRepositoryGitCommitMessageParserWorker' => 'PhabricatorRepositoryCommitMessageParserWorker', diff --git a/src/applications/diffusion/application/PhabricatorApplicationDiffusion.php b/src/applications/diffusion/application/PhabricatorApplicationDiffusion.php index 0aa3f20089..a13fba9528 100644 --- a/src/applications/diffusion/application/PhabricatorApplicationDiffusion.php +++ b/src/applications/diffusion/application/PhabricatorApplicationDiffusion.php @@ -74,6 +74,7 @@ final class PhabricatorApplicationDiffusion extends PhabricatorApplication { 'actions/' => 'DiffusionRepositoryEditActionsController', '(?Premote)/' => 'DiffusionRepositoryCreateController', 'local/' => 'DiffusionRepositoryEditLocalController', + 'delete/' => 'DiffusionRepositoryEditDeleteController', ), ), 'inline/' => array( diff --git a/src/applications/repository/controller/PhabricatorRepositoryDeleteController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditDeleteController.php similarity index 53% rename from src/applications/repository/controller/PhabricatorRepositoryDeleteController.php rename to src/applications/diffusion/controller/DiffusionRepositoryEditDeleteController.php index 284eb646c5..0a8c5d00a8 100644 --- a/src/applications/repository/controller/PhabricatorRepositoryDeleteController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryEditDeleteController.php @@ -1,34 +1,36 @@ id = $data['id']; - } +final class DiffusionRepositoryEditDeleteController + extends DiffusionRepositoryEditController { public function processRequest() { - $viewer = $this->getRequest()->getUser(); + $request = $this->getRequest(); + $viewer = $request->getUser(); + $drequest = $this->diffusionRequest; + $repository = $drequest->getRepository(); $repository = id(new PhabricatorRepositoryQuery()) ->setViewer($viewer) - ->withIDs(array($this->id)) + ->requireCapabilities( + array( + PhabricatorPolicyCapability::CAN_VIEW, + PhabricatorPolicyCapability::CAN_EDIT, + )) + ->withIDs(array($repository->getID())) ->executeOne(); if (!$repository) { return new Aphront404Response(); } - $request = $this->getRequest(); - - if ($request->isDialogFormPost()) { - return id(new AphrontRedirectResponse())->setURI('/repository/'); - } + $edit_uri = $this->getRepositoryControllerURI($repository, 'edit/'); $dialog = new AphrontDialogView(); - $text_1 = pht('If you really want to delete the repository, you must run:'); - $command = 'bin/repository delete '.$repository->getCallsign(); + $text_1 = pht( + 'If you really want to delete the repository, run this command from '. + 'the command line:'); + $command = csprintf( + 'phabricator/ $ ./bin/repository delete %s', + $repository->getCallsign()); $text_2 = pht('Repositories touch many objects and as such deletes are '. 'prohibitively expensive to run from the web UI.'); $body = phutil_tag( @@ -43,13 +45,14 @@ final class PhabricatorRepositoryDeleteController phutil_tag('p', array(), $text_2), )); - $dialog + $dialog = id(new AphrontDialogView()) ->setUser($request->getUser()) ->setTitle(pht('Really want to delete the repository?')) ->appendChild($body) - ->setSubmitURI('/repository/delete/'.$this->id.'/') - ->addSubmitButton(pht('Okay')); + ->addCancelButton($edit_uri, pht('Okay')); return id(new AphrontDialogResponse())->setDialog($dialog); } + + } diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php index 21eebaf6c9..32e5c0db30 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php @@ -174,6 +174,14 @@ final class DiffusionRepositoryEditMainController $view->addAction($activate); + $view->addAction( + id(new PhabricatorActionView()) + ->setName(pht('Delete Repository')) + ->setIcon('delete') + ->setHref( + $this->getRepositoryControllerURI($repository, 'edit/delete/')) + ->setWorkflow(true)); + return $view; } diff --git a/src/applications/repository/controller/PhabricatorRepositoryListController.php b/src/applications/repository/controller/PhabricatorRepositoryListController.php index b8d289a7cb..535cf69cdb 100644 --- a/src/applications/repository/controller/PhabricatorRepositoryListController.php +++ b/src/applications/repository/controller/PhabricatorRepositoryListController.php @@ -41,14 +41,6 @@ final class PhabricatorRepositoryListController 'href' => '/repository/edit/'.$repo->getID().'/', ), 'Edit'), - javelin_tag( - 'a', - array( - 'class' => 'button small grey', - 'href' => '/repository/delete/'.$repo->getID().'/', - 'sigil' => 'workflow', - ), - 'Delete'), ); } @@ -60,7 +52,6 @@ final class PhabricatorRepositoryListController 'Type', 'Diffusion', '', - '' )); $table->setColumnClasses( array( @@ -69,7 +60,6 @@ final class PhabricatorRepositoryListController null, null, 'action', - 'action', )); $table->setColumnVisibility( @@ -79,7 +69,6 @@ final class PhabricatorRepositoryListController true, true, $is_admin, - $is_admin, )); $panel = new AphrontPanelView();