From 19b23e2dd06d6431ae2ef81683eb47041fe94df4 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 5 May 2011 12:53:39 -0700 Subject: [PATCH] Fix repository deletion Summary: I never actually wrote this controller. Test Plan: Deleted a repository via web UI. Reviewed By: tuomaspelkonen Reviewers: tuomaspelkonen, jungejason, aran Commenters: aran CC: aran, tuomaspelkonen, epriestley Differential Revision: 231 --- src/__phutil_library_map__.php | 2 + .../PhabricatorRepositoryDeleteController.php | 56 +++++++++++++++++++ .../repository/controller/delete/__init__.php | 20 +++++++ .../PhabricatorRepositoryListController.php | 3 +- .../repository/controller/list/__init__.php | 1 + 5 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 src/applications/repository/controller/delete/PhabricatorRepositoryDeleteController.php create mode 100644 src/applications/repository/controller/delete/__init__.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 02ba6cd0ef..1751d70910 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -402,6 +402,7 @@ phutil_register_library_map(array( 'PhabricatorRepositoryDAO' => 'applications/repository/storage/base', 'PhabricatorRepositoryDaemon' => 'applications/repository/daemon/base', 'PhabricatorRepositoryDefaultCommitMessageDetailParser' => 'applications/repository/parser/default', + 'PhabricatorRepositoryDeleteController' => 'applications/repository/controller/delete', 'PhabricatorRepositoryEditController' => 'applications/repository/controller/edit', 'PhabricatorRepositoryGitCommitChangeParserWorker' => 'applications/repository/worker/commitchangeparser/git', 'PhabricatorRepositoryGitCommitDiscoveryDaemon' => 'applications/repository/daemon/commitdiscovery/git', @@ -804,6 +805,7 @@ phutil_register_library_map(array( 'PhabricatorRepositoryDAO' => 'PhabricatorLiskDAO', 'PhabricatorRepositoryDaemon' => 'PhabricatorDaemon', 'PhabricatorRepositoryDefaultCommitMessageDetailParser' => 'PhabricatorRepositoryCommitMessageDetailParser', + 'PhabricatorRepositoryDeleteController' => 'PhabricatorRepositoryController', 'PhabricatorRepositoryEditController' => 'PhabricatorRepositoryController', 'PhabricatorRepositoryGitCommitChangeParserWorker' => 'PhabricatorRepositoryCommitChangeParserWorker', 'PhabricatorRepositoryGitCommitDiscoveryDaemon' => 'PhabricatorRepositoryCommitDiscoveryDaemon', diff --git a/src/applications/repository/controller/delete/PhabricatorRepositoryDeleteController.php b/src/applications/repository/controller/delete/PhabricatorRepositoryDeleteController.php new file mode 100644 index 0000000000..8f570ba375 --- /dev/null +++ b/src/applications/repository/controller/delete/PhabricatorRepositoryDeleteController.php @@ -0,0 +1,56 @@ +id = $data['id']; + } + + public function processRequest() { + + $repository = id(new PhabricatorRepository())->load($this->id); + if (!$repository) { + return new Aphront404Response(); + } + + $request = $this->getRequest(); + + if ($request->isDialogFormPost()) { + $repository->delete(); + return id(new AphrontRedirectResponse())->setURI('/repository/'); + } + + $dialog = new AphrontDialogView(); + $dialog + ->setUser($request->getUser()) + ->setTitle('Really delete repository?') + ->appendChild( + '

Really delete the "'.phutil_escape_html($repository->getName()). + '" ('.phutil_escape_html($repository->getCallsign()).') repository? '. + 'This operation can not be undone.

') + ->setSubmitURI('/repository/delete/'.$this->id.'/') + ->addSubmitButton('Delete Repository') + ->addCancelButton('/repository/'); + + return id(new AphrontDialogResponse())->setDialog($dialog); + } +} diff --git a/src/applications/repository/controller/delete/__init__.php b/src/applications/repository/controller/delete/__init__.php new file mode 100644 index 0000000000..4d0e2e7efc --- /dev/null +++ b/src/applications/repository/controller/delete/__init__.php @@ -0,0 +1,20 @@ + '/repository/edit/'.$repo->getID().'/', ), 'Edit'), - phutil_render_tag( + javelin_render_tag( 'a', array( 'class' => 'button small grey', 'href' => '/repository/delete/'.$repo->getID().'/', + 'sigil' => 'workflow', ), 'Delete'), ); diff --git a/src/applications/repository/controller/list/__init__.php b/src/applications/repository/controller/list/__init__.php index 8f06e0887e..8f0762d2b1 100644 --- a/src/applications/repository/controller/list/__init__.php +++ b/src/applications/repository/controller/list/__init__.php @@ -10,6 +10,7 @@ phutil_require_module('phabricator', 'applications/repository/constants/reposito phutil_require_module('phabricator', 'applications/repository/controller/base'); phutil_require_module('phabricator', 'applications/repository/storage/arcanistproject'); phutil_require_module('phabricator', 'applications/repository/storage/repository'); +phutil_require_module('phabricator', 'infrastructure/javelin/markup'); phutil_require_module('phabricator', 'view/control/table'); phutil_require_module('phabricator', 'view/layout/panel');