mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
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
This commit is contained in:
parent
eda7a608e5
commit
ed9d212013
7 changed files with 58 additions and 13 deletions
|
@ -69,6 +69,14 @@ final class ManiphestEditEngine
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -223,7 +223,7 @@ final class PholioMockViewController extends PholioController {
|
|||
|
||||
$form = id(new PhabricatorApplicationTransactionCommentView())
|
||||
->setUser($viewer)
|
||||
->setObjectPHID($mock->getPHID())
|
||||
->setObject($mock)
|
||||
->setFormID($comment_form_id)
|
||||
->setDraft($draft)
|
||||
->setHeaderText($title)
|
||||
|
|
|
@ -60,7 +60,7 @@ final class PonderQuestionViewController extends PonderController {
|
|||
|
||||
$add_comment = id(new PhabricatorApplicationTransactionCommentView())
|
||||
->setUser($viewer)
|
||||
->setObjectPHID($question->getPHID())
|
||||
->setObject($question)
|
||||
->setShowPreview(false)
|
||||
->setAction($this->getApplicationURI("/question/comment/{$id}/"))
|
||||
->setSubmitButtonName(pht('Comment'));
|
||||
|
|
|
@ -121,7 +121,7 @@ final class PonderAnswerView extends AphrontTagView {
|
|||
|
||||
$comment_view = id(new PhabricatorApplicationTransactionCommentView())
|
||||
->setUser($viewer)
|
||||
->setObjectPHID($answer->getPHID())
|
||||
->setObject($answer)
|
||||
->setShowPreview(false)
|
||||
->setHeaderText(pht('Answer Comment'))
|
||||
->setAction("/ponder/answer/comment/{$id}/")
|
||||
|
|
|
@ -154,7 +154,7 @@ final class PhabricatorSlowvotePollController
|
|||
|
||||
return id(new PhabricatorApplicationTransactionCommentView())
|
||||
->setUser($viewer)
|
||||
->setObjectPHID($poll->getPHID())
|
||||
->setObject($poll)
|
||||
->setDraft($draft)
|
||||
->setHeaderText($add_comment_header)
|
||||
->setAction($this->getApplicationURI('/comment/'.$poll->getID().'/'))
|
||||
|
|
|
@ -339,7 +339,17 @@ abstract class PhabricatorEditEngine
|
|||
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 @@ abstract class PhabricatorEditEngine
|
|||
|
||||
$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(
|
||||
|
|
|
@ -15,11 +15,12 @@ final class PhabricatorApplicationTransactionCommentView
|
|||
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 @@ final class PhabricatorApplicationTransactionCommentView
|
|||
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 @@ final class PhabricatorApplicationTransactionCommentView
|
|||
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 @@ final class PhabricatorApplicationTransactionCommentView
|
|||
|
||||
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 @@ final class PhabricatorApplicationTransactionCommentView
|
|||
->addClass('phui-comment-fullwidth-control')
|
||||
->addClass('phui-comment-textarea-control')
|
||||
->setCanPin(true)
|
||||
->setPlaceholder($placeholder_text)
|
||||
->setName('comment');
|
||||
|
||||
$draft_comment = '';
|
||||
|
@ -331,7 +357,7 @@ final class PhabricatorApplicationTransactionCommentView
|
|||
}
|
||||
$remarkup_control->setRemarkupMetadata($draft_metadata);
|
||||
|
||||
if (!$this->getObjectPHID()) {
|
||||
if (!$this->getObject()->getPHID()) {
|
||||
throw new PhutilInvalidStateException('setObjectPHID', 'render');
|
||||
}
|
||||
|
||||
|
@ -345,7 +371,7 @@ final class PhabricatorApplicationTransactionCommentView
|
|||
->setFullWidth($this->fullWidth)
|
||||
->setMetadata(
|
||||
array(
|
||||
'objectPHID' => $this->getObjectPHID(),
|
||||
'objectPHID' => $this->getObject()->getPHID(),
|
||||
))
|
||||
->setAction($this->getAction())
|
||||
->setID($this->getFormID())
|
||||
|
|
Loading…
Reference in a new issue