diff --git a/core/modules/comment/comment.post_update.php b/core/modules/comment/comment.post_update.php index 04bf2db28d..8dba63d555 100644 --- a/core/modules/comment/comment.post_update.php +++ b/core/modules/comment/comment.post_update.php @@ -36,3 +36,31 @@ function comment_post_update_enable_comment_admin_view() { ->create($storage->read('views.view.comment')) ->save(); } + +/** + * Update the comment admin view. + */ +function comment_post_update_update_comment_admin_view() { + $module_handler = \Drupal::moduleHandler(); + + // Only update if the views module is enabled. + if (!$module_handler->moduleExists('views')) { + return; + } + $view_storage = \Drupal::entityTypeManager() + ->getStorage('view'); + + // Save the comment admin view to config. + $optional_install_path = $module_handler->getModule('comment')->getPath() . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY; + $storage = new FileStorage($optional_install_path); + $new_view = $view_storage + ->create($storage->read('views.view.comment')); + $uuid = NULL; + if ($view = $view_storage->load('comment')) { + // If we have an existing view then update that. + $new_view + ->set('uuid', $view->uuid()) + ->enforceIsNew(FALSE); + } + $new_view->save(); +} diff --git a/core/modules/comment/config/optional/views.view.comment.yml b/core/modules/comment/config/optional/views.view.comment.yml index e2f3dfd7df..c1d01b8b9e 100644 --- a/core/modules/comment/config/optional/views.view.comment.yml +++ b/core/modules/comment/config/optional/views.view.comment.yml @@ -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,169 @@ 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: combine + 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 + comment_type: + id: comment_type + table: comment_field_data + field: comment_type + relationship: none + group_type: group + admin_label: '' + operator: in + value: { } + group: 1 + exposed: true + expose: + operator_id: comment_type_op + label: 'Comment Type' + description: '' + use_operator: false + operator: comment_type_op + identifier: comment_type + 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: comment_type + plugin_id: bundle + 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 +869,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 +918,7 @@ display: contexts: - 'languages:language_content' - 'languages:language_interface' + - url - url.query_args - user.permissions cacheable: false @@ -733,6 +979,169 @@ 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: combine + 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 + comment_type: + id: comment_type + table: comment_field_data + field: comment_type + relationship: none + group_type: group + admin_label: '' + operator: in + value: { } + group: 1 + exposed: true + expose: + operator_id: comment_type_op + label: 'Comment Type' + description: '' + use_operator: false + operator: comment_type_op + identifier: comment_type + 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: comment_type + plugin_id: bundle + 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 @@ -1171,10 +1580,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 diff --git a/core/modules/comment/src/Tests/Update/CommentAdminViewUpdateTest.php b/core/modules/comment/src/Tests/Update/CommentAdminViewUpdateTest.php index 87f8f23a09..c094db47e8 100644 --- a/core/modules/comment/src/Tests/Update/CommentAdminViewUpdateTest.php +++ b/core/modules/comment/src/Tests/Update/CommentAdminViewUpdateTest.php @@ -8,6 +8,7 @@ * Tests that comment admin view is enabled after update. * * @see comment_post_update_enable_comment_admin_view() + * @see comment_post_update_update_comment_admin_view() * * @group Update */ @@ -46,6 +47,13 @@ public function testCommentAdminPostUpdateHook() { $this->drupalLogin($account); $this->drupalGet('admin/content/comment'); $this->assertText(t('No comments available.')); + + // Assert the expose filters on the admin page. + $this->assertField('subject'); + $this->assertField('combine'); + $this->assertField('comment_type'); + $this->assertField('langcode'); + } } diff --git a/core/modules/comment/src/Tests/Views/CommentAdminTest.php b/core/modules/comment/src/Tests/Views/CommentAdminTest.php index 925c837562..2c47a7b751 100644 --- a/core/modules/comment/src/Tests/Views/CommentAdminTest.php +++ b/core/modules/comment/src/Tests/Views/CommentAdminTest.php @@ -50,6 +50,12 @@ 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('combine'); + $this->assertField('comment_type'); + $this->assertField('langcode'); + $this->drupalLogout(); // Post anonymous comment without contact info. @@ -98,6 +104,13 @@ 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('combine'); + $this->assertField('comment_type'); + $this->assertField('langcode'); + $edit = [ "action" => 'comment_publish_action', "comment_bulk_form[1]" => $comments[0]->id(),