Projects - add "lock membership", which prevents people from leaving

Summary:
Fixes T5603. Puts the toggling of locking membership into the editor so we get exceptions and all that.

I think the dialogue when you try to leave a project that is locked could be a little better maybe? Right now it just says "You can't leave" and "The membership is locked" more or less; should I surface a link to the policy stuff there too?

Test Plan:
 - made a project, toggled the "lock" setting, observed stickiness and good transactions being made
 - locked a project and tried to leave as a non-editor - got a dialogue letting me know i couldn't
 - locked a project and tried to leave as an editor - left successfully

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T5603

Differential Revision: https://secure.phabricator.com/D10508
This commit is contained in:
Bob Trahan
2014-09-18 11:00:50 -07:00
parent 9b63f84ff9
commit 3238f1e091
9 changed files with 106 additions and 6 deletions

View File

@@ -49,6 +49,7 @@ final class PhabricatorProjectEditDetailsController
$v_slugs = $project_slugs;
$v_color = $project->getColor();
$v_icon = $project->getIcon();
$v_locked = $project->getIsMembershipLocked();
$validation_exception = null;
@@ -63,6 +64,7 @@ final class PhabricatorProjectEditDetailsController
$v_join = $request->getStr('can_join');
$v_color = $request->getStr('color');
$v_icon = $request->getStr('icon');
$v_locked = $request->getInt('is_membership_locked', 0);
$xactions = $field_list->buildFieldTransactionsFromRequest(
new PhabricatorProjectTransaction(),
@@ -73,6 +75,7 @@ final class PhabricatorProjectEditDetailsController
$type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY;
$type_icon = PhabricatorProjectTransaction::TYPE_ICON;
$type_color = PhabricatorProjectTransaction::TYPE_COLOR;
$type_locked = PhabricatorProjectTransaction::TYPE_LOCKED;
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType($type_name)
@@ -102,6 +105,10 @@ final class PhabricatorProjectEditDetailsController
->setTransactionType($type_color)
->setNewValue($v_color);
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType($type_locked)
->setNewValue($v_locked);
$editor = id(new PhabricatorProjectTransactionEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
@@ -148,6 +155,10 @@ final class PhabricatorProjectEditDetailsController
$icon_uri = $this->getApplicationURI('icon/'.$project->getID().'/');
$icon_display = PhabricatorProjectIcon::renderIconForChooser($v_icon);
list($can_lock, $lock_message) = $this->explainApplicationCapability(
ProjectCanLockProjectsCapability::CAPABILITY,
pht('You can update the Lock Project setting.'),
pht('You can not update the Lock Project setting.'));
$form
->appendChild(
@@ -201,6 +212,16 @@ final class PhabricatorProjectEditDetailsController
->setPolicyObject($project)
->setPolicies($policies)
->setCapability(PhabricatorPolicyCapability::CAN_JOIN))
->appendChild(
id(new AphrontFormCheckboxControl())
->setLabel(pht('Lock Project'))
->setDisabled(!$can_lock)
->addCheckbox(
'is_membership_locked',
1,
pht('Prevent members from leaving this project.'),
$v_locked)
->setCaption($lock_message))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($edit_uri)