@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 "Lock Project" to a separate action

Summary:
Ref T10010. Three motivations:

- Primarily: this makes conversion to EditEngine easier since I don't have to convert this weird control.
- This probably needs to have "Lock", "Unlock" and "Use Parent Project Setting" values after subprojects? But maybe just locking any parent locks all the children? Anyway, doesn't make sense to put it on the main edit form if it's weird like this, I think, since we'll want some kind of explanatory text.
- I probably want to move this to the "Members" tab anyway, and this won't be available on milestone projects at all.

Test Plan: Locked, unlocked, edited projects.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10010

Differential Revision: https://secure.phabricator.com/D14895

+100 -23
+2
src/__phutil_library_map__.php
··· 2853 2853 'PhabricatorProjectIconSet' => 'applications/project/icon/PhabricatorProjectIconSet.php', 2854 2854 'PhabricatorProjectInterface' => 'applications/project/interface/PhabricatorProjectInterface.php', 2855 2855 'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php', 2856 + 'PhabricatorProjectLockController' => 'applications/project/controller/PhabricatorProjectLockController.php', 2856 2857 'PhabricatorProjectLogicalAndDatasource' => 'applications/project/typeahead/PhabricatorProjectLogicalAndDatasource.php', 2857 2858 'PhabricatorProjectLogicalDatasource' => 'applications/project/typeahead/PhabricatorProjectLogicalDatasource.php', 2858 2859 'PhabricatorProjectLogicalOrNotDatasource' => 'applications/project/typeahead/PhabricatorProjectLogicalOrNotDatasource.php', ··· 7198 7199 'PhabricatorProjectHeraldAction' => 'HeraldAction', 7199 7200 'PhabricatorProjectIconSet' => 'PhabricatorIconSet', 7200 7201 'PhabricatorProjectListController' => 'PhabricatorProjectController', 7202 + 'PhabricatorProjectLockController' => 'PhabricatorProjectController', 7201 7203 'PhabricatorProjectLogicalAndDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 7202 7204 'PhabricatorProjectLogicalDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 7203 7205 'PhabricatorProjectLogicalOrNotDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
+2
src/applications/project/application/PhabricatorProjectApplication.php
··· 47 47 => 'PhabricatorProjectEditDetailsController', 48 48 'archive/(?P<id>[1-9]\d*)/' 49 49 => 'PhabricatorProjectArchiveController', 50 + 'lock/(?P<id>[1-9]\d*)/' 51 + => 'PhabricatorProjectLockController', 50 52 'members/(?P<id>[1-9]\d*)/' 51 53 => 'PhabricatorProjectMembersEditController', 52 54 'members/(?P<id>[1-9]\d*)/remove/'
+1 -23
src/applications/project/controller/PhabricatorProjectEditDetailsController.php
··· 54 54 $v_slugs = $project_slugs; 55 55 $v_color = $project->getColor(); 56 56 $v_icon = $project->getIcon(); 57 - $v_locked = $project->getIsMembershipLocked(); 58 57 59 58 $validation_exception = null; 60 59 ··· 69 68 $v_join = $request->getStr('can_join'); 70 69 $v_color = $request->getStr('color'); 71 70 $v_icon = $request->getStr('icon'); 72 - $v_locked = $request->getInt('is_membership_locked', 0); 73 71 74 72 $type_name = PhabricatorProjectTransaction::TYPE_NAME; 75 73 $type_slugs = PhabricatorProjectTransaction::TYPE_SLUGS; 76 74 $type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY; 77 75 $type_icon = PhabricatorProjectTransaction::TYPE_ICON; 78 76 $type_color = PhabricatorProjectTransaction::TYPE_COLOR; 79 - $type_locked = PhabricatorProjectTransaction::TYPE_LOCKED; 80 77 81 78 $xactions = array(); 82 79 ··· 107 104 $xactions[] = id(new PhabricatorProjectTransaction()) 108 105 ->setTransactionType($type_color) 109 106 ->setNewValue($v_color); 110 - 111 - $xactions[] = id(new PhabricatorProjectTransaction()) 112 - ->setTransactionType($type_locked) 113 - ->setNewValue($v_locked); 114 107 115 108 $xactions = array_merge( 116 109 $xactions, ··· 189 182 $field_list->appendFieldsToForm($form); 190 183 191 184 $shades = PhabricatorProjectIconSet::getColorMap(); 192 - 193 - list($can_lock, $lock_message) = $this->explainApplicationCapability( 194 - ProjectCanLockProjectsCapability::CAPABILITY, 195 - pht('You can update the Lock Project setting.'), 196 - pht('You can not update the Lock Project setting.')); 197 185 198 186 $form 199 187 ->appendChild( ··· 249 237 pht('Users who can edit a project can always join a project.')) 250 238 ->setPolicyObject($project) 251 239 ->setPolicies($policies) 252 - ->setCapability(PhabricatorPolicyCapability::CAN_JOIN)) 253 - ->appendChild( 254 - id(new AphrontFormCheckboxControl()) 255 - ->setLabel(pht('Lock Project')) 256 - ->setDisabled(!$can_lock) 257 - ->addCheckbox( 258 - 'is_membership_locked', 259 - 1, 260 - pht('Prevent members from leaving this project.'), 261 - $v_locked) 262 - ->setCaption($lock_message)); 240 + ->setCapability(PhabricatorPolicyCapability::CAN_JOIN)); 263 241 264 242 if ($request->isAjax()) { 265 243 $errors = array();
+76
src/applications/project/controller/PhabricatorProjectLockController.php
··· 1 + <?php 2 + 3 + final class PhabricatorProjectLockController 4 + extends PhabricatorProjectController { 5 + 6 + public function shouldAllowPublic() { 7 + return true; 8 + } 9 + 10 + public function handleRequest(AphrontRequest $request) { 11 + $viewer = $request->getViewer(); 12 + 13 + $this->requireApplicationCapability( 14 + ProjectCanLockProjectsCapability::CAPABILITY); 15 + 16 + $id = $request->getURIData('id'); 17 + $project = id(new PhabricatorProjectQuery()) 18 + ->setViewer($viewer) 19 + ->withIDs(array($id)) 20 + ->requireCapabilities( 21 + array( 22 + PhabricatorPolicyCapability::CAN_VIEW, 23 + PhabricatorPolicyCapability::CAN_EDIT, 24 + )) 25 + ->executeOne(); 26 + if (!$project) { 27 + return new Aphront404Response(); 28 + } 29 + 30 + $done_uri = $project->getURI(); 31 + $is_locked = $project->getIsMembershipLocked(); 32 + 33 + if ($request->isFormPost()) { 34 + $xactions = array(); 35 + 36 + if ($is_locked) { 37 + $new_value = 0; 38 + } else { 39 + $new_value = 1; 40 + } 41 + 42 + $xactions[] = id(new PhabricatorProjectTransaction()) 43 + ->setTransactionType(PhabricatorProjectTransaction::TYPE_LOCKED) 44 + ->setNewValue($new_value); 45 + 46 + $editor = id(new PhabricatorProjectTransactionEditor()) 47 + ->setActor($viewer) 48 + ->setContentSourceFromRequest($request) 49 + ->setContinueOnNoEffect(true) 50 + ->setContinueOnMissingFields(true) 51 + ->applyTransactions($project, $xactions); 52 + 53 + return id(new AphrontRedirectResponse())->setURI($done_uri); 54 + } 55 + 56 + if ($project->getIsMembershipLocked()) { 57 + $title = pht('Unlock Project'); 58 + $body = pht( 59 + 'If you unlock this project, members will be free to leave.'); 60 + $button = pht('Unlock Project'); 61 + } else { 62 + $title = pht('Lock Project'); 63 + $body = pht( 64 + 'If you lock this project, members will be prevented from '. 65 + 'leaving it.'); 66 + $button = pht('Lock Project'); 67 + } 68 + 69 + return $this->newDialog() 70 + ->setTitle($title) 71 + ->appendParagraph($body) 72 + ->addSubmitbutton($button) 73 + ->addCancelButton($done_uri); 74 + } 75 + 76 + }
+19
src/applications/project/controller/PhabricatorProjectProfileController.php
··· 106 106 ->setWorkflow(true)); 107 107 } 108 108 109 + $can_lock = $can_edit && $this->hasApplicationCapability( 110 + ProjectCanLockProjectsCapability::CAPABILITY); 111 + 112 + if ($project->getIsMembershipLocked()) { 113 + $lock_name = pht('Unlock Project'); 114 + $lock_icon = 'fa-unlock'; 115 + } else { 116 + $lock_name = pht('Lock Project'); 117 + $lock_icon = 'fa-lock'; 118 + } 119 + 120 + $view->addAction( 121 + id(new PhabricatorActionView()) 122 + ->setName($lock_name) 123 + ->setIcon($lock_icon) 124 + ->setHref($this->getApplicationURI("lock/{$id}/")) 125 + ->setDisabled(!$can_lock) 126 + ->setWorkflow(true)); 127 + 109 128 $action = null; 110 129 if (!$project->isUserMember($viewer->getPHID())) { 111 130 $can_join = PhabricatorPolicyFilter::hasCapability(