mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-20 13:52:40 +01:00
Move "Archive Project" to a standard, separate action
Summary: Ref T4379. Projects currently include their "delete/disable" function as part of edit, which is atypical. Instead, provide it as a first-class action. This is primarily for consistency between applications. (The action list on projects is getting pretty huge, but we can deal with that separately; I have some ideas.) Test Plan: Archived/unarchived a project. Edited a project. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4379 Differential Revision: https://secure.phabricator.com/D8177
This commit is contained in:
parent
a035d3d528
commit
c3544f8862
6 changed files with 101 additions and 11 deletions
|
@ -1825,6 +1825,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorPolicyTestObject' => 'applications/policy/__tests__/PhabricatorPolicyTestObject.php',
|
'PhabricatorPolicyTestObject' => 'applications/policy/__tests__/PhabricatorPolicyTestObject.php',
|
||||||
'PhabricatorPolicyType' => 'applications/policy/constants/PhabricatorPolicyType.php',
|
'PhabricatorPolicyType' => 'applications/policy/constants/PhabricatorPolicyType.php',
|
||||||
'PhabricatorProject' => 'applications/project/storage/PhabricatorProject.php',
|
'PhabricatorProject' => 'applications/project/storage/PhabricatorProject.php',
|
||||||
|
'PhabricatorProjectArchiveController' => 'applications/project/controller/PhabricatorProjectArchiveController.php',
|
||||||
'PhabricatorProjectBoardController' => 'applications/project/controller/PhabricatorProjectBoardController.php',
|
'PhabricatorProjectBoardController' => 'applications/project/controller/PhabricatorProjectBoardController.php',
|
||||||
'PhabricatorProjectBoardEditController' => 'applications/project/controller/PhabricatorProjectBoardEditController.php',
|
'PhabricatorProjectBoardEditController' => 'applications/project/controller/PhabricatorProjectBoardEditController.php',
|
||||||
'PhabricatorProjectColumn' => 'applications/project/storage/PhabricatorProjectColumn.php',
|
'PhabricatorProjectColumn' => 'applications/project/storage/PhabricatorProjectColumn.php',
|
||||||
|
@ -4557,6 +4558,7 @@ phutil_register_library_map(array(
|
||||||
2 => 'PhabricatorPolicyInterface',
|
2 => 'PhabricatorPolicyInterface',
|
||||||
3 => 'PhabricatorSubscribableInterface',
|
3 => 'PhabricatorSubscribableInterface',
|
||||||
),
|
),
|
||||||
|
'PhabricatorProjectArchiveController' => 'PhabricatorProjectController',
|
||||||
'PhabricatorProjectBoardController' => 'PhabricatorProjectController',
|
'PhabricatorProjectBoardController' => 'PhabricatorProjectController',
|
||||||
'PhabricatorProjectBoardEditController' => 'PhabricatorProjectController',
|
'PhabricatorProjectBoardEditController' => 'PhabricatorProjectController',
|
||||||
'PhabricatorProjectColumn' =>
|
'PhabricatorProjectColumn' =>
|
||||||
|
|
|
@ -38,6 +38,8 @@ final class PhabricatorApplicationProject extends PhabricatorApplication {
|
||||||
'(?:query/(?P<queryKey>[^/]+)/)?' => 'PhabricatorProjectListController',
|
'(?:query/(?P<queryKey>[^/]+)/)?' => 'PhabricatorProjectListController',
|
||||||
'filter/(?P<filter>[^/]+)/' => 'PhabricatorProjectListController',
|
'filter/(?P<filter>[^/]+)/' => 'PhabricatorProjectListController',
|
||||||
'edit/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectProfileEditController',
|
'edit/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectProfileEditController',
|
||||||
|
'archive/(?P<id>[1-9]\d*)/' =>
|
||||||
|
'PhabricatorProjectArchiveController',
|
||||||
'members/(?P<id>[1-9]\d*)/'
|
'members/(?P<id>[1-9]\d*)/'
|
||||||
=> 'PhabricatorProjectMembersEditController',
|
=> 'PhabricatorProjectMembersEditController',
|
||||||
'view/(?P<id>[1-9]\d*)/(?:(?P<page>\w+)/)?'
|
'view/(?P<id>[1-9]\d*)/(?:(?P<page>\w+)/)?'
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorProjectArchiveController
|
||||||
|
extends PhabricatorProjectController {
|
||||||
|
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
public function willProcessRequest(array $data) {
|
||||||
|
$this->id = $data['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processRequest() {
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$viewer = $request->getUser();
|
||||||
|
|
||||||
|
$project = id(new PhabricatorProjectQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withIDs(array($this->id))
|
||||||
|
->requireCapabilities(
|
||||||
|
array(
|
||||||
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
PhabricatorPolicyCapability::CAN_EDIT,
|
||||||
|
))
|
||||||
|
->needProfiles(true)
|
||||||
|
->executeOne();
|
||||||
|
if (!$project) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
$view_uri = $this->getApplicationURI('view/'.$project->getID().'/');
|
||||||
|
|
||||||
|
if ($request->isFormPost()) {
|
||||||
|
if ($project->isArchived()) {
|
||||||
|
$new_status = PhabricatorProjectStatus::STATUS_ACTIVE;
|
||||||
|
} else {
|
||||||
|
$new_status = PhabricatorProjectStatus::STATUS_ARCHIVED;
|
||||||
|
}
|
||||||
|
|
||||||
|
$xactions = array();
|
||||||
|
|
||||||
|
$xactions[] = id(new PhabricatorProjectTransaction())
|
||||||
|
->setTransactionType(PhabricatorProjectTransaction::TYPE_STATUS)
|
||||||
|
->setNewValue($new_status);
|
||||||
|
|
||||||
|
id(new PhabricatorProjectTransactionEditor())
|
||||||
|
->setActor($viewer)
|
||||||
|
->setContentSourceFromRequest($request)
|
||||||
|
->setContinueOnNoEffect(true)
|
||||||
|
->setContinueOnMissingFields(true)
|
||||||
|
->applyTransactions($project, $xactions);
|
||||||
|
|
||||||
|
return id(new AphrontRedirectResponse())->setURI($view_uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($project->isArchived()) {
|
||||||
|
$title = pht('Really unarchive project?');
|
||||||
|
$body = pht('This project will become active again.');
|
||||||
|
$button = pht('Unarchive Project');
|
||||||
|
} else {
|
||||||
|
$title = pht('Really archive project?');
|
||||||
|
$body = pht('This project will moved to the archive.');
|
||||||
|
$button = pht('Archive Project');
|
||||||
|
}
|
||||||
|
|
||||||
|
$dialog = id(new AphrontDialogView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setTitle($title)
|
||||||
|
->appendChild($body)
|
||||||
|
->addCancelButton($view_uri)
|
||||||
|
->addSubmitButton($button);
|
||||||
|
|
||||||
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -174,6 +174,24 @@ final class PhabricatorProjectProfileController
|
||||||
->setDisabled(!$can_edit)
|
->setDisabled(!$can_edit)
|
||||||
->setWorkflow(!$can_edit));
|
->setWorkflow(!$can_edit));
|
||||||
|
|
||||||
|
if ($project->isArchived()) {
|
||||||
|
$view->addAction(
|
||||||
|
id(new PhabricatorActionView())
|
||||||
|
->setName(pht('Unarchive Project'))
|
||||||
|
->setIcon('enable')
|
||||||
|
->setHref($this->getApplicationURI("archive/{$id}/"))
|
||||||
|
->setDisabled(!$can_edit)
|
||||||
|
->setWorkflow(true));
|
||||||
|
} else {
|
||||||
|
$view->addAction(
|
||||||
|
id(new PhabricatorActionView())
|
||||||
|
->setName(pht('Archive Project'))
|
||||||
|
->setIcon('disable')
|
||||||
|
->setHref($this->getApplicationURI("archive/{$id}/"))
|
||||||
|
->setDisabled(!$can_edit)
|
||||||
|
->setWorkflow(true));
|
||||||
|
}
|
||||||
|
|
||||||
$view->addAction(
|
$view->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setName(pht('Edit Members'))
|
->setName(pht('Edit Members'))
|
||||||
|
|
|
@ -29,7 +29,6 @@ final class PhabricatorProjectProfileEditController
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile = $project->getProfile();
|
$profile = $project->getProfile();
|
||||||
$options = PhabricatorProjectStatus::getStatusMap();
|
|
||||||
|
|
||||||
$e_name = true;
|
$e_name = true;
|
||||||
|
|
||||||
|
@ -41,10 +40,6 @@ final class PhabricatorProjectProfileEditController
|
||||||
->setTransactionType(PhabricatorProjectTransaction::TYPE_NAME)
|
->setTransactionType(PhabricatorProjectTransaction::TYPE_NAME)
|
||||||
->setNewValue($request->getStr('name'));
|
->setNewValue($request->getStr('name'));
|
||||||
|
|
||||||
$xactions[] = id(new PhabricatorProjectTransaction())
|
|
||||||
->setTransactionType(PhabricatorProjectTransaction::TYPE_STATUS)
|
|
||||||
->setNewValue($request->getStr('status'));
|
|
||||||
|
|
||||||
$xactions[] = id(new PhabricatorProjectTransaction())
|
$xactions[] = id(new PhabricatorProjectTransaction())
|
||||||
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)
|
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)
|
||||||
->setNewValue($request->getStr('can_view'));
|
->setNewValue($request->getStr('can_view'));
|
||||||
|
@ -101,12 +96,6 @@ final class PhabricatorProjectProfileEditController
|
||||||
->setName('name')
|
->setName('name')
|
||||||
->setValue($project->getName())
|
->setValue($project->getName())
|
||||||
->setError($e_name))
|
->setError($e_name))
|
||||||
->appendChild(
|
|
||||||
id(new AphrontFormSelectControl())
|
|
||||||
->setLabel(pht('Project Status'))
|
|
||||||
->setName('status')
|
|
||||||
->setOptions($options)
|
|
||||||
->setValue($project->getStatus()))
|
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new PhabricatorRemarkupControl())
|
id(new PhabricatorRemarkupControl())
|
||||||
->setLabel(pht('Description'))
|
->setLabel(pht('Description'))
|
||||||
|
|
|
@ -147,6 +147,10 @@ final class PhabricatorProject extends PhabricatorProjectDAO
|
||||||
return 'projects/'.$slug;
|
return 'projects/'.$slug;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isArchived() {
|
||||||
|
return ($this->getStatus() == PhabricatorProjectStatus::STATUS_ARCHIVED);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -( PhabricatorSubscribableInterface )----------------------------------- */
|
/* -( PhabricatorSubscribableInterface )----------------------------------- */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue