Problem/Motivation

If a site has many paragraph types and enables the Paragraphs Type Permissions module, then the list of permissions is hard to use. It would be easier to add the Manage Permissions tab for each paragraph type.

Steps to reproduce

Proposed resolution

  1. Make the per-type permissions depend on the paragraph type.
  2. Enable the Permissions form for each paragraph type.

See the change records

Since the entity type is defined in the main module, the submodule will have to alter the entity type definition.

Remaining tasks

User interface changes

Add the Permissions form for a paragraph type:

screenshot showing the Permissions form for a paragraph type

API changes

None

Data model changes

None

CommentFileSizeAuthor
#7 paragraph-permissions.png122.34 KBbenjifisher

Issue fork paragraphs-3350210

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

benjifisher created an issue. See original summary.

benjifisher’s picture

Title: Enble the Manage Permissions tab » Enable the Manage Permissions tab
igor mashevskyi’s picture

Assigned: Unassigned » igor mashevskyi

igor mashevskyi’s picture

Assigned: igor mashevskyi » Unassigned
igor mashevskyi’s picture

Status: Active » Needs review
benjifisher’s picture

Issue summary: View changes
Status: Needs review » Needs work
StatusFileSize
new122.34 KB

@Igor Mashevskyi, thanks for working on this!

I am not sure why the test failed. When I install the replicate module and run the test locally, it passes:

$ ddev phpunit modules/contrib/paragraphs/tests/src/Functional/WidgetStable/ParagraphsReplicateEnableTest.php 
PHPUnit 9.5.28 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\paragraphs\Functional\WidgetStable\ParagraphsReplicateEnableTest
...                                                                 3 / 3 (100%)

Time: 00:11.404, Memory: 4.00 MB

OK (3 tests, 114 assertions)

HTML output was generated

In addition to enabling the Permissions tab, the MR adds the dependency on the paragraph type (config entity) as described in the change record Permissions can define dependencies. I will add that to the issue description and let the maintainers decide whether they would like to do that in a separate issue. If so, then that should be a bug report, not a task. Either way, it might be worth adding a test that the permissions are removed if the paragraph type is removed.

Oh, I remember: the Permissions form for the type uses config dependency to find the related permissions, so the dependencies have to be declared in order for the form to work.

I tested manually by enabling the Paragraphs Library and Paragraphs Type Permissions modules. Going to /admin/structure/paragraphs_type, I found the "Manage Permissions" option in the drop button, and it led me to this page:

screenshot showing the Permissions form for a paragraph type

I will make a few suggestions on the MR. I am setting the status to NW now.

joelseguin’s picture

@benjifisher - thanks for the patch! I had assumed this functionality was already part of Paragraphs until I noticed it wasn't. I think it's very helpful for site builders as it improves the authoring experience especially when making use of many Paragraphs. It also serves as a reminder to actually set permissions for any new Paragraph that is created.

I tested the patch against the latest stable 1.x version and it worked without issues.

benjifisher’s picture

Status: Needs work » Needs review

@joelseguin: You are welcome. Technically, I just created the issue and reviewed the patch (or the merge request). Thank you for bumping this issue.

@IgorMashevskyi: Sorry, I did not notice that you updated the MR. I regularly check for issues that have been updated, but not MRs. I will set the status to NR now, and I will try to have another look soon.

igor mashevskyi’s picture

Hi guys, any updates here?
Can somebody check MR?
Thank you in advance

benjifisher’s picture

Status: Needs review » Needs work

I looked again at the MR. There is one open thread from my previous review, and I noticed that the change to the test seems to be unnecessary. (Or if it is necessary, it needs some explanation.) I ran the test locally with and without the change, and it passed (with deprecation notices) both ways.