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

Warn in comment field if task is closed as duplicate

Summary:
Display a placeholder text in the text comment field of a Maniphest task if the task status has been set to Duplicate.
This makes it clearer to users (who may have not checked the task status at the top of the page) not to fragment conversations.

Closes T15749

Test Plan:
* Be logged in and go to a task which is closed as a duplicate and see the placeholder text in the field to add a comment.
* Be logged in and go to tasks which are not closed as a duplicate and see no placeholder text in the field to add a comment.
* Go to other places whose code calls a `PhabricatorApplicationTransactionCommentView` constructor and check that it still renders correctly, for example Ponder in http://phorge.localhost/Q1, Slowvote in http://phorge.localhost/V1, Differential in http://phorge.localhost/D1

Reviewers: O1 Blessed Committers, valerio.bozzolan, avivey

Reviewed By: O1 Blessed Committers, valerio.bozzolan, avivey

Subscribers: avivey, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15749

Differential Revision: https://we.phorge.it/D25546

+58 -13
+8
src/applications/maniphest/editor/ManiphestEditEngine.php
··· 69 69 return pht('Set Sail for Adventure'); 70 70 } 71 71 72 + public function getCommentFieldPlaceholderText($object) { 73 + if ($object->getStatus() === ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE) { 74 + return pht('This task is closed as a duplicate. '. 75 + 'Only comment if you think that this task is not a duplicate.'); 76 + } 77 + return ''; 78 + } 79 + 72 80 protected function getObjectViewURI($object) { 73 81 return '/'.$object->getMonogram(); 74 82 }
+1 -1
src/applications/pholio/controller/PholioMockViewController.php
··· 223 223 224 224 $form = id(new PhabricatorApplicationTransactionCommentView()) 225 225 ->setUser($viewer) 226 - ->setObjectPHID($mock->getPHID()) 226 + ->setObject($mock) 227 227 ->setFormID($comment_form_id) 228 228 ->setDraft($draft) 229 229 ->setHeaderText($title)
+1 -1
src/applications/ponder/controller/PonderQuestionViewController.php
··· 60 60 61 61 $add_comment = id(new PhabricatorApplicationTransactionCommentView()) 62 62 ->setUser($viewer) 63 - ->setObjectPHID($question->getPHID()) 63 + ->setObject($question) 64 64 ->setShowPreview(false) 65 65 ->setAction($this->getApplicationURI("/question/comment/{$id}/")) 66 66 ->setSubmitButtonName(pht('Comment'));
+1 -1
src/applications/ponder/view/PonderAnswerView.php
··· 121 121 122 122 $comment_view = id(new PhabricatorApplicationTransactionCommentView()) 123 123 ->setUser($viewer) 124 - ->setObjectPHID($answer->getPHID()) 124 + ->setObject($answer) 125 125 ->setShowPreview(false) 126 126 ->setHeaderText(pht('Answer Comment')) 127 127 ->setAction("/ponder/answer/comment/{$id}/")
+1 -1
src/applications/slowvote/controller/PhabricatorSlowvotePollController.php
··· 154 154 155 155 return id(new PhabricatorApplicationTransactionCommentView()) 156 156 ->setUser($viewer) 157 - ->setObjectPHID($poll->getPHID()) 157 + ->setObject($poll) 158 158 ->setDraft($draft) 159 159 ->setHeaderText($add_comment_header) 160 160 ->setAction($this->getApplicationURI('/comment/'.$poll->getID().'/'))
+13 -2
src/applications/transactions/editengine/PhabricatorEditEngine.php
··· 339 339 return null; 340 340 } 341 341 342 - 342 + /** 343 + * Set default placeholder plain text in the comment textarea of the engine. 344 + * To be overwritten by conditions defined in the child EditEngine class. 345 + * 346 + * @param object Object in which the comment textarea is displayed. 347 + * @return string Placeholder text to display in the comment textarea. 348 + * @task text 349 + */ 350 + public function getCommentFieldPlaceholderText($object) { 351 + return ''; 352 + } 343 353 344 354 /** 345 355 * Return a human-readable header describing what this engine is used to do, ··· 1664 1674 1665 1675 $view = id(new PhabricatorApplicationTransactionCommentView()) 1666 1676 ->setUser($viewer) 1667 - ->setObjectPHID($object_phid) 1668 1677 ->setHeaderText($header_text) 1669 1678 ->setAction($comment_uri) 1670 1679 ->setRequiresMFA($requires_mfa) 1680 + ->setObject($object) 1681 + ->setEditEngine($this) 1671 1682 ->setSubmitButtonName($button_text); 1672 1683 1673 1684 $draft = PhabricatorVersionedDraft::loadDraft(
+33 -7
src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php
··· 15 15 private $draft; 16 16 private $requestURI; 17 17 private $showPreview = true; 18 - private $objectPHID; 18 + private $object; 19 19 private $headerText; 20 20 private $noPermission; 21 21 private $fullWidth; 22 22 private $infoView; 23 + private $editEngine; 23 24 private $editEngineLock; 24 25 private $noBorder; 25 26 private $requiresMFA; ··· 30 31 private $commentActionGroups = array(); 31 32 private $transactionTimeline; 32 33 33 - public function setObjectPHID($object_phid) { 34 - $this->objectPHID = $object_phid; 34 + /** 35 + * Set object in which this comment textarea field is displayed 36 + */ 37 + public function setObject($object) { 38 + $this->object = $object; 35 39 return $this; 36 40 } 37 41 38 - public function getObjectPHID() { 39 - return $this->objectPHID; 42 + /** 43 + * Get object in which this comment textarea is displayed 44 + */ 45 + public function getObject() { 46 + return $this->object; 40 47 } 41 48 42 49 public function setShowPreview($show_preview) { ··· 150 157 return $this->noPermission; 151 158 } 152 159 160 + public function setEditEngine(PhabricatorEditEngine $edit_engine) { 161 + $this->editEngine = $edit_engine; 162 + return $this; 163 + } 164 + 165 + public function getEditEngine() { 166 + return $this->editEngine; 167 + } 168 + 153 169 public function setEditEngineLock(PhabricatorEditEngineLock $lock) { 154 170 $this->editEngineLock = $lock; 155 171 return $this; ··· 295 311 296 312 private function renderCommentPanel() { 297 313 $viewer = $this->getViewer(); 314 + $engine = $this->getEditEngine(); 315 + // In a few rare cases PhabricatorApplicationTransactionCommentView gets 316 + // initiated in a View or Controller class. Don't crash in that case. 317 + if ($engine) { 318 + $placeholder_text = $engine 319 + ->getCommentFieldPlaceholderText($this->getObject()); 320 + } else { 321 + $placeholder_text = ''; 322 + } 298 323 299 324 $remarkup_control = id(new PhabricatorRemarkupControl()) 300 325 ->setViewer($viewer) ··· 302 327 ->addClass('phui-comment-fullwidth-control') 303 328 ->addClass('phui-comment-textarea-control') 304 329 ->setCanPin(true) 330 + ->setPlaceholder($placeholder_text) 305 331 ->setName('comment'); 306 332 307 333 $draft_comment = ''; ··· 331 357 } 332 358 $remarkup_control->setRemarkupMetadata($draft_metadata); 333 359 334 - if (!$this->getObjectPHID()) { 360 + if (!$this->getObject()->getPHID()) { 335 361 throw new PhutilInvalidStateException('setObjectPHID', 'render'); 336 362 } 337 363 ··· 345 371 ->setFullWidth($this->fullWidth) 346 372 ->setMetadata( 347 373 array( 348 - 'objectPHID' => $this->getObjectPHID(), 374 + 'objectPHID' => $this->getObject()->getPHID(), 349 375 )) 350 376 ->setAction($this->getAction()) 351 377 ->setID($this->getFormID())