1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-29 16:08:22 +01:00

Provide "Initial Members" instead of default joining projects

Summary:
Ref T10010. Instead of autojoining projects, provide "Initial Members: [___]" that the user can fill in.

This is only available in the web UI when creating a (non-milestone) project.

Test Plan:
  - Created a new project with no members.
  - Created a new project with some members.
  - Created a new milestone (no control).
  - Created a new project with myself as a member and an "Editable By: Project Members" policy, to verify this use case still works properly.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10010

Differential Revision: https://secure.phabricator.com/D15195
This commit is contained in:
epriestley 2016-02-05 13:26:47 -08:00
parent d30b57313e
commit 1db4de7dbc
2 changed files with 50 additions and 23 deletions

View file

@ -219,7 +219,12 @@ final class PhabricatorProjectTransactionEditor
foreach ($xactions as $xaction) {
switch ($xaction->getTransactionType()) {
case PhabricatorProjectTransaction::TYPE_MEMBERS:
case PhabricatorTransactions::TYPE_EDGE:
$type = $xaction->getMetadataValue('edge:type');
if ($type != PhabricatorProjectProjectHasMemberEdgeType::EDGECONST) {
break;
}
if ($is_parent) {
$errors[] = new PhabricatorApplicationTransactionValidationError(
$xaction->getTransactionType(),
@ -792,27 +797,6 @@ final class PhabricatorProjectTransactionEditor
$results = parent::expandTransactions($object, $xactions);
// Automatically add the author as a member when they create a project
// if they're using the web interface.
$content_source = $this->getContentSource();
$source_web = PhabricatorContentSource::SOURCE_WEB;
$is_web = ($content_source->getSource() === $source_web);
if ($this->getIsNewObject() && $is_web) {
if ($actor_phid) {
$type_member = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST;
$results[] = id(new PhabricatorProjectTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
->setMetadataValue('edge:type', $type_member)
->setNewValue(
array(
'+' => array($actor_phid => $actor_phid),
));
}
}
$is_milestone = $object->isMilestone();
foreach ($xactions as $xaction) {
switch ($xaction->getTransactionType()) {

View file

@ -176,7 +176,7 @@ final class PhabricatorProjectEditEngine
$milestone_phid = null;
}
return array(
$fields = array(
id(new PhabricatorHandlesEditField())
->setKey('parent')
->setLabel(pht('Parent'))
@ -243,6 +243,49 @@ final class PhabricatorProjectEditEngine
->setConduitTypeDescription(pht('New list of slugs.'))
->setValue($slugs),
);
$can_edit_members = (!$milestone) &&
(!$object->isMilestone()) &&
(!$object->getHasSubprojects());
if ($can_edit_members) {
// Show this on the web UI when creating a project, but not when editing
// one. It is always available via Conduit.
$conduit_only = !$this->getIsCreate();
$members_field = id(new PhabricatorUsersEditField())
->setKey('members')
->setAliases(array('memberPHIDs'))
->setLabel(pht('Initial Members'))
->setIsConduitOnly($conduit_only)
->setUseEdgeTransactions(true)
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
->setMetadataValue(
'edge:type',
PhabricatorProjectProjectHasMemberEdgeType::EDGECONST)
->setDescription(pht('Initial project members.'))
->setConduitDescription(pht('Set project members.'))
->setConduitTypeDescription(pht('New list of members.'))
->setValue(array());
$members_field->setViewer($this->getViewer());
$edit_add = $members_field->getConduitEditType('members.add')
->setConduitDescription(pht('Add members.'));
$edit_set = $members_field->getConduitEditType('members.set')
->setConduitDescription(
pht('Set members, overwriting the current value.'));
$edit_rem = $members_field->getConduitEditType('members.remove')
->setConduitDescription(pht('Remove members.'));
$fields[] = $members_field;
}
return $fields;
}
}