@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Provide comment actions for tokenizer custom fields

Summary:
Ref T13114. See PHI519. An install is interested in modifying a tokenizer custom field from the comment area. Provide this capability.

This patch is fairly narrow but should solve the immediate need.

Test Plan: Added, removed, and modified a tokenizer custom field using the comment action dropdown.

Maniphest Tasks: T13114

Differential Revision: https://secure.phabricator.com/D19270

+77
+34
src/infrastructure/customfield/editor/PhabricatorCustomFieldEditField.php
··· 7 7 private $httpParameterType; 8 8 private $conduitParameterType; 9 9 private $bulkParameterType; 10 + private $commentAction; 10 11 11 12 public function setCustomField(PhabricatorCustomField $custom_field) { 12 13 $this->customField = $custom_field; ··· 47 48 return $this->bulkParameterType; 48 49 } 49 50 51 + public function setCustomFieldCommentAction( 52 + PhabricatorEditEngineCommentAction $comment_action) { 53 + $this->commentAction = $comment_action; 54 + return $this; 55 + } 56 + 57 + public function getCustomFieldCommentAction() { 58 + return $this->commentAction; 59 + } 60 + 50 61 protected function buildControl() { 51 62 if ($this->getIsConduitOnly()) { 52 63 return null; ··· 77 88 return $clone->getNewValueForApplicationTransactions(); 78 89 } 79 90 91 + protected function getValueForCommentAction($value) { 92 + $field = $this->getCustomField(); 93 + $clone = clone $field; 94 + $clone->setValueFromApplicationTransactions($value); 95 + 96 + // TODO: This is somewhat bogus because only StandardCustomFields 97 + // implement a getFieldValue() method -- not all CustomFields. Today, 98 + // only StandardCustomFields can ever actually generate a comment action 99 + // so we never reach this method with other field types. 100 + 101 + return $clone->getFieldValue(); 102 + } 103 + 80 104 protected function getValueExistsInSubmit(AphrontRequest $request, $key) { 81 105 return true; 82 106 } ··· 105 129 106 130 if ($type) { 107 131 return clone $type; 132 + } 133 + 134 + return null; 135 + } 136 + 137 + protected function newCommentAction() { 138 + $action = $this->getCustomFieldCommentAction(); 139 + 140 + if ($action) { 141 + return clone $action; 108 142 } 109 143 110 144 return null;
+21
src/infrastructure/customfield/field/PhabricatorCustomField.php
··· 1127 1127 $field->setCustomFieldBulkParameterType($bulk_type); 1128 1128 } 1129 1129 1130 + $comment_action = $this->getCommentAction(); 1131 + if ($comment_action) { 1132 + $field 1133 + ->setCustomFieldCommentAction($comment_action) 1134 + ->setCommentActionLabel( 1135 + pht( 1136 + 'Change %s', 1137 + $this->getFieldName())); 1138 + } 1139 + 1130 1140 return $field; 1131 1141 } 1132 1142 ··· 1455 1465 protected function newConduitEditParameterType() { 1456 1466 if ($this->proxy) { 1457 1467 return $this->proxy->newConduitEditParameterType(); 1468 + } 1469 + return null; 1470 + } 1471 + 1472 + public function getCommentAction() { 1473 + return $this->newCommentAction(); 1474 + } 1475 + 1476 + protected function newCommentAction() { 1477 + if ($this->proxy) { 1478 + return $this->proxy->newCommentAction(); 1458 1479 } 1459 1480 return null; 1460 1481 }
+22
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldTokenizer.php
··· 143 143 ->setDatasource($datasource); 144 144 } 145 145 146 + protected function newCommentAction() { 147 + $viewer = $this->getViewer(); 148 + 149 + $datasource = $this->getDatasource() 150 + ->setViewer($viewer); 151 + 152 + $action = id(new PhabricatorEditEngineTokenizerCommentAction()) 153 + ->setDatasource($datasource); 154 + 155 + $limit = $this->getFieldConfigValue('limit'); 156 + if ($limit) { 157 + $action->setLimit($limit); 158 + } 159 + 160 + $value = $this->getFieldValue(); 161 + if ($value !== null) { 162 + $action->setInitialValue($value); 163 + } 164 + 165 + return $action; 166 + } 167 + 146 168 }