Filter permissions on description not just module name

Created on 7 January 2023, almost 2 years ago
Updated 23 January 2023, almost 2 years ago

Problem/Motivation

In #3212569: Permissions filter appears to filter on module name, but doesn't make that clear β†’ the quick solution was implemented to change the placeholder text to show that filtering was just by module name. This issue is to investigate if we can also filter on the permission displayed name.

Steps to reproduce

On the permissions page admin/people/permissions enter - The permission "administer blocks" is not shown.

Proposed resolution

Filter on the permission name, so that entering will show all permissions that include 'admin' in the permission name

✨ Feature request
Status

Fixed

Version

4.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom jonathan1055

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.

  • Status changed to Needs work almost 2 years ago
  • πŸ‡¬πŸ‡§United Kingdom jonathan1055

    We also need to go the other way - when a module name is matched then display all of the permissions defined by it. Otherwise the filter is not really helpful because the actual checkboxes will not be shown. This is how it works right now, without this MR. The filter is not giving us anything useful other than allowing you to see the module names. To make changes you need to to remove the filter text.

    I'm sure we can get this working so that it is useful.

  • πŸ‡¬πŸ‡§United Kingdom jonathan1055

    Now that I've added a test for the existing permissions filter, this MR should show a test failure.

  • πŸ‡¬πŸ‡§United Kingdom jonathan1055

    Good. As expected the new test (which passes on the 4.x branch) fails here, showing that the initial commit as shown in #2 causes the existing functionality to fail.

    The problem is that the javascript was checking for empty text to determine if the item was a module or a permission using
    item.isModule = item.text != ''
    This worked fine before, because all of the permission elements returned '' for text. But now that we are selecting the permission text elements for matching, they have a text value. Hence everything was being treated as a module name. But we can simply use the element class to determine if it is a module or permission
    item.isModule = item.element.has('.module').length;

    This also solves the problem of the module name not showing when a permission is matched. We already have code to display the module name when the item is a permission (maybe left over from when matching on permission was attempted before? in 7.x?). So now that 'isModule' is set correctly we get the module names being shown when a permission they contain matches the input, even if the module name does not match the input. Attached is a new screengrab when filtering on 'admin'. Compare this to the screen in #2 and #6

  • Status changed to Needs review almost 2 years ago
  • πŸ‡¬πŸ‡§United Kingdom jonathan1055

    I have also expanded the existing test to cover matching on the text of the permission.
    And the placeholder now says 'Filter by module or permission'

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

    Tested by filtering for

    administer blocks and it got treated as searching for 2 words separately (which is true search to me)

    Then I searched "administer block" and got just the permission for blocks

    Great work!

  • Status changed to Fixed almost 2 years ago
  • πŸ‡¬πŸ‡§United Kingdom jonathan1055

    Ah, I never thought about testing for two words. Most of the work was done already, I only had to fix the isModule problem.

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

Production build 0.71.5 2024