1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-28 09:42:41 +01:00
phorge-phorge/src/applications/transactions/editfield/PhabricatorApplyEditField.php
epriestley fab37aa4e3 When accepting revisions, allow users to accept on behalf of a subset of reviewers
Summary:
Ref T12271. Currenty, when you "Accept" a revision, you always accept it for all reviewers you have authority over.

There are some situations where communication can be more clear if users can accept as only themselves, or for only some packages, etc. T12271 discusses some of these use cases in more depth.

Instead of making "Accept" a blanket action, default it to doing what it does now but let the user uncheck reviewers.

In cases where project/package reviewers aren't in use, this doesn't change anything.

For now, "reject" still acts the old way (reject everything). We could make that use checkboxes too, but I'm not sure there's as much of a use case for it, and I generally want users who are blocking stuff to have more direct accountability in a product sense.

Test Plan:
  - Accepted normally.
  - Accepted a subset.
  - Tried to accept none.
  - Tried to accept bogus reviewers.
  - Accepted with myself not a reviewer
  - Accepted with only one reviewer (just got normal "this will be accepted" text).

{F4251255}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12271

Differential Revision: https://secure.phabricator.com/D17533
2017-03-22 14:25:04 -07:00

72 lines
1.8 KiB
PHP

<?php
final class PhabricatorApplyEditField
extends PhabricatorEditField {
private $actionDescription;
private $actionConflictKey;
private $options;
protected function newControl() {
return null;
}
public function setActionDescription($action_description) {
$this->actionDescription = $action_description;
return $this;
}
public function getActionDescription() {
return $this->actionDescription;
}
public function setActionConflictKey($action_conflict_key) {
$this->actionConflictKey = $action_conflict_key;
return $this;
}
public function getActionConflictKey() {
return $this->actionConflictKey;
}
public function setOptions(array $options) {
$this->options = $options;
return $this;
}
public function getOptions() {
return $this->options;
}
protected function newHTTPParameterType() {
if ($this->getOptions()) {
return new AphrontPHIDListHTTPParameterType();
} else {
return new AphrontBoolHTTPParameterType();
}
}
protected function newConduitParameterType() {
return new ConduitBoolParameterType();
}
public function shouldGenerateTransactionsFromSubmit() {
// This type of edit field just applies a prebuilt action, like "Accept
// Revision", and can not be submitted as part of an "Edit Object" form.
return false;
}
protected function newCommentAction() {
$options = $this->getOptions();
if ($options) {
return id(new PhabricatorEditEngineCheckboxesCommentAction())
->setConflictKey($this->getActionConflictKey())
->setOptions($options);
} else {
return id(new PhabricatorEditEngineStaticCommentAction())
->setConflictKey($this->getActionConflictKey())
->setDescription($this->getActionDescription());
}
}
}