diff --git a/core/modules/comment/comment.views.inc b/core/modules/comment/comment.views.inc index f243b1b..e77d22c 100644 --- a/core/modules/comment/comment.views.inc +++ b/core/modules/comment/comment.views.inc @@ -247,15 +247,7 @@ function comment_views_data() { ), ); - // Define some fields based upon views_handler_field_entity in the entity - // table so they can be re-used with other query backends. - // @see views_handler_field_entity - - // Define the base group of this table. Fields that don't have a group defined - // will go into this field by default. - $data['views_entity_comment']['table']['group'] = t('Comments'); - - $data['views_entity_comment']['view_comment'] = array( + $data['comment']['view_comment'] = array( 'field' => array( 'title' => t('Link to comment'), 'help' => t('Provide a simple link to the comment.'), @@ -263,7 +255,7 @@ function comment_views_data() { ), ); - $data['views_entity_comment']['edit_comment'] = array( + $data['comment']['edit_comment'] = array( 'field' => array( 'title' => t('Link to edit comment'), 'help' => t('Provide a simple link to edit the comment.'), @@ -271,7 +263,7 @@ function comment_views_data() { ), ); - $data['views_entity_comment']['delete_comment'] = array( + $data['comment']['delete_comment'] = array( 'field' => array( 'title' => t('Link to delete comment'), 'help' => t('Provide a simple link to delete the comment.'), @@ -279,7 +271,7 @@ function comment_views_data() { ), ); - $data['views_entity_comment']['approve_comment'] = array( + $data['comment']['approve_comment'] = array( 'field' => array( 'title' => t('Link to approve comment'), 'help' => t('Provide a simple link to approve the comment.'), @@ -287,7 +279,7 @@ function comment_views_data() { ), ); - $data['views_entity_comment']['replyto_comment'] = array( + $data['comment']['replyto_comment'] = array( 'field' => array( 'title' => t('Link to reply-to comment'), 'help' => t('Provide a simple link to reply to the comment.'), diff --git a/core/modules/comment/config/views.view.comments.yml b/core/modules/comment/config/views.view.comments.yml index ed1e17d..c5c57cd 100644 --- a/core/modules/comment/config/views.view.comments.yml +++ b/core/modules/comment/config/views.view.comments.yml @@ -4,157 +4,65 @@ core: 8.x description: 'Find and manage comments.' status: '1' display: - default: - display_plugin: default - id: default - display_title: Master + page_1: + display_plugin: page + id: page_1 + display_title: Comments position: '' display_options: - access: - type: perm - options: - perm: 'administer comments' - cache: - type: none - options: { } - query: - type: views_query - options: - disable_sql_rewrite: '0' - distinct: '0' - slave: '0' - query_comment: '' - query_tags: { } - exposed_form: - type: basic - options: - submit_button: Apply - reset_button: '0' - reset_button_label: Reset - exposed_sorts_label: 'Sort by' - expose_sort_order: '1' - sort_asc_label: Asc - sort_desc_label: Desc - pager: - type: full - options: - items_per_page: '50' - offset: '0' - id: '0' - total_pages: '' - expose: - items_per_page: '0' - items_per_page_label: 'Items per page' - items_per_page_options: '5, 10, 20, 40, 60' - items_per_page_options_all: '0' - items_per_page_options_all_label: '- All -' - offset: '0' - offset_label: Offset - tags: - previous: '‹ previous' - next: 'next ›' - first: '« first' - last: 'last »' - quantity: '9' - style: - type: table - options: - grouping: { } - row_class: '' - default_row_class: '1' - row_class_special: '1' - override: '1' - sticky: '0' - caption: '' - summary: '' - description: '' - columns: - action_bulk_form: action_bulk_form - subject: subject - name: name - title: title - changed: changed - approve_comment: approve_comment - edit_comment: edit_comment - delete_comment: delete_comment - dropbutton: dropbutton - info: - action_bulk_form: - sortable: '0' - default_sort_order: asc - align: '' - separator: '' - empty_column: '1' - responsive: '' - subject: - sortable: '1' - default_sort_order: asc - align: '' - separator: '' - empty_column: '0' - responsive: '' - name: - sortable: '1' - default_sort_order: asc - align: '' - separator: '' - empty_column: '0' - responsive: '' - title: - sortable: '1' - default_sort_order: asc - align: '' - separator: '' - empty_column: '0' - responsive: '' - changed: - sortable: '1' - default_sort_order: desc - align: '' - separator: '' - empty_column: '0' - responsive: '' - approve_comment: - sortable: '0' - default_sort_order: asc - align: '' - separator: '' - empty_column: '0' - responsive: '' - edit_comment: - sortable: '0' - default_sort_order: asc - align: '' - separator: '' - empty_column: '0' - responsive: '' - delete_comment: - sortable: '0' - default_sort_order: asc - align: '' - separator: '' - empty_column: '0' - responsive: '' - dropbutton: - sortable: '0' - default_sort_order: asc - align: '' - separator: '' - empty_column: '0' - responsive: '' - default: changed - empty_table: '1' - row: - type: fields - relationships: - nid: - id: nid + path: admin/content/comment + menu: + type: tab + title: Comments + description: 'Comments published' + name: admin + weight: '0' + context: '0' + display_description: '' + filters: + status: + id: status table: comment - field: nid - required: '1' + field: status relationship: none group_type: group - admin_label: Content + admin_label: '' + operator: '=' + value: '1' + group: '1' + exposed: '0' + expose: + operator_id: '0' + label: '' + description: '' + use_operator: '0' + operator: '0' + identifier: '' + required: '0' + remember: '0' + multiple: '0' + remember_roles: + authenticated: authenticated + is_grouped: '0' + group_info: + label: '' + description: '' + identifier: '' + optional: '1' + widget: select + multiple: '0' + remember: '0' + default_group: All + default_group_multiple: { } + group_items: { } + defaults: + filters: '0' + filter_groups: '0' + fields: '0' + filter_groups: + operator: AND + groups: + 1: AND fields: action_bulk_form: id: action_bulk_form @@ -165,7 +73,6 @@ display: admin_label: '' label: 'Bulk update' exclude: '0' - optional: '1' alter: alter_text: '0' text: '' @@ -207,6 +114,7 @@ display: hide_alter_empty: '1' include_exclude: include selected_actions: + comment_delete_action: comment_delete_action comment_unpublish_action: comment_unpublish_action plugin_id: action_bulk_form subject: @@ -316,8 +224,162 @@ display: relationship: nid group_type: group admin_label: '' - label: 'Posted in' - exclude: '0' + label: 'Posted in' + exclude: '0' + alter: + alter_text: '0' + text: '' + make_link: '0' + path: '' + absolute: '0' + external: '0' + replace_spaces: '0' + path_case: none + trim_whitespace: '0' + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: '0' + max_length: '' + word_boundary: '1' + ellipsis: '1' + more_link: '0' + more_link_text: '' + more_link_path: '' + strip_tags: '0' + trim: '0' + preserve_tags: '' + html: '0' + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: '1' + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: '1' + empty: '' + hide_empty: '0' + empty_zero: '0' + hide_alter_empty: '1' + link_to_node: '1' + plugin_id: node + changed: + id: changed + table: comment + field: changed + relationship: none + group_type: group + admin_label: '' + label: Updated + exclude: '0' + alter: + alter_text: '0' + text: '' + make_link: '0' + path: '' + absolute: '0' + external: '0' + replace_spaces: '0' + path_case: none + trim_whitespace: '0' + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: '0' + max_length: '' + word_boundary: '1' + ellipsis: '1' + more_link: '0' + more_link_text: '' + more_link_path: '' + strip_tags: '0' + trim: '0' + preserve_tags: '' + html: '0' + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: '1' + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: '1' + empty: '' + hide_empty: '0' + empty_zero: '0' + hide_alter_empty: '1' + date_format: short + custom_date_format: '' + timezone: '' + plugin_id: date + edit_comment: + id: edit_comment + table: comment + field: edit_comment + relationship: none + group_type: group + admin_label: '' + label: '' + exclude: '1' + alter: + alter_text: '0' + text: '' + make_link: '0' + path: '' + absolute: '0' + external: '0' + replace_spaces: '0' + path_case: none + trim_whitespace: '0' + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: '0' + max_length: '' + word_boundary: '1' + ellipsis: '1' + more_link: '0' + more_link_text: '' + more_link_path: '' + strip_tags: '0' + trim: '0' + preserve_tags: '' + html: '0' + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: '0' + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: '1' + empty: '' + hide_empty: '0' + empty_zero: '0' + hide_alter_empty: '1' + text: Edit + link_to_node: '0' + destination: '0' + plugin_id: comment_link_edit + delete_comment: + id: delete_comment + table: comment + field: delete_comment + relationship: none + group_type: group + admin_label: '' + label: '' + exclude: '1' alter: alter_text: '0' text: '' @@ -349,7 +411,7 @@ display: element_class: '' element_label_type: '' element_label_class: '' - element_label_colon: '1' + element_label_colon: '0' element_wrapper_type: '' element_wrapper_class: '' element_default_classes: '1' @@ -357,16 +419,17 @@ display: hide_empty: '0' empty_zero: '0' hide_alter_empty: '1' - link_to_node: '1' - plugin_id: node - changed: - id: changed - table: comment - field: changed + text: Delete + link_to_node: '0' + plugin_id: comment_link_delete + dropbutton: + id: dropbutton + table: views + field: dropbutton relationship: none group_type: group admin_label: '' - label: Updated + label: Operations exclude: '0' alter: alter_text: '0' @@ -399,7 +462,7 @@ display: element_class: '' element_label_type: '' element_label_class: '' - element_label_colon: '1' + element_label_colon: '0' element_wrapper_type: '' element_wrapper_class: '' element_default_classes: '1' @@ -407,75 +470,16 @@ display: hide_empty: '0' empty_zero: '0' hide_alter_empty: '1' - date_format: short - custom_date_format: '' - timezone: '' - plugin_id: date - filters: - status: - id: status - table: comment - field: status - relationship: none - group_type: group - admin_label: '' - operator: '=' - value: '1' - group: '1' - exposed: '0' - expose: - operator_id: '0' - label: '' - description: '' - use_operator: '0' - operator: '0' - identifier: '' - required: '0' - remember: '0' - multiple: '0' - remember_roles: - authenticated: authenticated - is_grouped: '0' - group_info: - label: '' - description: '' - identifier: '' - optional: '1' - widget: select - multiple: '0' - remember: '0' - default_group: All - default_group_multiple: { } - group_items: { } - sorts: - created: - id: created - table: comment - field: created - order: DESC - relationship: none - group_type: group - admin_label: '' - exposed: '0' - expose: - label: '' - granularity: second - title: Comments - header: { } - footer: { } - empty: - area_text_custom: - id: area_text_custom - table: views - field: area_text_custom - relationship: none - group_type: group - admin_label: '' - empty: '1' - tokenize: '0' - content: '' - plugin_id: text_custom - arguments: { } + fields: + edit_comment: edit_comment + delete_comment: delete_comment + action_bulk_form: '0' + subject: '0' + name: '0' + title: '0' + changed: '0' + destination: '1' + plugin_id: dropbutton page_2: display_plugin: page id: page_2 @@ -545,7 +549,6 @@ display: admin_label: '' label: 'Bulk update' exclude: '0' - optional: '1' alter: alter_text: '0' text: '' @@ -794,7 +797,7 @@ display: plugin_id: date approve_comment: id: approve_comment - table: views_entity_comment + table: comment field: approve_comment relationship: none group_type: group @@ -845,7 +848,7 @@ display: plugin_id: comment_link_approve edit_comment: id: edit_comment - table: views_entity_comment + table: comment field: edit_comment relationship: none group_type: group @@ -897,7 +900,7 @@ display: plugin_id: comment_link_edit delete_comment: id: delete_comment - table: views_entity_comment + table: comment field: delete_comment relationship: none group_type: group @@ -1005,65 +1008,157 @@ display: changed: '0' destination: '1' plugin_id: dropbutton - page_1: - display_plugin: page - id: page_1 - display_title: Comments + default: + display_plugin: default + id: default + display_title: Master position: '' display_options: - path: admin/content/comment - menu: - type: tab - title: Comments - description: 'Comments published' - name: admin - weight: '0' - context: '0' - display_description: '' - filters: - status: - id: status + access: + type: perm + options: + perm: 'administer comments' + cache: + type: none + options: { } + query: + type: views_query + options: + disable_sql_rewrite: '0' + distinct: '0' + slave: '0' + query_comment: '' + query_tags: { } + exposed_form: + type: basic + options: + submit_button: Apply + reset_button: '0' + reset_button_label: Reset + exposed_sorts_label: 'Sort by' + expose_sort_order: '1' + sort_asc_label: Asc + sort_desc_label: Desc + pager: + type: full + options: + items_per_page: '50' + offset: '0' + id: '0' + total_pages: '' + expose: + items_per_page: '0' + items_per_page_label: 'Items per page' + items_per_page_options: '5, 10, 20, 40, 60' + items_per_page_options_all: '0' + items_per_page_options_all_label: '- All -' + offset: '0' + offset_label: Offset + tags: + previous: '‹ previous' + next: 'next ›' + first: '« first' + last: 'last »' + quantity: '9' + style: + type: table + options: + grouping: { } + row_class: '' + default_row_class: '1' + row_class_special: '1' + override: '1' + sticky: '0' + caption: '' + summary: '' + description: '' + columns: + action_bulk_form: action_bulk_form + subject: subject + name: name + title: title + changed: changed + approve_comment: approve_comment + edit_comment: edit_comment + delete_comment: delete_comment + dropbutton: dropbutton + info: + action_bulk_form: + sortable: '0' + default_sort_order: asc + align: '' + separator: '' + empty_column: '1' + responsive: '' + subject: + sortable: '1' + default_sort_order: asc + align: '' + separator: '' + empty_column: '0' + responsive: '' + name: + sortable: '1' + default_sort_order: asc + align: '' + separator: '' + empty_column: '0' + responsive: '' + title: + sortable: '1' + default_sort_order: asc + align: '' + separator: '' + empty_column: '0' + responsive: '' + changed: + sortable: '1' + default_sort_order: desc + align: '' + separator: '' + empty_column: '0' + responsive: '' + approve_comment: + sortable: '0' + default_sort_order: asc + align: '' + separator: '' + empty_column: '0' + responsive: '' + edit_comment: + sortable: '0' + default_sort_order: asc + align: '' + separator: '' + empty_column: '0' + responsive: '' + delete_comment: + sortable: '0' + default_sort_order: asc + align: '' + separator: '' + empty_column: '0' + responsive: '' + dropbutton: + sortable: '0' + default_sort_order: asc + align: '' + separator: '' + empty_column: '0' + responsive: '' + default: changed + empty_table: '1' + row: + type: fields + relationships: + nid: + id: nid table: comment - field: status + field: nid + required: '1' relationship: none group_type: group - admin_label: '' - operator: '=' - value: '1' - group: '1' - exposed: '0' - expose: - operator_id: '0' - label: '' - description: '' - use_operator: '0' - operator: '0' - identifier: '' - required: '0' - remember: '0' - multiple: '0' - remember_roles: - authenticated: authenticated - is_grouped: '0' - group_info: - label: '' - description: '' - identifier: '' - optional: '1' - widget: select - multiple: '0' - remember: '0' - default_group: All - default_group_multiple: { } - group_items: { } - defaults: - filters: '0' - filter_groups: '0' - fields: '0' - filter_groups: - operator: AND - groups: - 1: AND + admin_label: Content fields: action_bulk_form: id: action_bulk_form @@ -1074,7 +1169,6 @@ display: admin_label: '' label: 'Bulk update' exclude: '0' - optional: '1' alter: alter_text: '0' text: '' @@ -1116,7 +1210,6 @@ display: hide_alter_empty: '1' include_exclude: include selected_actions: - comment_delete_action: comment_delete_action comment_unpublish_action: comment_unpublish_action plugin_id: action_bulk_form subject: @@ -1321,167 +1414,71 @@ display: custom_date_format: '' timezone: '' plugin_id: date - edit_comment: - id: edit_comment - table: views_entity_comment - field: edit_comment + filters: + status: + id: status + table: comment + field: status relationship: none group_type: group admin_label: '' - label: '' - exclude: '1' - alter: - alter_text: '0' - text: '' - make_link: '0' - path: '' - absolute: '0' - external: '0' - replace_spaces: '0' - path_case: none - trim_whitespace: '0' - alt: '' - rel: '' - link_class: '' - prefix: '' - suffix: '' - target: '' - nl2br: '0' - max_length: '' - word_boundary: '1' - ellipsis: '1' - more_link: '0' - more_link_text: '' - more_link_path: '' - strip_tags: '0' - trim: '0' - preserve_tags: '' - html: '0' - element_type: '' - element_class: '' - element_label_type: '' - element_label_class: '' - element_label_colon: '0' - element_wrapper_type: '' - element_wrapper_class: '' - element_default_classes: '1' - empty: '' - hide_empty: '0' - empty_zero: '0' - hide_alter_empty: '1' - text: Edit - link_to_node: '0' - destination: '0' - plugin_id: comment_link_edit - delete_comment: - id: delete_comment - table: views_entity_comment - field: delete_comment + operator: '=' + value: '1' + group: '1' + exposed: '0' + expose: + operator_id: '0' + label: '' + description: '' + use_operator: '0' + operator: '0' + identifier: '' + required: '0' + remember: '0' + multiple: '0' + remember_roles: + authenticated: authenticated + is_grouped: '0' + group_info: + label: '' + description: '' + identifier: '' + optional: '1' + widget: select + multiple: '0' + remember: '0' + default_group: All + default_group_multiple: { } + group_items: { } + sorts: + created: + id: created + table: comment + field: created + order: DESC relationship: none group_type: group admin_label: '' - label: '' - exclude: '1' - alter: - alter_text: '0' - text: '' - make_link: '0' - path: '' - absolute: '0' - external: '0' - replace_spaces: '0' - path_case: none - trim_whitespace: '0' - alt: '' - rel: '' - link_class: '' - prefix: '' - suffix: '' - target: '' - nl2br: '0' - max_length: '' - word_boundary: '1' - ellipsis: '1' - more_link: '0' - more_link_text: '' - more_link_path: '' - strip_tags: '0' - trim: '0' - preserve_tags: '' - html: '0' - element_type: '' - element_class: '' - element_label_type: '' - element_label_class: '' - element_label_colon: '0' - element_wrapper_type: '' - element_wrapper_class: '' - element_default_classes: '1' - empty: '' - hide_empty: '0' - empty_zero: '0' - hide_alter_empty: '1' - text: Delete - link_to_node: '0' - plugin_id: comment_link_delete - dropbutton: - id: dropbutton + exposed: '0' + expose: + label: '' + granularity: second + title: Comments + header: { } + footer: { } + empty: + area_text_custom: + id: area_text_custom table: views - field: dropbutton + field: area_text_custom relationship: none group_type: group admin_label: '' - label: Operations - exclude: '0' - alter: - alter_text: '0' - text: '' - make_link: '0' - path: '' - absolute: '0' - external: '0' - replace_spaces: '0' - path_case: none - trim_whitespace: '0' - alt: '' - rel: '' - link_class: '' - prefix: '' - suffix: '' - target: '' - nl2br: '0' - max_length: '' - word_boundary: '1' - ellipsis: '1' - more_link: '0' - more_link_text: '' - more_link_path: '' - strip_tags: '0' - trim: '0' - preserve_tags: '' - html: '0' - element_type: '' - element_class: '' - element_label_type: '' - element_label_class: '' - element_label_colon: '0' - element_wrapper_type: '' - element_wrapper_class: '' - element_default_classes: '1' - empty: '' - hide_empty: '0' - empty_zero: '0' - hide_alter_empty: '1' - fields: - edit_comment: edit_comment - delete_comment: delete_comment - action_bulk_form: '0' - subject: '0' - name: '0' - title: '0' - changed: '0' - destination: '1' - plugin_id: dropbutton + empty: '1' + tokenize: '0' + content: 'No comments available.' + plugin_id: text_custom + arguments: { } label: Comments module: views id: comments diff --git a/core/modules/comment/lib/Drupal/comment/Tests/Views/CommentAdminView.php b/core/modules/comment/lib/Drupal/comment/Tests/Views/CommentAdminView.php index 4158a09..d4aa11c 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/Views/CommentAdminView.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/Views/CommentAdminView.php @@ -31,6 +31,14 @@ class CommentAdminView extends ViewTestBase { protected $commentStorageController; /** + * Node to use as base for the comments of the test. + * + * @var \Drupal\node\NodeInterface + */ + protected $node; + + + /** * An array of comment ids. * * @var array @@ -51,16 +59,20 @@ protected function setUp() { $this->commentStorageController = $this->container->get('plugin.manager.entity')->getStorageController('comment'); // Create a node. - $node = $this->drupalCreateNode(); + $this->node = $this->drupalCreateNode(); + } - // Add several comments. + /** + * Add comments to the node. + */ + protected function createComments() { $this->comments = array(); for ($i = 0; $i < 20; $i++) { $status = ($i % 2 == 0) ? FALSE : TRUE; $comment = $this->commentStorageController->create(array( - 'nid' => $node->nid, - 'node_type' => 'node_type_' . $node->bundle(), - 'uid' => $node->uid, + 'nid' => $this->node->nid, + 'node_type' => 'node_type_' . $this->node->bundle(), + 'uid' => $this->node->uid, 'status' => $status, 'subject' => $this->randomName(), 'language' => Language::LANGCODE_NOT_SPECIFIED, @@ -76,6 +88,8 @@ protected function setUp() { * Tests the comment admin view. */ public function testCommentAdminView() { + // Create comments. + $this->createComments(); $view = views_get_view('comments'); $view->setDisplay('page_1'); $this->executeView($view); @@ -108,7 +122,11 @@ public function testCommentAdminScreen() { // Visit the comment page. $this->drupalGet('admin/content/comment'); $this->assertResponse(200); + $this->assertText('No comments available.', 'Empty text is displayed when there are no comments'); + // Re visit when the comments are created. + $this->createComments(); + $this->drupalGet('admin/content/comment'); // Check that the title and the links are present. $this->assertTitle('Comments | Drupal'); $this->assertLink('Published comments');