@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+101 -11
+2
src/__phutil_library_map__.php
··· 1825 1825 'PhabricatorPolicyTestObject' => 'applications/policy/__tests__/PhabricatorPolicyTestObject.php', 1826 1826 'PhabricatorPolicyType' => 'applications/policy/constants/PhabricatorPolicyType.php', 1827 1827 'PhabricatorProject' => 'applications/project/storage/PhabricatorProject.php', 1828 + 'PhabricatorProjectArchiveController' => 'applications/project/controller/PhabricatorProjectArchiveController.php', 1828 1829 'PhabricatorProjectBoardController' => 'applications/project/controller/PhabricatorProjectBoardController.php', 1829 1830 'PhabricatorProjectBoardEditController' => 'applications/project/controller/PhabricatorProjectBoardEditController.php', 1830 1831 'PhabricatorProjectColumn' => 'applications/project/storage/PhabricatorProjectColumn.php', ··· 4557 4558 2 => 'PhabricatorPolicyInterface', 4558 4559 3 => 'PhabricatorSubscribableInterface', 4559 4560 ), 4561 + 'PhabricatorProjectArchiveController' => 'PhabricatorProjectController', 4560 4562 'PhabricatorProjectBoardController' => 'PhabricatorProjectController', 4561 4563 'PhabricatorProjectBoardEditController' => 'PhabricatorProjectController', 4562 4564 'PhabricatorProjectColumn' =>
+2
src/applications/project/application/PhabricatorApplicationProject.php
··· 38 38 '(?:query/(?P<queryKey>[^/]+)/)?' => 'PhabricatorProjectListController', 39 39 'filter/(?P<filter>[^/]+)/' => 'PhabricatorProjectListController', 40 40 'edit/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectProfileEditController', 41 + 'archive/(?P<id>[1-9]\d*)/' => 42 + 'PhabricatorProjectArchiveController', 41 43 'members/(?P<id>[1-9]\d*)/' 42 44 => 'PhabricatorProjectMembersEditController', 43 45 'view/(?P<id>[1-9]\d*)/(?:(?P<page>\w+)/)?'
+75
src/applications/project/controller/PhabricatorProjectArchiveController.php
··· 1 + <?php 2 + 3 + final class PhabricatorProjectArchiveController 4 + extends PhabricatorProjectController { 5 + 6 + private $id; 7 + 8 + public function willProcessRequest(array $data) { 9 + $this->id = $data['id']; 10 + } 11 + 12 + public function processRequest() { 13 + $request = $this->getRequest(); 14 + $viewer = $request->getUser(); 15 + 16 + $project = id(new PhabricatorProjectQuery()) 17 + ->setViewer($viewer) 18 + ->withIDs(array($this->id)) 19 + ->requireCapabilities( 20 + array( 21 + PhabricatorPolicyCapability::CAN_VIEW, 22 + PhabricatorPolicyCapability::CAN_EDIT, 23 + )) 24 + ->needProfiles(true) 25 + ->executeOne(); 26 + if (!$project) { 27 + return new Aphront404Response(); 28 + } 29 + 30 + $view_uri = $this->getApplicationURI('view/'.$project->getID().'/'); 31 + 32 + if ($request->isFormPost()) { 33 + if ($project->isArchived()) { 34 + $new_status = PhabricatorProjectStatus::STATUS_ACTIVE; 35 + } else { 36 + $new_status = PhabricatorProjectStatus::STATUS_ARCHIVED; 37 + } 38 + 39 + $xactions = array(); 40 + 41 + $xactions[] = id(new PhabricatorProjectTransaction()) 42 + ->setTransactionType(PhabricatorProjectTransaction::TYPE_STATUS) 43 + ->setNewValue($new_status); 44 + 45 + id(new PhabricatorProjectTransactionEditor()) 46 + ->setActor($viewer) 47 + ->setContentSourceFromRequest($request) 48 + ->setContinueOnNoEffect(true) 49 + ->setContinueOnMissingFields(true) 50 + ->applyTransactions($project, $xactions); 51 + 52 + return id(new AphrontRedirectResponse())->setURI($view_uri); 53 + } 54 + 55 + if ($project->isArchived()) { 56 + $title = pht('Really unarchive project?'); 57 + $body = pht('This project will become active again.'); 58 + $button = pht('Unarchive Project'); 59 + } else { 60 + $title = pht('Really archive project?'); 61 + $body = pht('This project will moved to the archive.'); 62 + $button = pht('Archive Project'); 63 + } 64 + 65 + $dialog = id(new AphrontDialogView()) 66 + ->setUser($viewer) 67 + ->setTitle($title) 68 + ->appendChild($body) 69 + ->addCancelButton($view_uri) 70 + ->addSubmitButton($button); 71 + 72 + return id(new AphrontDialogResponse())->setDialog($dialog); 73 + } 74 + 75 + }
+18
src/applications/project/controller/PhabricatorProjectProfileController.php
··· 174 174 ->setDisabled(!$can_edit) 175 175 ->setWorkflow(!$can_edit)); 176 176 177 + if ($project->isArchived()) { 178 + $view->addAction( 179 + id(new PhabricatorActionView()) 180 + ->setName(pht('Unarchive Project')) 181 + ->setIcon('enable') 182 + ->setHref($this->getApplicationURI("archive/{$id}/")) 183 + ->setDisabled(!$can_edit) 184 + ->setWorkflow(true)); 185 + } else { 186 + $view->addAction( 187 + id(new PhabricatorActionView()) 188 + ->setName(pht('Archive Project')) 189 + ->setIcon('disable') 190 + ->setHref($this->getApplicationURI("archive/{$id}/")) 191 + ->setDisabled(!$can_edit) 192 + ->setWorkflow(true)); 193 + } 194 + 177 195 $view->addAction( 178 196 id(new PhabricatorActionView()) 179 197 ->setName(pht('Edit Members'))
-11
src/applications/project/controller/PhabricatorProjectProfileEditController.php
··· 29 29 } 30 30 31 31 $profile = $project->getProfile(); 32 - $options = PhabricatorProjectStatus::getStatusMap(); 33 32 34 33 $e_name = true; 35 34 ··· 40 39 $xactions[] = id(new PhabricatorProjectTransaction()) 41 40 ->setTransactionType(PhabricatorProjectTransaction::TYPE_NAME) 42 41 ->setNewValue($request->getStr('name')); 43 - 44 - $xactions[] = id(new PhabricatorProjectTransaction()) 45 - ->setTransactionType(PhabricatorProjectTransaction::TYPE_STATUS) 46 - ->setNewValue($request->getStr('status')); 47 42 48 43 $xactions[] = id(new PhabricatorProjectTransaction()) 49 44 ->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) ··· 101 96 ->setName('name') 102 97 ->setValue($project->getName()) 103 98 ->setError($e_name)) 104 - ->appendChild( 105 - id(new AphrontFormSelectControl()) 106 - ->setLabel(pht('Project Status')) 107 - ->setName('status') 108 - ->setOptions($options) 109 - ->setValue($project->getStatus())) 110 99 ->appendChild( 111 100 id(new PhabricatorRemarkupControl()) 112 101 ->setLabel(pht('Description'))
+4
src/applications/project/storage/PhabricatorProject.php
··· 147 147 return 'projects/'.$slug; 148 148 } 149 149 150 + public function isArchived() { 151 + return ($this->getStatus() == PhabricatorProjectStatus::STATUS_ARCHIVED); 152 + } 153 + 150 154 151 155 /* -( PhabricatorSubscribableInterface )----------------------------------- */ 152 156