Postponed on #3023527: Add: "View any unpublished [entity_type]" permission

Describe your bug or feature request.

The module doesn't provide a "view any unpublished commerce_product" permission.
There's only a "view own unpublished commerce_product" permission.
Therefore, commerce products created by a different user that the one who's accessing the commerce products dashboard are not showing up in the list.

Purposed resolution

We should have a "view any unpublished commerce_product" permission (or per bundle "view any unpublished %commerce_product_type commerce_product") and users with that permission should be able to see any unpublished product in the commerce product overview.

Issue fork commerce-3262938

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

MacSim created an issue. See original summary.

macsim’s picture

Issue summary: View changes

macsim’s picture

Status: Active » Needs work

I don't quite understand the way the permissions are managed in this module so I can't actually do more than just providing the test that has to be ok in the end.

macsim’s picture

Status: Needs work » Closed (works as designed)

Closing the issue. I just needed to give the "administer commerce products" permission to the role.

apolitsin’s picture

Status: Closed (works as designed) » Active

A global permission "administer commerce products" gives too much power: a user has the ability to delete any product - it's bad for linked orders.

plopesc made their first commit to this issue’s fork.

plopesc’s picture

Category: Bug report » Feature request
Status: Active » Needs review

Hello!

We had this same issue and here is a patch to solve this situation, adding those required permissions and integrating them into the whole Commerce ecosystem.

Thank you!

arantxio’s picture

Status: Needs review » Reviewed & tested by the community

Tested this in our environment and helps us a bunch. Still works for commerce 2.35. Thank you!

jsacksick’s picture

Would have been nice to have this handled by the Entity module. Unfortunately, #3023527: Add: "View any unpublished [entity_type]" permission never landed.

mkalkbrenner made their first commit to this issue’s fork.

mglaman’s picture

Status: Reviewed & tested by the community » Needs work

The code needs work to make it more readable and reduce cognitive load. Also, the logic is redundant. Why add an OR condition for a boolean field when allowing both states?

mkalkbrenner’s picture

Version: 8.x-2.29 » 8.x-2.x-dev
Status: Needs work » Needs review
StatusFileSize
new10.83 KB

ProductQueryAccessHandler within the current MR contains lot of code copied from its base class. I think we should avoid that redundancy and simplify the patch.

I don't want to change the existing MR, so I created a patch.

mkalkbrenner’s picture

StatusFileSize
new10.83 KB
new842 bytes
mkalkbrenner’s picture

StatusFileSize
new11.07 KB
new1.77 KB

Even if all tests pass, the commerce_products view breaks using the patch in #16. It just displays unpublished products.
I think I fixed that now.

In general in would be better to solve #3023527: Add: "View any unpublished [entity_type]" permission, but we need this feature quickly, so we use this patch here.

anybody’s picture

Status: Needs review » Reviewed & tested by the community

We just ran into the same issue, this permission is definitely still missing. Anyway I agree with #17 - thanks for the patch @mkalkbrenner!!

So I'll set this RTBC for the maintainer to decide if this should be postponed or integrated already.

jsacksick’s picture

Since we're depending on the entity module, I also think it makes more sense to add support for the "view any unpublished [entity_type] permission" there to avoid duplicating the logic in Commerce.

anybody’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Postponed
jsacksick’s picture

Even if the Entity API fix lands, we'll still need to update Commerce, so we need to keep this opened :). But I guess "postponed" is an okay status.
I personally don't have commit access to the Entity API module so I cannot be the one merging the MR there unfortunately.

mkalkbrenner’s picture

StatusFileSize
new11.07 KB

Here's a patch against commerce 3.3.2