Add views field to display a user's assigned Workbench Section

Created on 9 June 2022, over 2 years ago
Updated 13 September 2024, 3 months ago

Problem/Motivation

Workbench Access provides a "Workbench Section: {access scheme name}" views field plugin (also a filter plugin) for each access scheme configured at /admin/config/workflow/workbench_access.

Let's assume that we have an access scheme named "Division" that is configured to use the vocabulary named "Business Group" (which has terms "Sales" and "Manufacturing"). In this example, there would be a views field plugin named "Workbench Section: Division" available for us to add to a view. Let's suppose we have added this views field to a view.

Suppose we have a user named "Sara" whose user account has a role that does not have the "Bypass Workbench Access permissions" permission, and who's workbench access section is "Manufacturing". In the view, the "Workbench Section: Division" field for the "Sara" role would display "Manufacturing", as expected.

Suppose we have another user named "Jane" whose user account has a role that does have the "Bypass Workbench Access permissions" permission, and who's workbench access section is "Sales". In the view, the "Workbench Section: Division" field would display "Business Group" instead of "Sales", because Jane has the "Bypass Workbench Access permissions" permission, and therefore has access to all content controlled by that workbench section. (in a sense, the view field shows the "effective" workbench section, as opposed to the "assigned" workbench section)

I'd like to propose that we add a "Workbench Assigned Section: {access scheme name}" views field plugin, which would always display the assigned workbench access section, i.e.: "Manufacturing" for Sara, and "Sales" for Jane.

Steps to reproduce

  1. Download Drupal 9.3.15, install using the Standard install profile, and log in as an administrator.
  2. composer require 'drupal/workbench_access:1.x-dev@dev'. Go to /admin/modules and enable the "Workbench access" module.
  3. Go to /admin/people/permissions/content_editor, check "Allow all members of this role to be assigned to Workbench Access sections", check "View Workbench Access information", and click "Save permissions".
  4. Go to /admin/structure/taxonomy/add and add a vocabulary named "Business Group". Add terms "Sales" and "Manufacturing".
  5. Go to /admin/config/workflow/workbench_access/access_scheme/add and add an access scheme:
    • Label = "Division"
    • Plural Label = "Divisions"
    • Access scheme = "Taxonomy"
    • Click "Save"
    • Vocabularies = "Business Group"
    • Click "Save" again
  6. Go to /admin/people/create, add a user named "Sara", with the roles "Authenticated user" and "Content editor". Click "Create new account". In the "Created a new user account for Sara" message, click "Sara", then the "Workbench Access" tab, check = "- Manufacturing" in the Assigned sections control, and click "Save".
  7. Go to /admin/people/create, add a user named "Jane", with the roles "Authenticated user" and "Administrator". Click "Create new account". In the "Created a new user account for Jane" message, click "Jane", then the "Workbench Access" tab, check "- Sales" in the Assigned sections control, and click "Save".
  8. Go to /admin/config/development/performance and click "Clear all caches"
  9. Go to /admin/structure/views/view/user_admin_people/edit/page_1. Next to "Fields", click "Add". Check "Workbench Section: Division", and click "Add and configure fields". Click "Apply" to use the default settings. Click "Save" to save the view.
  10. Go to /admin/people. Note there is a "Workbench Section: Division" column. Note that "Sara" shows "Manufacturing" in that column. Note that "Jane" (and your administrator user, if applicable) both show "Business Group".
    • This ticket proposes adding a new field that would show "Sales" for Jane instead of "Business Group" (and an empty cell for users who do not have an explicit workbench section, e.g.: your administrator user)

Proposed resolution

Add views field to display a user's *assigned* Workbench Section.

Remaining tasks

  1. Review and feedback
  2. RTBC and feedback
  3. Commit and release

User interface changes

Adds a views field plugin, "Workbench Assigned Section", which shows the assigned workbench section, rather than the effective workbench section.

API changes

None.

Data model changes

None.

✨ Feature request
Status

Needs review

Version

2.0

Component

Code

Created by

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States agentrickard Georgia (US)

    Bumping for review.

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

    The patch worked for me but can we open an MR before marking. Make sure it passes tests

  • Hi, any update on this MR?

    I'm particularly interested in using this feature to restrict content visibility in the content admin based on a user's assigned workbench section. I would like users who are not assigned to a particular section to only see nodes that are tagged with that section. For example, Sara would only see nodes that are tagged with "Manufacturing" and Jane would only see "Sales" nodes.

    Would this MR be able to fulfill this use case? If not, are there any additional steps or modifications required to achieve this functionality?

Production build 0.71.5 2024