From 03de872802be78bde597ad1caeee2ca318c8e561 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Mon, 2 Nov 2015 15:17:52 +0000 Subject: [PATCH] Issue #2604618 by andypost, xjm: Views operations dropbuttons do not work with Comment because it does not specify a list builder --- core/modules/comment/comment.install | 17 ++ core/modules/comment/src/Entity/Comment.php | 1 + .../src/Tests/Views/CommentOperationsTest.php | 38 +++ .../views.view.test_comment_operations.yml | 254 ++++++++++++++++++ 4 files changed, 310 insertions(+) create mode 100644 core/modules/comment/src/Tests/Views/CommentOperationsTest.php create mode 100644 core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_comment_operations.yml diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install index 327feff349af..b67825e1d647 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -110,3 +110,20 @@ function comment_schema() { return $schema; } + +/** + * @addtogroup updates-8.0.0-rc + * @{ + */ + +/** + * Clear caches to fix Comment entity list builder and operations Views field. + */ +function comment_update_8001() { + // Empty update to cause a cache flush to rebuild comment entity handler + // information, so that comment operation links work. +} + +/** + * @} End of "addtogroup updates-8.0.0-rc". + */ diff --git a/core/modules/comment/src/Entity/Comment.php b/core/modules/comment/src/Entity/Comment.php index b20d9bb0d77e..e2ab3d81508c 100644 --- a/core/modules/comment/src/Entity/Comment.php +++ b/core/modules/comment/src/Entity/Comment.php @@ -30,6 +30,7 @@ * "storage" = "Drupal\comment\CommentStorage", * "storage_schema" = "Drupal\comment\CommentStorageSchema", * "access" = "Drupal\comment\CommentAccessControlHandler", + * "list_builder" = "Drupal\Core\Entity\EntityListBuilder", * "view_builder" = "Drupal\comment\CommentViewBuilder", * "views_data" = "Drupal\comment\CommentViewsData", * "form" = { diff --git a/core/modules/comment/src/Tests/Views/CommentOperationsTest.php b/core/modules/comment/src/Tests/Views/CommentOperationsTest.php new file mode 100644 index 000000000000..0d928f1739cb --- /dev/null +++ b/core/modules/comment/src/Tests/Views/CommentOperationsTest.php @@ -0,0 +1,38 @@ +<?php + +/** + * @file + * Contains \Drupal\comment\Tests\Views\CommentOperationsTest. + */ + +namespace Drupal\comment\Tests\Views; + +/** + * Tests comment operations. + * + * @group comment + */ +class CommentOperationsTest extends CommentTestBase { + + /** + * Views used by this test. + * + * @var array + */ + public static $testViews = ['test_comment_operations']; + + /** + * Test the operations field plugin. + */ + public function testCommentOperations() { + $admin_account = $this->drupalCreateUser(['administer comments']); + $this->drupalLogin($admin_account); + $this->drupalGet('test-comment-operations'); + $this->assertResponse(200); + $operation = $this->cssSelect('.views-field-operations li.edit a'); + $this->assertEqual(count($operation), 1, 'Found edit operation for comment.'); + $operation = $this->cssSelect('.views-field-operations li.delete a'); + $this->assertEqual(count($operation), 1, 'Found delete operation for comment.'); + } + +} diff --git a/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_comment_operations.yml b/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_comment_operations.yml new file mode 100644 index 000000000000..2537700cd400 --- /dev/null +++ b/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_comment_operations.yml @@ -0,0 +1,254 @@ +langcode: en +status: true +dependencies: + module: + - comment + - user +id: test_comment_operations +label: test_comment_operations +module: views +description: '' +tag: '' +base_table: comment_field_data +base_field: cid +core: 8.x +display: + default: + display_plugin: default + id: default + display_title: Master + position: 0 + display_options: + access: + type: perm + options: + perm: 'administer comments' + cache: + type: tag + options: { } + query: + type: views_query + options: + disable_sql_rewrite: false + distinct: false + replica: false + query_comment: '' + query_tags: { } + exposed_form: + type: basic + options: + submit_button: Apply + reset_button: false + reset_button_label: Reset + exposed_sorts_label: 'Sort by' + expose_sort_order: true + sort_asc_label: Asc + sort_desc_label: Desc + pager: + type: full + options: + items_per_page: 10 + offset: 0 + id: 0 + total_pages: null + expose: + items_per_page: false + items_per_page_label: 'Items per page' + items_per_page_options: '5, 10, 25, 50' + items_per_page_options_all: false + items_per_page_options_all_label: '- All -' + offset: false + offset_label: Offset + tags: + previous: '‹ Previous' + next: 'Next ›' + first: '« First' + last: 'Last »' + quantity: 9 + style: + type: table + options: + grouping: { } + row_class: '' + default_row_class: true + override: true + sticky: false + caption: '' + summary: '' + description: '' + columns: + subject: subject + operations: operations + info: + subject: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + operations: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + default: '-1' + empty_table: false + row: + type: fields + options: + inline: { } + separator: '' + hide_empty: false + default_field_elements: true + relationships: { } + fields: + subject: + id: subject + table: comment_field_data + field: subject + relationship: none + group_type: group + admin_label: '' + label: Subject + exclude: false + 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: false + ellipsis: false + 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: true + 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: string + 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: comment + entity_field: subject + plugin_id: field + operations: + id: operations + table: comment + field: operations + relationship: none + group_type: group + admin_label: '' + label: Operations + exclude: false + 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 + destination: true + entity_type: comment + plugin_id: entity_operations + filters: { } + sorts: { } + header: { } + footer: { } + empty: { } + arguments: { } + display_extenders: { } + cache_metadata: + max-age: 0 + contexts: + - 'languages:language_content' + - 'languages:language_interface' + - url.query_args + - user.permissions + tags: { } + page_1: + display_plugin: page + id: page_1 + display_title: Page + position: 1 + display_options: + display_extenders: { } + path: test-comment-operations + cache_metadata: + max-age: 0 + contexts: + - 'languages:language_content' + - 'languages:language_interface' + - url.query_args + - user.permissions + tags: { } -- GitLab