Index: src/__phutil_library_map__.php =================================================================== --- src/__phutil_library_map__.php +++ src/__phutil_library_map__.php @@ -1825,6 +1825,7 @@ '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 @@ 2 => 'PhabricatorPolicyInterface', 3 => 'PhabricatorSubscribableInterface', ), + 'PhabricatorProjectArchiveController' => 'PhabricatorProjectController', 'PhabricatorProjectBoardController' => 'PhabricatorProjectController', 'PhabricatorProjectBoardEditController' => 'PhabricatorProjectController', 'PhabricatorProjectColumn' => Index: src/applications/project/application/PhabricatorApplicationProject.php =================================================================== --- src/applications/project/application/PhabricatorApplicationProject.php +++ src/applications/project/application/PhabricatorApplicationProject.php @@ -38,6 +38,8 @@ '(?: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+)/)?' Index: src/applications/project/controller/PhabricatorProjectArchiveController.php =================================================================== --- /dev/null +++ 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); + } + +} Index: src/applications/project/controller/PhabricatorProjectProfileController.php =================================================================== --- src/applications/project/controller/PhabricatorProjectProfileController.php +++ src/applications/project/controller/PhabricatorProjectProfileController.php @@ -174,6 +174,24 @@ ->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')) Index: src/applications/project/controller/PhabricatorProjectProfileEditController.php =================================================================== --- src/applications/project/controller/PhabricatorProjectProfileEditController.php +++ src/applications/project/controller/PhabricatorProjectProfileEditController.php @@ -29,7 +29,6 @@ } $profile = $project->getProfile(); - $options = PhabricatorProjectStatus::getStatusMap(); $e_name = true; @@ -42,10 +41,6 @@ ->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')); @@ -102,12 +97,6 @@ ->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')) ->setName('blurb') Index: src/applications/project/storage/PhabricatorProject.php =================================================================== --- src/applications/project/storage/PhabricatorProject.php +++ src/applications/project/storage/PhabricatorProject.php @@ -147,6 +147,10 @@ return 'projects/'.$slug; } + public function isArchived() { + return ($this->getStatus() == PhabricatorProjectStatus::STATUS_ARCHIVED); + } + /* -( PhabricatorSubscribableInterface )----------------------------------- */