At admin/group, the operations on groups are only Edit and Delete. But once I'm looking at a group, there are tabs for all the group content types, eg Members.

It would be useful to have these show in the operation dropdowns on the listing.

Comments

joachim created an issue. See original summary.

kristiaanvandeneynde’s picture

+1 on so many levels :)

I definitely want this in before RC1, but it may be a nice one to tackle once we're in beta.

jludwig’s picture

Status: Active » Needs review
StatusFileSize
new1.74 KB

This patch adds 'Members' and 'Nodes' as operations to the group listing page.

zerolab’s picture

Status: Needs review » Needs work

That looks like a promising start.

It is worth noting that only the memberships plugin is baked into group. Nodes come from the gnode GroupContentEnabler plugin and, in our case, other entities from custom plugins. As such it would be better to either provide a hook that each GroupContentEnabler plugin must implement. Or add operations based on $base_plugin_id and the label discovered by the plugin.

joachim’s picture

> As such it would be better to either provide a hook that each GroupContentEnabler plugin must implement.

I don't think that or the approach in the patch is needed. IIRC, I've seen other code that provides operations on entities on an entity listing, and it does so by looking at the menu tabs on the entity view: it's automatic.

jludwig’s picture

Status: Needs work » Needs review
StatusFileSize
new2.21 KB

> I don't think that or the approach in the patch is needed. IIRC, I've seen other code that provides operations on entities on an entity listing, and it does so by looking at the menu tabs on the entity view: it's automatic.

This approach doesn't seem to work in this circumstance. The way this is usually accomplished is through routing that is directly associated with the entity, the routing in this case is actually associated with the group_content entity rather than the group entity.

I did play around with it to see if I could get something to work, but the code ended up being rather messy and would take a change to the plugin that would seem to be more work to get it working than just implementing a hook.

The attached patch uses a core hook to split the operations additions into the appropriate modules. The group membership one could still be added using the getDefaultOperations() method, but I think that this way provides an example on how to add additional operations to people writing their own plugins.

One thing that I do not like about this patch is that type hinting it causes a PHP error because the passed argument could be two different interfaces, but I tried to document that as best I could in the docblock.

Edit: FYI, when I type hinted with EntityInterface, I got the following error on group/{group}/node:

a:5:{s:5:"%type";s:9:"TypeError";s:8:"@message";s:136:"Argument 1 passed to gnode_entity_operation() must be an instance of EntityInterface, instance of Drupal\group\Entity\GroupContent given";s:9:"%function";s:24:"gnode_entity_operation()";s:5:"%file";s:86:"/usr/share/webapps/drupal/drupal8.dev/modules/contrib/group/modules/gnode/gnode.module";s:5:"%line";i:321;}  

Typehinting with GroupContent ends up with this on the admin groups list:

a:5:{s:5:"%type";s:9:"TypeError";s:8:"@mes
sage";s:146:"Argument 1 passed to gnode_entity_operation() must be an instance of Drupal\group\Entity\Group, instance of Drupal\group\Entity\GroupContent given";s:9:"%function";s:24:"gnode_entity_operation()";s:5:"%file";s:86:"/usr/share/w
ebapps/drupal/drupal8.dev/modules/contrib/group/modules/gnode/gnode.module";s:5:"%line";i:319;}
alan.upstone’s picture

#6 is working well for me. Thanks.

The last submitted patch, 3: group-groups_listing_operations-2716051-0.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 6: group-groups_listing_operations-2716051-1.patch, failed testing.

mike.davis’s picture

Status: Needs work » Needs review
StatusFileSize
new2.68 KB

Hi, the patch from #6 doesn't work correctly with the latest group code. Here is an updated patch which enables this to work.

mike.davis’s picture

Here is an updated patch which checks for permissions on the user to be able to access the members and node list

mike.davis’s picture

Couple of tweaks due to various methods now being available on the GroupContentEnablerInterface for the plugin

mike.davis’s picture

Another update, so that the `administer group` access is checked to allow access to any administrators regardless of whether they are in the group or not

mike.davis’s picture

Here is another update which handles the check for the permissions of a user within a group better

kristiaanvandeneynde’s picture

Looks good, thanks all!

Applied is an updated patch which does not require a plugin to be installed for the Nodes tab to show up (as it's permission based) and adds tests.

kristiaanvandeneynde’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.