mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-01 19:22:42 +01:00
Accept null
via conduit.edit
to unassign a task
Summary: See <https://discourse.phabricator-community.org/t/maniphest-edit-to-unassign-owner-documentation-is-wrong/1053>. This unusual field doesn't actually accept `null`, although the documentation says it does and that was the intent. Accept `null`, and show `phid|null` in the docs. Test Plan: Viewed docs, saw `phid|null`. Unassigned with `null`. Reviewers: amckinley Reviewed By: amckinley Differential Revision: https://secure.phabricator.com/D18976
This commit is contained in:
parent
f9336e5694
commit
6d5f265a57
4 changed files with 56 additions and 13 deletions
|
@ -3,9 +3,26 @@
|
||||||
final class ConduitPHIDParameterType
|
final class ConduitPHIDParameterType
|
||||||
extends ConduitParameterType {
|
extends ConduitParameterType {
|
||||||
|
|
||||||
|
private $isNullable;
|
||||||
|
|
||||||
|
public function setIsNullable($is_nullable) {
|
||||||
|
$this->isNullable = $is_nullable;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIsNullable() {
|
||||||
|
return $this->isNullable;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getParameterValue(array $request, $key, $strict) {
|
protected function getParameterValue(array $request, $key, $strict) {
|
||||||
$value = parent::getParameterValue($request, $key, $strict);
|
$value = parent::getParameterValue($request, $key, $strict);
|
||||||
|
|
||||||
|
if ($this->getIsNullable()) {
|
||||||
|
if ($value === null) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!is_string($value)) {
|
if (!is_string($value)) {
|
||||||
$this->raiseValidationException(
|
$this->raiseValidationException(
|
||||||
$request,
|
$request,
|
||||||
|
@ -17,8 +34,12 @@ final class ConduitPHIDParameterType
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getParameterTypeName() {
|
protected function getParameterTypeName() {
|
||||||
|
if ($this->getIsNullable()) {
|
||||||
|
return 'phid|null';
|
||||||
|
} else {
|
||||||
return 'phid';
|
return 'phid';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function getParameterFormatDescriptions() {
|
protected function getParameterFormatDescriptions() {
|
||||||
return array(
|
return array(
|
||||||
|
@ -27,9 +48,15 @@ final class ConduitPHIDParameterType
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getParameterExamples() {
|
protected function getParameterExamples() {
|
||||||
return array(
|
$examples = array(
|
||||||
'"PHID-WXYZ-1111222233334444"',
|
'"PHID-WXYZ-1111222233334444"',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($this->getIsNullable()) {
|
||||||
|
$examples[] = 'null';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $examples;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,6 +196,7 @@ EODOCS
|
||||||
pht('New task owner, or `null` to unassign.'))
|
pht('New task owner, or `null` to unassign.'))
|
||||||
->setTransactionType(ManiphestTaskOwnerTransaction::TRANSACTIONTYPE)
|
->setTransactionType(ManiphestTaskOwnerTransaction::TRANSACTIONTYPE)
|
||||||
->setIsCopyable(true)
|
->setIsCopyable(true)
|
||||||
|
->setIsNullable(true)
|
||||||
->setSingleValue($object->getOwnerPHID())
|
->setSingleValue($object->getOwnerPHID())
|
||||||
->setCommentActionLabel(pht('Assign / Claim'))
|
->setCommentActionLabel(pht('Assign / Claim'))
|
||||||
->setCommentActionValue($owner_value),
|
->setCommentActionValue($owner_value),
|
||||||
|
|
|
@ -5,6 +5,7 @@ abstract class PhabricatorPHIDListEditField
|
||||||
|
|
||||||
private $useEdgeTransactions;
|
private $useEdgeTransactions;
|
||||||
private $isSingleValue;
|
private $isSingleValue;
|
||||||
|
private $isNullable;
|
||||||
|
|
||||||
public function setUseEdgeTransactions($use_edge_transactions) {
|
public function setUseEdgeTransactions($use_edge_transactions) {
|
||||||
$this->useEdgeTransactions = $use_edge_transactions;
|
$this->useEdgeTransactions = $use_edge_transactions;
|
||||||
|
@ -30,13 +31,23 @@ abstract class PhabricatorPHIDListEditField
|
||||||
return $this->isSingleValue;
|
return $this->isSingleValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setIsNullable($is_nullable) {
|
||||||
|
$this->isNullable = $is_nullable;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIsNullable() {
|
||||||
|
return $this->isNullable;
|
||||||
|
}
|
||||||
|
|
||||||
protected function newHTTPParameterType() {
|
protected function newHTTPParameterType() {
|
||||||
return new AphrontPHIDListHTTPParameterType();
|
return new AphrontPHIDListHTTPParameterType();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function newConduitParameterType() {
|
protected function newConduitParameterType() {
|
||||||
if ($this->getIsSingleValue()) {
|
if ($this->getIsSingleValue()) {
|
||||||
return new ConduitPHIDParameterType();
|
return id(new ConduitPHIDParameterType())
|
||||||
|
->setIsNullable($this->getIsNullable());
|
||||||
} else {
|
} else {
|
||||||
return new ConduitPHIDListParameterType();
|
return new ConduitPHIDListParameterType();
|
||||||
}
|
}
|
||||||
|
@ -99,7 +110,8 @@ abstract class PhabricatorPHIDListEditField
|
||||||
}
|
}
|
||||||
|
|
||||||
return id(new PhabricatorDatasourceEditType())
|
return id(new PhabricatorDatasourceEditType())
|
||||||
->setIsSingleValue($this->getIsSingleValue());
|
->setIsSingleValue($this->getIsSingleValue())
|
||||||
|
->setIsNullable($this->getIsNullable());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function newBulkEditTypes() {
|
protected function newBulkEditTypes() {
|
||||||
|
|
|
@ -6,6 +6,7 @@ abstract class PhabricatorPHIDListEditType
|
||||||
private $datasource;
|
private $datasource;
|
||||||
private $isSingleValue;
|
private $isSingleValue;
|
||||||
private $defaultValue;
|
private $defaultValue;
|
||||||
|
private $isNullable;
|
||||||
|
|
||||||
public function setDatasource(PhabricatorTypeaheadDatasource $datasource) {
|
public function setDatasource(PhabricatorTypeaheadDatasource $datasource) {
|
||||||
$this->datasource = $datasource;
|
$this->datasource = $datasource;
|
||||||
|
@ -30,16 +31,17 @@ abstract class PhabricatorPHIDListEditType
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDefaultValue() {
|
public function setIsNullable($is_nullable) {
|
||||||
return $this->defaultValue;
|
$this->isNullable = $is_nullable;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValueType() {
|
public function getIsNullable() {
|
||||||
if ($this->getIsSingleValue()) {
|
return $this->isNullable;
|
||||||
return 'phid';
|
|
||||||
} else {
|
|
||||||
return 'list<phid>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDefaultValue() {
|
||||||
|
return $this->defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function newConduitParameterType() {
|
protected function newConduitParameterType() {
|
||||||
|
@ -49,7 +51,8 @@ abstract class PhabricatorPHIDListEditType
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->getIsSingleValue()) {
|
if ($this->getIsSingleValue()) {
|
||||||
return new ConduitPHIDParameterType();
|
return id(new ConduitPHIDParameterType())
|
||||||
|
->setIsNullable($this->getIsNullable());
|
||||||
} else {
|
} else {
|
||||||
return new ConduitPHIDListParameterType();
|
return new ConduitPHIDListParameterType();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue