Page MenuHomePhabricator

D19270.id.diff
No OneTemporary

D19270.id.diff

diff --git a/src/infrastructure/customfield/editor/PhabricatorCustomFieldEditField.php b/src/infrastructure/customfield/editor/PhabricatorCustomFieldEditField.php
--- a/src/infrastructure/customfield/editor/PhabricatorCustomFieldEditField.php
+++ b/src/infrastructure/customfield/editor/PhabricatorCustomFieldEditField.php
@@ -7,6 +7,7 @@
private $httpParameterType;
private $conduitParameterType;
private $bulkParameterType;
+ private $commentAction;
public function setCustomField(PhabricatorCustomField $custom_field) {
$this->customField = $custom_field;
@@ -47,6 +48,16 @@
return $this->bulkParameterType;
}
+ public function setCustomFieldCommentAction(
+ PhabricatorEditEngineCommentAction $comment_action) {
+ $this->commentAction = $comment_action;
+ return $this;
+ }
+
+ public function getCustomFieldCommentAction() {
+ return $this->commentAction;
+ }
+
protected function buildControl() {
if ($this->getIsConduitOnly()) {
return null;
@@ -77,6 +88,19 @@
return $clone->getNewValueForApplicationTransactions();
}
+ protected function getValueForCommentAction($value) {
+ $field = $this->getCustomField();
+ $clone = clone $field;
+ $clone->setValueFromApplicationTransactions($value);
+
+ // TODO: This is somewhat bogus because only StandardCustomFields
+ // implement a getFieldValue() method -- not all CustomFields. Today,
+ // only StandardCustomFields can ever actually generate a comment action
+ // so we never reach this method with other field types.
+
+ return $clone->getFieldValue();
+ }
+
protected function getValueExistsInSubmit(AphrontRequest $request, $key) {
return true;
}
@@ -110,6 +134,16 @@
return null;
}
+ protected function newCommentAction() {
+ $action = $this->getCustomFieldCommentAction();
+
+ if ($action) {
+ return clone $action;
+ }
+
+ return null;
+ }
+
protected function newConduitParameterType() {
$type = $this->getCustomFieldConduitParameterType();
diff --git a/src/infrastructure/customfield/field/PhabricatorCustomField.php b/src/infrastructure/customfield/field/PhabricatorCustomField.php
--- a/src/infrastructure/customfield/field/PhabricatorCustomField.php
+++ b/src/infrastructure/customfield/field/PhabricatorCustomField.php
@@ -1127,6 +1127,16 @@
$field->setCustomFieldBulkParameterType($bulk_type);
}
+ $comment_action = $this->getCommentAction();
+ if ($comment_action) {
+ $field
+ ->setCustomFieldCommentAction($comment_action)
+ ->setCommentActionLabel(
+ pht(
+ 'Change %s',
+ $this->getFieldName()));
+ }
+
return $field;
}
@@ -1459,6 +1469,17 @@
return null;
}
+ public function getCommentAction() {
+ return $this->newCommentAction();
+ }
+
+ protected function newCommentAction() {
+ if ($this->proxy) {
+ return $this->proxy->newCommentAction();
+ }
+ return null;
+ }
+
/* -( Herald )------------------------------------------------------------- */
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldTokenizer.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldTokenizer.php
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldTokenizer.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldTokenizer.php
@@ -143,4 +143,26 @@
->setDatasource($datasource);
}
+ protected function newCommentAction() {
+ $viewer = $this->getViewer();
+
+ $datasource = $this->getDatasource()
+ ->setViewer($viewer);
+
+ $action = id(new PhabricatorEditEngineTokenizerCommentAction())
+ ->setDatasource($datasource);
+
+ $limit = $this->getFieldConfigValue('limit');
+ if ($limit) {
+ $action->setLimit($limit);
+ }
+
+ $value = $this->getFieldValue();
+ if ($value !== null) {
+ $action->setInitialValue($value);
+ }
+
+ return $action;
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 22, 12:23 AM (2 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7358228
Default Alt Text
D19270.id.diff (3 KB)

Event Timeline