Unverified Commit 49e28971 authored by larowlan's avatar larowlan
Browse files

Issue #3214487 by paulocs, vakulrai, vetal4ik, manojithape, nishantghetiya,...

Issue #3214487 by paulocs, vakulrai, vetal4ik, manojithape, nishantghetiya, quietone, Lendude: Remove 'reply' link from comment field when threading is disabled

(cherry picked from commit 1926ec30)
parent 0ed1656d
......@@ -181,7 +181,9 @@ protected function buildLinks(CommentInterface $entity, EntityInterface $comment
'url' => $entity->toUrl('edit-form'),
];
}
if ($entity->access('create')) {
$field_definition = $commented_entity->getFieldDefinition($entity->getFieldName());
if ($entity->access('create')
&& $field_definition->getSetting('default_mode') === CommentManagerInterface::COMMENT_MODE_THREADED) {
$links['comment-reply'] = [
'title' => t('Reply'),
'url' => Url::fromRoute('comment.reply', [
......
......@@ -5,6 +5,7 @@
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\comment\CommentInterface;
use Drupal\comment\CommentManagerInterface;
use Drupal\user\RoleInterface;
use Drupal\comment\Entity\Comment;
......@@ -76,6 +77,16 @@ public function testCommentLinks() {
$comment->save();
$this->comment = $comment;
// Tests that reply link is not visible when threading is disabled.
$this->drupalLogin($this->webUser);
$this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT, 'Comment paging changed.');
$this->drupalGet('node/' . $this->node->id());
$this->assertSession()->linkNotExists('Reply');
// Tests that reply link is visible when threading is enabled.
$this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.');
$this->drupalGet('node/' . $this->node->id());
$this->assertSession()->linkExists('Reply');
// Change comment settings.
$this->setCommentSettings('form_location', CommentItemInterface::FORM_BELOW, 'Set comment form location');
$this->setCommentAnonymous(TRUE);
......
......@@ -542,8 +542,8 @@ public function testForumWithNewPost() {
$this->submitForm($edit, 'Save');
$this->assertSession()->statusCodeEquals(200);
// Test replying to a comment.
$this->clickLink('Reply');
// Test adding a new comment.
$this->clickLink('Add new comment');
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->fieldExists('comment_body[0][value]');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment