Allow generic config entities to opt in to the entity specific Manage Permissions form

Created on 9 December 2024, about 1 month ago

Problem/Motivation

As part of #2934995: Add a "Manage permissions" tab for each bundle that has associated permissions β†’ & #3253955: Let modules opt in to the bundle-specific permissions form β†’ , a nice UI to manage bundle-specific permissions directly from the bundle management page was added.

However, according to the Change Record ([#3242827]), it is not possible to provide this feature to generic config entities that provide permissions, like core's Filter Formats or Dashboards provided by Dashboard module.

The aim of this issue is to give the possibility to opt-in to include a similar tab for generic config entities.

Proposed resolution

Provide a way for generic config entities to opt-in the Manage permissions tab.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

✨ Feature request
Status

Active

Version

11.0 πŸ”₯

Component

user.module

Created by

πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @plopesc
  • Pipeline finished with Failed
    about 1 month ago
    Total: 805s
    #363198
  • Pipeline finished with Success
    about 1 month ago
    Total: 1719s
    #363244
  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid

    MR created.

  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Ran the test-only feature

    1) Drupal\Tests\user\Unit\Plugin\Derivative\UserLocalTaskTest::testGetDerivativeDefinitions
    Failed asserting that two arrays are equal.
    --- Expected
    +++ Actual
    @@ @@
     Array (
         'permissions_entity_bundle_of_id' => [...]
    -    'permissions_entity_no_bundle_of' => [...]
     )
    /builds/issue/drupal-3492584/core/modules/user/tests/src/Unit/Plugin/Derivative/UserLocalTaskTest.php:95
    FAILURES!
    Tests: 1, Assertions: 1, Fa
    

    Which shows the coverage.
    Issue summary appears complete.

    Thought maybe the variable rename would be out of scope but this does more clearly match the change.
    Pipeline is still fully green
    So to be the change should be fine and don't see anything glaring.

    Saving credit for @plopesc for doing everything lol

  • πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

    @smustgrave:

    The "T" in RTBC is for "testing", and that usually means manual testing (not just confirming that the automated tests pass). You did not mention how you tested this issue.

    @plopesc:

    Can you explain why you want this change?

    In the issue summary, you wrote,

    As an example of this feature, Text Formats opt-in to provide the Manage permissions tab-

    I tested the MR with the Umami demo profile. As expected, I got a permissions form at /en/admin/config/content/formats/manage/basic_html/permissions:

    Do we really need a whole page just to manage one permission? Maybe we do, if people look for a local task (tab) to manage that permission. But we already have a page for managing all permissions from the filter module: /en/admin/people/permissions/module/filter:

    I see that you added this issue after working on ✨ provide a Manage Permissions tab for Dashboard entity Active for the Dashboard module. I have not tried that module, so I am not sure of the use case there. Are there typically several dashboards on a site (perhaps most roles get a dedicated dashboard)? Are there several permissions for each one? If either answer is "no", then maybe /en/admin/people/permissions/module/dashboard is good enough.

    While working on #2934995: Add a "Manage permissions" tab for each bundle that has associated permissions β†’ , we considered adding permissions forms for more generic config entities. In Comment #65 on that issue, I wrote,

    I wonder if we want to make this work for entity types which don't define bundles, say config entities or content entities without bundles?

    I am not sure what you mean. If there are no bundles, then there are no per-bundle permissions. For example, the user entity has no bundles.

    There are permissions for each text format: see /admin/people/permissions/module/filter. There could be other examples, or a conrib [sic] module could add additional permissions for each text format. Even if we want to implement a permissions form for that use case, I think it is out of scope for this issue, since the implementation here relies heavily on the information we get from the Entity API.

    This suggestion looks to me like a solution in search of a problem.

    So we explicitly considered the filter module. I am not saying that the decision we made then was final, just that we need some justification for overriding that decision.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Wooow ok

  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid

    Thank you for your input here @benjifisher.

    While working on ✨ provide a Manage Permissions tab for Dashboard entity Active as you pointed out, we found out this limitation and tried to give support to generic config entities here.

    Since Text formats were mentioned explicitly in the Change Record, I assumed it could be a good example for this new feature.

    Reading the comment mentioned above, it seems you had good reasons to not give that support for Text Formats, so we could remove that part from this issue.

    However, given that technically is possible, and some contrib modules, and maybe core ones in the future, could make use of this feature. Might you consider to implement it for now in a test entity type in core, leaving text formats as they are now?

Production build 0.71.5 2024