Page MenuHomePhorge

D25546.1734635216.diff
No OneTemporary

D25546.1734635216.diff

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,14 @@
return pht('Set Sail for Adventure');
}
+ public function getCommentFieldPlaceholderText($object) {
+ if ($object->getStatus() === ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE) {
+ return pht('This task is closed as a duplicate. '.
+ 'Only comment if you think that this task is not a duplicate.');
+ }
+ return '';
+ }
+
protected function getObjectViewURI($object) {
return '/'.$object->getMonogram();
}
diff --git a/src/applications/pholio/controller/PholioMockViewController.php b/src/applications/pholio/controller/PholioMockViewController.php
--- a/src/applications/pholio/controller/PholioMockViewController.php
+++ b/src/applications/pholio/controller/PholioMockViewController.php
@@ -223,7 +223,7 @@
$form = id(new PhabricatorApplicationTransactionCommentView())
->setUser($viewer)
- ->setObjectPHID($mock->getPHID())
+ ->setObject($mock)
->setFormID($comment_form_id)
->setDraft($draft)
->setHeaderText($title)
diff --git a/src/applications/ponder/controller/PonderQuestionViewController.php b/src/applications/ponder/controller/PonderQuestionViewController.php
--- a/src/applications/ponder/controller/PonderQuestionViewController.php
+++ b/src/applications/ponder/controller/PonderQuestionViewController.php
@@ -60,7 +60,7 @@
$add_comment = id(new PhabricatorApplicationTransactionCommentView())
->setUser($viewer)
- ->setObjectPHID($question->getPHID())
+ ->setObject($question)
->setShowPreview(false)
->setAction($this->getApplicationURI("/question/comment/{$id}/"))
->setSubmitButtonName(pht('Comment'));
diff --git a/src/applications/ponder/view/PonderAnswerView.php b/src/applications/ponder/view/PonderAnswerView.php
--- a/src/applications/ponder/view/PonderAnswerView.php
+++ b/src/applications/ponder/view/PonderAnswerView.php
@@ -121,7 +121,7 @@
$comment_view = id(new PhabricatorApplicationTransactionCommentView())
->setUser($viewer)
- ->setObjectPHID($answer->getPHID())
+ ->setObject($answer)
->setShowPreview(false)
->setHeaderText(pht('Answer Comment'))
->setAction("/ponder/answer/comment/{$id}/")
diff --git a/src/applications/slowvote/controller/PhabricatorSlowvotePollController.php b/src/applications/slowvote/controller/PhabricatorSlowvotePollController.php
--- a/src/applications/slowvote/controller/PhabricatorSlowvotePollController.php
+++ b/src/applications/slowvote/controller/PhabricatorSlowvotePollController.php
@@ -154,7 +154,7 @@
return id(new PhabricatorApplicationTransactionCommentView())
->setUser($viewer)
- ->setObjectPHID($poll->getPHID())
+ ->setObject($poll)
->setDraft($draft)
->setHeaderText($add_comment_header)
->setAction($this->getApplicationURI('/comment/'.$poll->getID().'/'))
diff --git a/src/applications/transactions/editengine/PhabricatorEditEngine.php b/src/applications/transactions/editengine/PhabricatorEditEngine.php
--- a/src/applications/transactions/editengine/PhabricatorEditEngine.php
+++ b/src/applications/transactions/editengine/PhabricatorEditEngine.php
@@ -339,7 +339,17 @@
return null;
}
-
+ /**
+ * Set default placeholder plain text in the comment textarea of the engine.
+ * To be overwritten by conditions defined in the child EditEngine class.
+ *
+ * @param object Object in which the comment textarea is displayed.
+ * @return string Placeholder text to display in the comment textarea.
+ * @task text
+ */
+ public function getCommentFieldPlaceholderText($object) {
+ return '';
+ }
/**
* Return a human-readable header describing what this engine is used to do,
@@ -1664,10 +1674,11 @@
$view = id(new PhabricatorApplicationTransactionCommentView())
->setUser($viewer)
- ->setObjectPHID($object_phid)
->setHeaderText($header_text)
->setAction($comment_uri)
->setRequiresMFA($requires_mfa)
+ ->setObject($object)
+ ->setEditEngine($this)
->setSubmitButtonName($button_text);
$draft = PhabricatorVersionedDraft::loadDraft(
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
@@ -15,11 +15,12 @@
private $draft;
private $requestURI;
private $showPreview = true;
- private $objectPHID;
+ private $object;
private $headerText;
private $noPermission;
private $fullWidth;
private $infoView;
+ private $editEngine;
private $editEngineLock;
private $noBorder;
private $requiresMFA;
@@ -30,13 +31,19 @@
private $commentActionGroups = array();
private $transactionTimeline;
- public function setObjectPHID($object_phid) {
- $this->objectPHID = $object_phid;
+ /**
+ * Set object in which this comment textarea field is displayed
+ */
+ public function setObject($object) {
+ $this->object = $object;
return $this;
}
- public function getObjectPHID() {
- return $this->objectPHID;
+ /**
+ * Get object in which this comment textarea is displayed
+ */
+ public function getObject() {
+ return $this->object;
}
public function setShowPreview($show_preview) {
@@ -150,6 +157,15 @@
return $this->noPermission;
}
+ public function setEditEngine(PhabricatorEditEngine $edit_engine) {
+ $this->editEngine = $edit_engine;
+ return $this;
+ }
+
+ public function getEditEngine() {
+ return $this->editEngine;
+ }
+
public function setEditEngineLock(PhabricatorEditEngineLock $lock) {
$this->editEngineLock = $lock;
return $this;
@@ -295,6 +311,15 @@
private function renderCommentPanel() {
$viewer = $this->getViewer();
+ $engine = $this->getEditEngine();
+ // In a few rare cases PhabricatorApplicationTransactionCommentView gets
+ // initiated in a View or Controller class. Don't crash in that case.
+ if ($engine) {
+ $placeholder_text = $engine
+ ->getCommentFieldPlaceholderText($this->getObject());
+ } else {
+ $placeholder_text = '';
+ }
$remarkup_control = id(new PhabricatorRemarkupControl())
->setViewer($viewer)
@@ -302,6 +327,7 @@
->addClass('phui-comment-fullwidth-control')
->addClass('phui-comment-textarea-control')
->setCanPin(true)
+ ->setPlaceholder($placeholder_text)
->setName('comment');
$draft_comment = '';
@@ -331,7 +357,7 @@
}
$remarkup_control->setRemarkupMetadata($draft_metadata);
- if (!$this->getObjectPHID()) {
+ if (!$this->getObject()->getPHID()) {
throw new PhutilInvalidStateException('setObjectPHID', 'render');
}
@@ -345,7 +371,7 @@
->setFullWidth($this->fullWidth)
->setMetadata(
array(
- 'objectPHID' => $this->getObjectPHID(),
+ 'objectPHID' => $this->getObject()->getPHID(),
))
->setAction($this->getAction())
->setID($this->getFormID())

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 19:06 (20 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1015413
Default Alt Text
D25546.1734635216.diff (7 KB)

Event Timeline