diff --git a/modules/collabora_online_group/config/override/views.view.group_media.yml b/modules/collabora_online_group/config/override/views.view.group_media.yml index 4082e523..0db5c082 100644 --- a/modules/collabora_online_group/config/override/views.view.group_media.yml +++ b/modules/collabora_online_group/config/override/views.view.group_media.yml @@ -369,263 +369,6 @@ display: empty_zero: false hide_alter_empty: true text: 'Edit in Collabora' - view_group_content: - id: view_group_content - table: group_relationship - field: view_group_content - relationship: group_content - group_type: group - admin_label: '' - entity_type: group_content - plugin_id: entity_link - label: 'View relation link' - 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: true - element_wrapper_type: '' - element_wrapper_class: '' - element_default_classes: true - empty: '' - hide_empty: false - empty_zero: false - hide_alter_empty: true - text: 'View relation' - output_url_as_text: false - absolute: false - edit_group_content: - id: edit_group_content - table: group_relationship - field: edit_group_content - relationship: group_content - group_type: group - admin_label: '' - entity_type: group_content - plugin_id: entity_link_edit - label: 'Edit relation link' - 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: true - element_wrapper_type: '' - element_wrapper_class: '' - element_default_classes: true - empty: '' - hide_empty: false - empty_zero: false - hide_alter_empty: true - text: 'Edit relation' - delete_group_content: - id: delete_group_content - table: group_relationship - field: delete_group_content - relationship: group_content - group_type: group - admin_label: '' - entity_type: group_content - plugin_id: entity_link_delete - label: 'Delete relation link' - 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: true - element_wrapper_type: '' - element_wrapper_class: '' - element_default_classes: true - empty: '' - hide_empty: false - empty_zero: false - hide_alter_empty: true - text: 'Delete relation' - edit_media: - id: edit_media - table: media - field: edit_media - relationship: none - group_type: group - admin_label: '' - entity_type: media - plugin_id: entity_link_edit - label: 'Edit media' - 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: true - element_wrapper_type: '' - element_wrapper_class: '' - element_default_classes: true - empty: '' - hide_empty: false - empty_zero: false - hide_alter_empty: true - text: Edit - delete_media: - id: delete_media - table: media - field: delete_media - relationship: none - group_type: group - admin_label: '' - entity_type: media - plugin_id: entity_link_delete - label: 'Delete Media' - 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: true - element_wrapper_type: '' - element_wrapper_class: '' - element_default_classes: true - empty: '' - hide_empty: false - empty_zero: false - hide_alter_empty: true - text: Delete dropbutton: id: dropbutton table: views @@ -634,7 +377,7 @@ display: group_type: group admin_label: '' plugin_id: dropbutton - label: Dropbutton + label: Operations exclude: false alter: alter_text: false @@ -679,14 +422,15 @@ display: fields: collabora_preview: collabora_preview collabora_edit: collabora_edit - view_group_content: view_group_content - edit_group_content: edit_group_content - delete_group_content: delete_group_content edit_media: edit_media delete_media: delete_media + edit_group_relationship: edit_group_relationship + delete_group_relationship: delete_group_relationship + view_group_relationship: view_group_relationship name: '0' bundle: '0' status: '0' + uid: '0' pager: type: mini options: @@ -729,10 +473,10 @@ display: id: gid table: group_relationship_field_data field: gid - relationship: group_content + relationship: group_relationship group_type: group admin_label: '' - entity_type: group_content + entity_type: group_relationship entity_field: gid plugin_id: group_id default_action: ignore @@ -956,19 +700,19 @@ display: replica: false query_tags: {} relationships: - group_content: - id: group_content + group_relationship: + id: group_relationship table: media_field_data - field: group_content + field: group_relationship relationship: none group_type: group - admin_label: 'Media group content' + admin_label: 'Media group relationship' entity_type: media - plugin_id: group_content_to_entity_reverse + plugin_id: group_relationship_to_entity_reverse required: false - group_content_plugins: + group_relation_plugins: 'group_media:audio': '0' - 'group_media:file': '0' + 'group_media:document': '0' 'group_media:image': '0' 'group_media:remote_video': '0' 'group_media:video': '0' diff --git a/modules/collabora_online_group/tests/src/Functional/InstallationTest.php b/modules/collabora_online_group/tests/src/Functional/InstallationTest.php deleted file mode 100644 index b5dce8f2..00000000 --- a/modules/collabora_online_group/tests/src/Functional/InstallationTest.php +++ /dev/null @@ -1,35 +0,0 @@ -drupalGet(''); - $this->assertSession()->statusCodeEquals(200); - } - -} diff --git a/modules/collabora_online_group/tests/src/Functional/ViewTest.php b/modules/collabora_online_group/tests/src/Functional/ViewTest.php new file mode 100644 index 00000000..78873c78 --- /dev/null +++ b/modules/collabora_online_group/tests/src/Functional/ViewTest.php @@ -0,0 +1,175 @@ +createGroupType(['id' => 'group_type_1']); + $media_type = $this->createMediaType('file', ['id' => 'document']); + $this->createGroupRole([ + 'group_type' => 'group_type_1', + 'scope' => PermissionScopeInterface::INSIDER_ID, + 'global_role' => RoleInterface::AUTHENTICATED_ID, + 'permissions' => [ + 'view group', + 'access group_media overview', + 'view group_media:document entity', + 'edit any group_media:document in collabora', + 'preview group_media:document in collabora', + ], + ]); + $this->createPluginRelation($group_type, 'group_media:document', [ + 'group_cardinality' => 0, + 'entity_cardinality' => 1, + 'use_creation_wizard' => FALSE, + ]); + + // Create content. + $group = $this->createGroup(['type' => 'group_type_1']); + for ($i = 1;$i < 4;$i++) { + $media = $this->createMediaEntity('document', [ + 'id' => 'media_' . $i, + 'name' => 'Media ' . $i, + ]); + $group->addRelationship($media, 'group_media:document'); + } + $user = $this->createUser([ + 'view the administration theme', + 'access administration pages', + 'access group overview', + ]); + $group->addMember($user); + + // Go to the page and check the links added to the view. + $this->drupalLogin($user); + $this->drupalGet("group/{$group->id()}/media"); + $assert_session = $this->assertSession(); + + // Check table header. + $table = $assert_session->elementExists('css', 'table'); + $table_header = $assert_session->elementExists('css', 'thead', $table); + $rows = $table_header->findAll('css', 'tr'); + $cols = $rows[0]->findAll('css', 'th'); + $this->assertEquals('Media name', $cols[0]->getText()); + $this->assertEquals('Bundle', $cols[1]->getText()); + $this->assertEquals('Status', $cols[2]->getText()); + $this->assertEquals('Publisher', $cols[3]->getText()); + $this->assertEquals('Operations', $cols[4]->getText()); + + // Check that rows contain new links for operations in Collabora. + $table_body = $assert_session->elementExists('css', 'tbody', $table); + $rows = $table_body->findAll('css', 'tr'); + $i = 0; + foreach(Media::loadMultiple() as $media) { + $cols = $rows[$i]->findAll('css', 'td'); + $this->assertEquals($media->getName(), $cols[0]->getText()); + $this->assertEquals($media_type->label(), $cols[1]->getText()); + $this->assertEquals('Yes', $cols[2]->getText()); + $this->assertEquals('Anonymous', $cols[3]->getText()); + $operation_links = $cols[4]->findAll('css', 'a'); + $this->assertEquals('Preview in Collabora', $operation_links[0]->getText()); + $this->assertEquals( + Url::fromRoute('collabora-online.view', ['media' => $media->id()])->toString(), + $operation_links[0]->getAttribute('href') + ); + $this->assertEquals('Edit in Collabora', $operation_links[1]->getText()); + $this->assertEquals( + Url::fromRoute('collabora-online.edit', ['media' => $media->id()])->toString(), + $operation_links[1]->getAttribute('href') + ); + } + } + + /** + * Tests that the module configuration only adds links. + */ + public function testConfigDiff(): void { + // Check that view adds only fields for links. + $name = 'views.view.group_media'; + // Get modules path. + $collabora_path = \Drupal::moduleHandler()->getModule('collabora_online_group')->getPath(); + $groupmedia_path = \Drupal::moduleHandler()->getModule('groupmedia')->getPath(); + // Load views configurations to compare. + $collabora_source = new FileStorage($collabora_path . '/config/override'); + $collabora_view = $collabora_source->read($name); + $groupmedia_source = new FileStorage($groupmedia_path . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY); + $groupmedia_view = $groupmedia_source->read($name); + + // Link fields in configuration array are too big, we just check that are + // present. Links are checked in other test. + $this->assertTrue(!empty($collabora_view['display']['default']['display_options']['fields']['collabora_preview'])); + $this->assertTrue(!empty($collabora_view['display']['default']['display_options']['fields']['collabora_edit'])); + $collabora_view['display']['default']['display_options']['fields']['collabora_preview'] = []; + $collabora_view['display']['default']['display_options']['fields']['collabora_edit'] = []; + + // Difference should be module dependencies, fields, and dropdown. + $diff = DiffArray::diffAssocRecursive($collabora_view, $groupmedia_view); + $this->assertEquals([ + 'dependencies' => [ + 'module' => [ + 'collabora_online', + 'group', + 'media' + ] + ], + 'display' => [ + 'default' => [ + 'display_options' => [ + 'fields' => [ + 'collabora_preview' => [], + 'collabora_edit' => [], + 'dropbutton' => [ + 'fields' => [ + 'collabora_preview' => 'collabora_preview', + 'collabora_edit' => 'collabora_edit', + ] + ] + ] + ] + ] + ] + ], $diff); + } + +}