diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 939f7382bf..f78f3dd849 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -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' => diff --git a/src/applications/project/application/PhabricatorApplicationProject.php b/src/applications/project/application/PhabricatorApplicationProject.php index 9a1f22c9b9..8014ef62d8 100644 --- a/src/applications/project/application/PhabricatorApplicationProject.php +++ b/src/applications/project/application/PhabricatorApplicationProject.php @@ -38,6 +38,8 @@ final class PhabricatorApplicationProject extends PhabricatorApplication { '(?:query/(?P[^/]+)/)?' => 'PhabricatorProjectListController', 'filter/(?P[^/]+)/' => 'PhabricatorProjectListController', 'edit/(?P[1-9]\d*)/' => 'PhabricatorProjectProfileEditController', + 'archive/(?P[1-9]\d*)/' => + 'PhabricatorProjectArchiveController', 'members/(?P[1-9]\d*)/' => 'PhabricatorProjectMembersEditController', 'view/(?P[1-9]\d*)/(?:(?P\w+)/)?' diff --git a/src/applications/project/controller/PhabricatorProjectArchiveController.php b/src/applications/project/controller/PhabricatorProjectArchiveController.php new file mode 100644 index 0000000000..8ac59f4c79 --- /dev/null +++ b/src/applications/project/controller/PhabricatorProjectArchiveController.php @@ -0,0 +1,75 @@ +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); + } + +} diff --git a/src/applications/project/controller/PhabricatorProjectProfileController.php b/src/applications/project/controller/PhabricatorProjectProfileController.php index f643e98c28..6ba5f666d4 100644 --- a/src/applications/project/controller/PhabricatorProjectProfileController.php +++ b/src/applications/project/controller/PhabricatorProjectProfileController.php @@ -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')) diff --git a/src/applications/project/controller/PhabricatorProjectProfileEditController.php b/src/applications/project/controller/PhabricatorProjectProfileEditController.php index 474a56c3a4..dc31632bec 100644 --- a/src/applications/project/controller/PhabricatorProjectProfileEditController.php +++ b/src/applications/project/controller/PhabricatorProjectProfileEditController.php @@ -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')) diff --git a/src/applications/project/storage/PhabricatorProject.php b/src/applications/project/storage/PhabricatorProject.php index 86394ac80d..f496109791 100644 --- a/src/applications/project/storage/PhabricatorProject.php +++ b/src/applications/project/storage/PhabricatorProject.php @@ -147,6 +147,10 @@ final class PhabricatorProject extends PhabricatorProjectDAO return 'projects/'.$slug; } + public function isArchived() { + return ($this->getStatus() == PhabricatorProjectStatus::STATUS_ARCHIVED); + } + /* -( PhabricatorSubscribableInterface )----------------------------------- */