diff --git a/src/applications/maniphest/editor/ManiphestEditEngine.php b/src/applications/maniphest/editor/ManiphestEditEngine.php --- a/src/applications/maniphest/editor/ManiphestEditEngine.php +++ b/src/applications/maniphest/editor/ManiphestEditEngine.php @@ -69,6 +69,29 @@ return pht('Set Sail for Adventure'); } + /** + * Set a placeholder text in the comment field. + * + * @param string PHID of the current object the comment field is + * displayed in to allow defining rendering conditions + * @return string Placeholder text to display in comment field + */ + public function getCommentFieldPlaceholderText($object_phid) { + $viewer = $this->getViewer(); + $query = id(new ManiphestTaskQuery()) + ->setViewer($viewer) + ->needSubscriberPHIDs(false) + ->needProjectPHIDs(false); + $query->withPHIDs(array($object_phid)); + $task = $query->executeOne(); + + if ($task->getStatus() === ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE) { + return pht('This task is closed as a duplicate. '. + 'Only comment here if you think that this task is not a duplicate.'); + } + return ''; + } + protected function getObjectViewURI($object) { return '/'.$object->getMonogram(); } diff --git a/src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php b/src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php --- a/src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php +++ b/src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php @@ -296,12 +296,38 @@ private function renderCommentPanel() { $viewer = $this->getViewer(); + // Set a placeholder text in the comment field defined via + // getCommentFieldPlaceholderText() in the object's EditEngine class + $placeholder_text = ''; + $object_phid = $this->getObjectPHID(); + + $phid_types = mpull(PhabricatorPHIDType::getAllInstalledTypes($viewer), + null, 'getTypeConstant'); + $object_type = idx($phid_types, substr($object_phid, 5, 4)); + // Find matching EditEngine for our object via ApplicationClasses + if ($object_type) { + $app_class = $object_type->getPHIDTypeApplicationClass(); + + $engines = id(new PhabricatorEditEngineQuery()) + ->setViewer($this->getViewer()) + ->execute(); + $engines = mpull($engines, null, 'getEngineApplicationClass'); + $engine = idx($engines, $app_class); + $engine_class = get_class($engine); + + if (method_exists($engine_class, 'getCommentFieldPlaceholderText')) { + $placeholder_text = + $engine->getCommentFieldPlaceholderText($object_phid); + } + } + $remarkup_control = id(new PhabricatorRemarkupControl()) ->setViewer($viewer) ->setID($this->getCommentID()) ->addClass('phui-comment-fullwidth-control') ->addClass('phui-comment-textarea-control') ->setCanPin(true) + ->setPlaceholder($placeholder_text) ->setName('comment'); $draft_comment = '';