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',
|
||||
'PhabricatorPolicyType' => 'applications/policy/constants/PhabricatorPolicyType.php',
|
||||
'PhabricatorProject' => 'applications/project/storage/PhabricatorProject.php',
|
||||
'PhabricatorProjectArchiveController' => 'applications/project/controller/PhabricatorProjectArchiveController.php',
|
||||
'PhabricatorProjectBoardController' => 'applications/project/controller/PhabricatorProjectBoardController.php',
|
||||
'PhabricatorProjectBoardEditController' => 'applications/project/controller/PhabricatorProjectBoardEditController.php',
|
||||
'PhabricatorProjectColumn' => 'applications/project/storage/PhabricatorProjectColumn.php',
|
||||
|
@ -4557,6 +4558,7 @@ phutil_register_library_map(array(
|
|||
2 => 'PhabricatorPolicyInterface',
|
||||
3 => 'PhabricatorSubscribableInterface',
|
||||
),
|
||||
'PhabricatorProjectArchiveController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectBoardController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectBoardEditController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectColumn' =>
|
||||
|
|
|
@ -38,6 +38,8 @@ final class PhabricatorApplicationProject extends PhabricatorApplication {
|
|||
'(?:query/(?P<queryKey>[^/]+)/)?' => 'PhabricatorProjectListController',
|
||||
'filter/(?P<filter>[^/]+)/' => 'PhabricatorProjectListController',
|
||||
'edit/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectProfileEditController',
|
||||
'archive/(?P<id>[1-9]\d*)/' =>
|
||||
'PhabricatorProjectArchiveController',
|
||||
'members/(?P<id>[1-9]\d*)/'
|
||||
=> 'PhabricatorProjectMembersEditController',
|
||||
'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)
|
||||
->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(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('Edit Members'))
|
||||
|
|
|
@ -29,7 +29,6 @@ final class PhabricatorProjectProfileEditController
|
|||
}
|
||||
|
||||
$profile = $project->getProfile();
|
||||
$options = PhabricatorProjectStatus::getStatusMap();
|
||||
|
||||
$e_name = true;
|
||||
|
||||
|
@ -41,10 +40,6 @@ final class PhabricatorProjectProfileEditController
|
|||
->setTransactionType(PhabricatorProjectTransaction::TYPE_NAME)
|
||||
->setNewValue($request->getStr('name'));
|
||||
|
||||
$xactions[] = id(new PhabricatorProjectTransaction())
|
||||
->setTransactionType(PhabricatorProjectTransaction::TYPE_STATUS)
|
||||
->setNewValue($request->getStr('status'));
|
||||
|
||||
$xactions[] = id(new PhabricatorProjectTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)
|
||||
->setNewValue($request->getStr('can_view'));
|
||||
|
@ -101,12 +96,6 @@ final class PhabricatorProjectProfileEditController
|
|||
->setName('name')
|
||||
->setValue($project->getName())
|
||||
->setError($e_name))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel(pht('Project Status'))
|
||||
->setName('status')
|
||||
->setOptions($options)
|
||||
->setValue($project->getStatus()))
|
||||
->appendChild(
|
||||
id(new PhabricatorRemarkupControl())
|
||||
->setLabel(pht('Description'))
|
||||
|
|
|
@ -147,6 +147,10 @@ final class PhabricatorProject extends PhabricatorProjectDAO
|
|||
return 'projects/'.$slug;
|
||||
}
|
||||
|
||||
public function isArchived() {
|
||||
return ($this->getStatus() == PhabricatorProjectStatus::STATUS_ARCHIVED);
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorSubscribableInterface )----------------------------------- */
|
||||
|
||||
|
|
Loading…
Reference in a new issue