@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.

Render Maniphest fields in an application-transactions-compatible way

Summary: Improves transaction rendering for custom fields and standard custom fields.

Test Plan: See screenshot.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

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

+217 -39
+2
src/__phutil_library_map__.php
··· 735 735 'ManiphestTransactionEditor' => 'applications/maniphest/editor/ManiphestTransactionEditor.php', 736 736 'ManiphestTransactionListView' => 'applications/maniphest/view/ManiphestTransactionListView.php', 737 737 'ManiphestTransactionPreviewController' => 'applications/maniphest/controller/ManiphestTransactionPreviewController.php', 738 + 'ManiphestTransactionPro' => 'applications/maniphest/storage/ManiphestTransactionPro.php', 738 739 'ManiphestTransactionSaveController' => 'applications/maniphest/controller/ManiphestTransactionSaveController.php', 739 740 'ManiphestTransactionType' => 'applications/maniphest/constants/ManiphestTransactionType.php', 740 741 'ManiphestView' => 'applications/maniphest/view/ManiphestView.php', ··· 2828 2829 'ManiphestTransactionEditor' => 'PhabricatorEditor', 2829 2830 'ManiphestTransactionListView' => 'ManiphestView', 2830 2831 'ManiphestTransactionPreviewController' => 'ManiphestController', 2832 + 'ManiphestTransactionPro' => 'PhabricatorApplicationTransaction', 2831 2833 'ManiphestTransactionSaveController' => 'ManiphestController', 2832 2834 'ManiphestTransactionType' => 'ManiphestConstants', 2833 2835 'ManiphestView' => 'AphrontView',
+1 -1
src/applications/maniphest/controller/ManiphestTaskEditController.php
··· 153 153 $placeholder_editor, 154 154 PhabricatorTransactions::TYPE_CUSTOMFIELD, 155 155 array( 156 - id(new PhabricatorUserTransaction()) 156 + id(new ManiphestTransactionPro()) 157 157 ->setOldValue($aux_old_value) 158 158 ->setNewValue($aux_new_value), 159 159 ));
-19
src/applications/maniphest/field/ManiphestCustomField.php
··· 28 28 return false; 29 29 } 30 30 31 - 32 - // TODO: All of this is legacy junk. 33 - 34 - public function renderTransactionEmailVerb( 35 - ManiphestTransaction $transaction) { 36 - return null; 37 - } 38 - 39 - public function renderTransactionDescription( 40 - ManiphestTransaction $transaction) { 41 - $old = $transaction->getOldValue(); 42 - $new = $transaction->getNewValue(); 43 - return pht( 44 - 'updated field %s from %s to %s', 45 - $this->getFieldName(), 46 - hsprintf('%s', $old), 47 - hsprintf('%s', $new)); 48 - } 49 - 50 31 }
+19
src/applications/maniphest/storage/ManiphestTransactionPro.php
··· 1 + <?php 2 + 3 + final class ManiphestTransactionPro 4 + extends PhabricatorApplicationTransaction { 5 + 6 + public function getApplicationName() { 7 + return 'maniphest'; 8 + } 9 + 10 + public function getApplicationTransactionType() { 11 + return ManiphestPHIDTypeTask::TYPECONST; 12 + } 13 + 14 + public function getApplicationTransactionCommentObject() { 15 + return null; 16 + } 17 + 18 + } 19 +
+39 -19
src/applications/maniphest/view/ManiphestTransactionDetailView.php
··· 92 92 $descs = array(); 93 93 $comments = null; 94 94 foreach ($this->transactions as $transaction) { 95 - list($verb, $desc, $classes) = $this->describeAction($transaction); 96 - if ($desc === null) { 97 - continue; 95 + list($verb, $desc, $classes, $full) = $this->describeAction($transaction); 96 + 97 + if ($full) { 98 + $desc = $full; 99 + } else { 100 + if ($desc === null) { 101 + continue; 102 + } else { 103 + $desc = $author.' '.$desc.'.'; 104 + } 98 105 } 106 + 99 107 if ($action === null) { 100 108 $action = $verb; 101 109 } 102 - $desc = $author.' '.$desc.'.'; 110 + 103 111 if ($with_date) { 104 112 // NOTE: This is going into a (potentially multi-recipient) email so 105 113 // we can't use a single user's timezone preferences. Use the server's ··· 155 163 $more_classes = array(); 156 164 $descs = array(); 157 165 foreach ($transactions as $transaction) { 158 - list($verb, $desc, $classes) = $this->describeAction($transaction); 166 + list($verb, $desc, $classes, $full) = $this->describeAction($transaction); 167 + if ($full) { 168 + $descs[] = javelin_tag( 169 + 'div', 170 + array( 171 + 'sigil' => 'maniphest-transaction-description', 172 + ), 173 + $full); 174 + continue; 175 + } 176 + 159 177 if ($desc === null) { 160 178 continue; 161 179 } ··· 301 319 private function describeAction($transaction) { 302 320 $verb = null; 303 321 $desc = null; 322 + $full = null; 304 323 $classes = array(); 305 324 306 325 $handles = $this->handles; ··· 525 544 $aux_field = $this->getAuxiliaryField('std:maniphest:'.$aux_key); 526 545 } 527 546 528 - $verb = null; 529 - if ($aux_field) { 530 - $verb = $aux_field->renderTransactionEmailVerb($transaction); 531 - } 532 - if ($verb === null) { 533 - if ($old === null) { 534 - $verb = "Set Field"; 535 - } else if ($new === null) { 536 - $verb = "Removed Field"; 537 - } else { 538 - $verb = "Updated Field"; 539 - } 547 + if ($old === null) { 548 + $verb = "Set Field"; 549 + } else if ($new === null) { 550 + $verb = "Removed Field"; 551 + } else { 552 + $verb = "Updated Field"; 540 553 } 541 554 542 555 $desc = null; 543 556 if ($aux_field) { 544 - $desc = $aux_field->renderTransactionDescription($transaction); 557 + $proxy_transaction = new ManiphestTransactionPro(); 558 + $proxy_transaction->setOldValue($transaction->getOldValue()); 559 + $proxy_transaction->setNewValue($transaction->getNewValue()); 560 + $proxy_transaction->setAuthorPHID($transaction->getAuthorPHID()); 561 + $proxy_transaction->setHandles($this->handles); 562 + 563 + $full = $aux_field->getApplicationTransactionTitle( 564 + $proxy_transaction); 545 565 } else { 546 566 $desc = 'updated a field'; 547 567 } ··· 556 576 // correctly right now. 557 577 $desc = phutil_safe_html($desc); 558 578 559 - return array($verb, $desc, $classes); 579 + return array($verb, $desc, $classes, $full); 560 580 } 561 581 562 582 private function renderFullSummary($transaction) {
+13
src/infrastructure/customfield/field/PhabricatorCustomField.php
··· 873 873 return array(); 874 874 } 875 875 876 + public function getApplicationTransactionTitle( 877 + PhabricatorApplicationTransaction $xaction) { 878 + if ($this->proxy) { 879 + return $this->proxy->getApplicationTransactionTitle( 880 + $xaction); 881 + } 882 + 883 + $author_phid = $xaction->getAuthorPHID(); 884 + return pht( 885 + '%s updated this object.', 886 + $xaction->renderHandleLink($author_phid)); 887 + } 888 + 876 889 877 890 /* -( Edit View )---------------------------------------------------------- */ 878 891
+28
src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php
··· 300 300 return !strlen($value); 301 301 } 302 302 303 + public function getApplicationTransactionTitle( 304 + PhabricatorApplicationTransaction $xaction) { 305 + $author_phid = $xaction->getAuthorPHID(); 306 + $old = $xaction->getOldValue(); 307 + $new = $xaction->getNewValue(); 308 + 309 + if (!$old) { 310 + return pht( 311 + '%s set %s to %s.', 312 + $xaction->renderHandleLink($author_phid), 313 + $this->getFieldName(), 314 + $new); 315 + } else if (!$new) { 316 + return pht( 317 + '%s removed %s.', 318 + $xaction->renderHandleLink($author_phid), 319 + $this->getFieldName()); 320 + } else { 321 + return pht( 322 + '%s changed %s from %s to %s.', 323 + $xaction->renderHandleLink($author_phid), 324 + $this->getFieldName(), 325 + $old, 326 + $new); 327 + } 328 + } 329 + 330 + 303 331 }
+19
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBool.php
··· 92 92 } 93 93 } 94 94 95 + public function getApplicationTransactionTitle( 96 + PhabricatorApplicationTransaction $xaction) { 97 + $author_phid = $xaction->getAuthorPHID(); 98 + $old = $xaction->getOldValue(); 99 + $new = $xaction->getNewValue(); 100 + 101 + if ($new) { 102 + return pht( 103 + '%s checked %s.', 104 + $xaction->renderHandleLink($author_phid), 105 + $this->getFieldName()); 106 + } else { 107 + return pht( 108 + '%s unchecked %s.', 109 + $xaction->renderHandleLink($author_phid), 110 + $this->getFieldName()); 111 + } 112 + } 113 + 95 114 96 115 }
+39
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php
··· 74 74 // but don't provide a UI for searching. To do so, we need a reasonable date 75 75 // range control and the ability to add a range constraint. 76 76 77 + public function getApplicationTransactionTitle( 78 + PhabricatorApplicationTransaction $xaction) { 79 + $author_phid = $xaction->getAuthorPHID(); 80 + $old = $xaction->getOldValue(); 81 + $new = $xaction->getNewValue(); 82 + 83 + $viewer = $this->getViewer(); 84 + 85 + $old_date = null; 86 + if ($old) { 87 + $old_date = phabricator_datetime($old, $viewer); 88 + } 89 + 90 + $new_date = null; 91 + if ($new) { 92 + $new_date = phabricator_datetime($new, $viewer); 93 + } 94 + 95 + if (!$old) { 96 + return pht( 97 + '%s set %s to %s.', 98 + $xaction->renderHandleLink($author_phid), 99 + $this->getFieldName(), 100 + $new_date); 101 + } else if (!$new) { 102 + return pht( 103 + '%s removed %s.', 104 + $xaction->renderHandleLink($author_phid), 105 + $this->getFieldName()); 106 + } else { 107 + return pht( 108 + '%s changed %s from %s to %s.', 109 + $xaction->renderHandleLink($author_phid), 110 + $this->getFieldName(), 111 + $old_date, 112 + $new_date); 113 + } 114 + } 115 + 77 116 }
+13
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php
··· 37 37 $viewer); 38 38 } 39 39 40 + public function getApplicationTransactionTitle( 41 + PhabricatorApplicationTransaction $xaction) { 42 + $author_phid = $xaction->getAuthorPHID(); 43 + 44 + // TODO: Expose fancy transactions. 45 + 46 + return pht( 47 + '%s edited %s.', 48 + $xaction->renderHandleLink($author_phid), 49 + $this->getFieldName()); 50 + } 51 + 52 + 40 53 }
+31
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldSelect.php
··· 77 77 return idx($this->getOptions(), $this->getFieldValue()); 78 78 } 79 79 80 + 81 + public function getApplicationTransactionTitle( 82 + PhabricatorApplicationTransaction $xaction) { 83 + $author_phid = $xaction->getAuthorPHID(); 84 + $old = $xaction->getOldValue(); 85 + $new = $xaction->getNewValue(); 86 + 87 + $old = idx($this->getOptions(), $old, $old); 88 + $new = idx($this->getOptions(), $new, $new); 89 + 90 + if (!$old) { 91 + return pht( 92 + '%s set %s to %s.', 93 + $xaction->renderHandleLink($author_phid), 94 + $this->getFieldName(), 95 + $new); 96 + } else if (!$new) { 97 + return pht( 98 + '%s removed %s.', 99 + $xaction->renderHandleLink($author_phid), 100 + $this->getFieldName()); 101 + } else { 102 + return pht( 103 + '%s changed %s from %s to %s.', 104 + $xaction->renderHandleLink($author_phid), 105 + $this->getFieldName(), 106 + $old, 107 + $new); 108 + } 109 + } 110 + 80 111 }
+13
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php
··· 50 50 $form->appendChild($control); 51 51 } 52 52 53 + 54 + public function getApplicationTransactionTitle( 55 + PhabricatorApplicationTransaction $xaction) { 56 + $author_phid = $xaction->getAuthorPHID(); 57 + 58 + // TODO: Show added/removed and render handles. We don't have handle 59 + // surfacing or batching yet so this is a bit awkward right now. 60 + 61 + return pht( 62 + '%s updated %s.', 63 + $xaction->renderHandleLink($author_phid), 64 + $this->getFieldName()); 65 + } 53 66 }