mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
allow arcanist projects to be deleted via the ui
Summary: tricky part is purging symbols at that time too. override "delete" method to get there, use transactions, etc. Test Plan: deleted an arcanist project - it worked! Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin, mbishopim3 Maniphest Tasks: T1738 Differential Revision: https://secure.phabricator.com/D3613
This commit is contained in:
parent
36d02b6c79
commit
4c86893108
5 changed files with 92 additions and 2 deletions
|
@ -975,6 +975,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorRemarkupRuleYoutube' => 'infrastructure/markup/rule/PhabricatorRemarkupRuleYoutube.php',
|
||||
'PhabricatorRepository' => 'applications/repository/storage/PhabricatorRepository.php',
|
||||
'PhabricatorRepositoryArcanistProject' => 'applications/repository/storage/PhabricatorRepositoryArcanistProject.php',
|
||||
'PhabricatorRepositoryArcanistProjectDeleteController' => 'applications/repository/controller/PhabricatorRepositoryArcanistProjectDeleteController.php',
|
||||
'PhabricatorRepositoryArcanistProjectEditController' => 'applications/repository/controller/PhabricatorRepositoryArcanistProjectEditController.php',
|
||||
'PhabricatorRepositoryAuditRequest' => 'applications/repository/storage/PhabricatorRepositoryAuditRequest.php',
|
||||
'PhabricatorRepositoryCommit' => 'applications/repository/storage/PhabricatorRepositoryCommit.php',
|
||||
|
@ -2099,6 +2100,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorRemarkupRuleYoutube' => 'PhutilRemarkupRule',
|
||||
'PhabricatorRepository' => 'PhabricatorRepositoryDAO',
|
||||
'PhabricatorRepositoryArcanistProject' => 'PhabricatorRepositoryDAO',
|
||||
'PhabricatorRepositoryArcanistProjectDeleteController' => 'PhabricatorRepositoryController',
|
||||
'PhabricatorRepositoryArcanistProjectEditController' => 'PhabricatorRepositoryController',
|
||||
'PhabricatorRepositoryAuditRequest' => 'PhabricatorRepositoryDAO',
|
||||
'PhabricatorRepositoryCommit' => 'PhabricatorRepositoryDAO',
|
||||
|
|
|
@ -46,8 +46,10 @@ final class PhabricatorApplicationRepositories extends PhabricatorApplication {
|
|||
'edit/(?P<id>\d+)/(?:(?P<view>\w+)?/)?' =>
|
||||
'PhabricatorRepositoryEditController',
|
||||
'delete/(?P<id>\d+)/' => 'PhabricatorRepositoryDeleteController',
|
||||
'project/(?P<id>\d+)/' =>
|
||||
'project/edit/(?P<id>\d+)/' =>
|
||||
'PhabricatorRepositoryArcanistProjectEditController',
|
||||
'project/delete/(?P<id>\d+)/' =>
|
||||
'PhabricatorRepositoryArcanistProjectDeleteController',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
final class PhabricatorRepositoryArcanistProjectDeleteController
|
||||
extends PhabricatorRepositoryController {
|
||||
|
||||
private $id;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = $data['id'];
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
|
||||
$arc_project =
|
||||
id(new PhabricatorRepositoryArcanistProject())->load($this->id);
|
||||
if (!$arc_project) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
if ($request->isDialogFormPost()) {
|
||||
$arc_project->delete();
|
||||
return id(new AphrontRedirectResponse())->setURI('/repository/');
|
||||
}
|
||||
|
||||
$dialog = new AphrontDialogView();
|
||||
$dialog
|
||||
->setUser($request->getUser())
|
||||
->setTitle('Really delete this arcanist project?')
|
||||
->appendChild(
|
||||
'<p>Really delete the "'.phutil_escape_html($arc_project->getName()).
|
||||
'" arcanist project? '.
|
||||
'This operation can not be undone.</p>')
|
||||
->setSubmitURI('/repository/project/delete/'.$this->id.'/')
|
||||
->addSubmitButton('Delete Arcanist Project')
|
||||
->addCancelButton('/repository/');
|
||||
|
||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||
}
|
||||
}
|
|
@ -123,11 +123,20 @@ final class PhabricatorRepositoryListController
|
|||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/repository/project/'.$project->getID().'/',
|
||||
'href' => '/repository/project/edit/'.$project->getID().'/',
|
||||
'class' => 'button grey small',
|
||||
),
|
||||
'Edit'),
|
||||
javelin_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/repository/project/delete/'.$project->getID().'/',
|
||||
'class' => 'button grey small',
|
||||
'sigil' => 'workflow',
|
||||
),
|
||||
'Delete'),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
$project_table = new AphrontTableView($rows);
|
||||
|
@ -136,12 +145,14 @@ final class PhabricatorRepositoryListController
|
|||
'Project ID',
|
||||
'Repository',
|
||||
'',
|
||||
'',
|
||||
));
|
||||
$project_table->setColumnClasses(
|
||||
array(
|
||||
'',
|
||||
'wide',
|
||||
'action',
|
||||
'action',
|
||||
));
|
||||
|
||||
$project_table->setColumnVisibility(
|
||||
|
@ -149,6 +160,7 @@ final class PhabricatorRepositoryListController
|
|||
true,
|
||||
true,
|
||||
$is_admin,
|
||||
$is_admin,
|
||||
));
|
||||
|
||||
$project_panel = new AphrontPanelView();
|
||||
|
|
|
@ -48,4 +48,21 @@ final class PhabricatorRepositoryArcanistProject
|
|||
return id(new PhabricatorRepository())->load($this->getRepositoryID());
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
$this->openTransaction();
|
||||
$conn_w = $this->establishConnection('w');
|
||||
|
||||
$symbols = id(new PhabricatorRepositorySymbol())->loadAllWhere(
|
||||
'arcanistProjectID = %d',
|
||||
$this->getID()
|
||||
);
|
||||
foreach ($symbols as $symbol) {
|
||||
$symbol->delete();
|
||||
}
|
||||
|
||||
$result = parent::delete();
|
||||
$this->saveTransaction();
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue