Commit 620cc4c7 authored by xjm's avatar xjm

Issue #2898344 by jibran, xjm, Lendude, dawehner, andypost, mradcliffe,...

Issue #2898344 by jibran, xjm, Lendude, dawehner, andypost, mradcliffe, larowlan, annajl, Bojhan: Add filters to the comments administration pages
parent fdef8555
......@@ -177,7 +177,7 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: true
action_title: 'Update Options'
action_title: Action
include_exclude: include
selected_actions:
- comment_delete_action
......@@ -561,6 +561,71 @@ display:
destination: true
entity_type: comment
plugin_id: entity_operations
name_1:
id: name_1
table: users_field_data
field: name
relationship: uid
group_type: group
admin_label: ''
label: ''
exclude: true
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: user_name
settings:
link_to_entity: true
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
entity_type: user
entity_field: name
plugin_id: field
filters:
status:
id: status
......@@ -600,6 +665,128 @@ display:
entity_type: comment
entity_field: status
plugin_id: boolean
subject:
id: subject
table: comment_field_data
field: subject
relationship: none
group_type: group
admin_label: ''
operator: contains
value: ''
group: 1
exposed: true
expose:
operator_id: subject_op
label: Subject
description: ''
use_operator: false
operator: subject_op
identifier: subject
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
anonymous: '0'
administrator: '0'
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
entity_type: comment
entity_field: subject
plugin_id: string
combine:
id: combine
table: views
field: combine
relationship: none
group_type: group
admin_label: ''
operator: contains
value: ''
group: 1
exposed: true
expose:
operator_id: combine_op
label: 'Author name'
description: ''
use_operator: false
operator: combine_op
identifier: author_name
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
anonymous: '0'
administrator: '0'
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
fields:
name: name
name_1: name_1
plugin_id: combine
langcode:
id: langcode
table: comment_field_data
field: langcode
relationship: none
group_type: group
admin_label: ''
operator: in
value: { }
group: 1
exposed: true
expose:
operator_id: langcode_op
label: Language
description: ''
use_operator: false
operator: langcode_op
identifier: langcode
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
anonymous: '0'
administrator: '0'
reduce: false
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
entity_type: comment
entity_field: langcode
plugin_id: language
sorts:
changed:
id: changed
......@@ -641,10 +828,27 @@ display:
show_admin_links: true
group_by: false
css_class: ''
relationships:
uid:
id: uid
table: comment_field_data
field: uid
relationship: none
group_type: group
admin_label: author
required: false
entity_type: comment
entity_field: uid
plugin_id: standard
filter_groups:
operator: AND
groups:
1: AND
cache_metadata:
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- url.query_args
- user.permissions
cacheable: false
......@@ -673,6 +877,7 @@ display:
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- url.query_args
- user.permissions
cacheable: false
......@@ -733,6 +938,128 @@ display:
entity_type: comment
entity_field: status
plugin_id: boolean
subject:
id: subject
table: comment_field_data
field: subject
relationship: none
group_type: group
admin_label: ''
operator: contains
value: ''
group: 1
exposed: true
expose:
operator_id: subject_op
label: Subject
description: ''
use_operator: false
operator: subject_op
identifier: subject
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
anonymous: '0'
administrator: '0'
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
entity_type: comment
entity_field: subject
plugin_id: string
combine:
id: combine
table: views
field: combine
relationship: none
group_type: group
admin_label: ''
operator: contains
value: ''
group: 1
exposed: true
expose:
operator_id: combine_op
label: 'Author Name'
description: ''
use_operator: false
operator: combine_op
identifier: author_name
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
anonymous: '0'
administrator: '0'
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
fields:
name: name
name_1: name_1
plugin_id: combine
langcode:
id: langcode
table: comment_field_data
field: langcode
relationship: none
group_type: group
admin_label: ''
operator: in
value: { }
group: 1
exposed: true
expose:
operator_id: langcode_op
label: Language
description: ''
use_operator: false
operator: langcode_op
identifier: langcode
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
anonymous: '0'
administrator: '0'
reduce: false
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
entity_type: comment
entity_field: langcode
plugin_id: language
defaults:
filters: false
filter_groups: false
......@@ -787,7 +1114,7 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: true
action_title: 'Update Options'
action_title: Action
include_exclude: include
selected_actions:
- comment_delete_action
......@@ -1171,10 +1498,80 @@ display:
destination: true
entity_type: comment
plugin_id: entity_operations
name_1:
id: name_1
table: users_field_data
field: name
relationship: uid
group_type: group
admin_label: ''
label: ''
exclude: true
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: user_name
settings:
link_to_entity: false
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
entity_type: user
entity_field: name
plugin_id: field
filter_groups:
operator: AND
groups:
1: AND
cache_metadata:
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- url.query_args
- user.permissions
cacheable: false
......
......@@ -50,6 +50,11 @@ public function testApprovalAdminInterface() {
$this->drupalGet('admin/content/comment');
$this->assertText(t('No comments available.'));
// Assert the expose filters on the admin page.
$this->assertField('subject');
$this->assertField('author_name');
$this->assertField('langcode');
$this->drupalLogout();
// Post anonymous comment without contact info.
......@@ -98,6 +103,12 @@ public function testApprovalAdminInterface() {
$this->drupalLogin($this->adminUser);
$this->drupalGet('admin/content/comment/approval');
$this->assertText(t('Unapproved comments (@count)', ['@count' => 2]), 'Two unapproved comments waiting for approval.');
// Assert the expose filters on the admin page.
$this->assertField('subject');
$this->assertField('author_name');
$this->assertField('langcode');
$edit = [
"action" => 'comment_publish_action',
"comment_bulk_form[1]" => $comments[0]->id(),
......
<?php
namespace Drupal\Tests\comment\Kernel\Views;
use Drupal\comment\Entity\Comment;
use Drupal\comment\Entity\CommentType;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\user\Entity\Role;
use Drupal\user\Entity\User;
use Drupal\views\Views;
/**
* Tests comment admin view filters.
*
* @group comment
*/
class CommentAdminViewTest extends ViewsKernelTestBase {
/**
* Comments.
*
* @var \Drupal\comment\Entity\Comment[]
*/
protected $comments = [];
/**
* Admin user.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
/**
* {@inheritdoc}
*/
public static $modules = [
'user',
'comment',
'entity_test',
'language',
'locale',
];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
$this->installEntitySchema('user');
$this->installEntitySchema('comment');
$this->installEntitySchema('entity_test');
// Create the anonymous role.
$this->installConfig(['user']);
// Enable another language.
ConfigurableLanguage::createFromLangcode('ur')->save();
// Rebuild the container to update the default language container variable.
$this->container->get('kernel')->rebuildContainer();
// Create an anonymous user.
$storage = \Drupal::entityTypeManager()->getStorage('user');
// Insert a row for the anonymous user.
$storage
->create([
'uid' => 0,
'name' => '',
'status' => 0,
])
->save();
// Created admin role.
$admin_role = Role::create([
'id' => 'admin',
'permissions' => ['administer comments'],
]);
$admin_role->save();
// Create the admin user.
$this->adminUser = User::create([
'name' => $this->randomMachineName(),
'roles' => [$admin_role->id()],
]);
$this->adminUser->save();
// Create a comment type.
CommentType::create([
'id' => 'comment',
'label' => 'Default comments',
'target_entity_type_id' => 'entity_test',
'description' => 'Default comment field',
])->save();
// Create a commented entity.
$entity = EntityTest::create();
$entity->name->value = $this->randomMachineName();
$entity->save();
// Create some comments.
$comment = Comment::create([
'subject' => 'My comment title',
'uid' => $this->adminUser->id(),
'entity_type' => 'entity_test',
'comment_type' => 'comment',
'status' => 1,
'entity_id' => $entity->id(),
]);
$comment->save();
$this->comments[] = $comment;
$comment_anonymous = Comment::create([
'subject' => 'Anonymous comment title',
'uid' => 0,
'name' => 'barry',
'mail' => 'test@example.com',
'homepage' => 'https://example.com',
'entity_type' => 'entity_test',