Media author views filter should use the user_name plugin

Created on 16 February 2020, almost 5 years ago
Updated 11 April 2024, 10 months ago

Problem/Motivation

The media Authored by filter should use the user_name filter plugin OOTB in order to be consistent with Content, and provide a better UX with an autocomplete field.

Proposed resolution

Add this one liner to MediaViewsData

$data['media_field_data']['uid']['filter']['id'] = 'user_name';

How to test

  1. Enable the media module.
  2. Create a view for media content.
  3. Add an media author filter to a view and make it an exposed filter.
  4. Notice it's a simple text field and takes the uid as a value.
  5. Remove the filter and apply the patch, clearing caches just to be sure.
  6. Add the filter again, notice it's now an autocomplete field taking usernames as the values.
🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Views 

Last updated about 2 hours ago

Created by

🇦🇺Australia acbramley

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

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

  • First commit to issue fork.
  • 🇺🇸United States maskedjellybean Portland, OR

    Thank you for the patch in #99. It still works in Drupal core 10.2.3.

    I opened a MR (in case that helps move this along) which contains the changes from #99, plus hopefully fixes the tests, although I can already see they've failed...

  • Pipeline finished with Failed
    10 months ago
    Total: 959s
    #144377
  • 🇺🇸United States maskedjellybean Portland, OR

    Made the requested changed to the MR. Unfortunately I can't do anything more to make the tests pass because the error appears to have nothing to do with the test being added here.

  • Pipeline finished with Canceled
    10 months ago
    Total: 473s
    #147456
  • Pipeline finished with Success
    10 months ago
    Total: 988s
    #147466
  • 🇩🇪Germany mrshowerman Munich

    Just came across this and fell into the same trap as #85.
    Updating IS for clarity.

  • Pipeline finished with Success
    7 months ago
    Total: 597s
    #210766
  • Status changed to Needs review 7 months ago
  • 🇮🇳India mohit_aghera Rajkot

    - All three points mentioned by @acbramley is fixed by @maskedjellybean
    - Issue summary is updated and PR is rebased with latest 11.x.
    - Merge conflict is resolved.
    - Hiding older patches in favour of PR based approach.
    - I think it is ready for moving to needs review.

  • Status changed to RTBC 7 months ago
  • 🇺🇸United States smustgrave

    Ran test-only feature

    1) Drupal\Tests\media\Functional\MediaOverviewPageTest::testMediaOverviewAuthorFilter
    Behat\Mink\Exception\ElementNotFoundException: Form field with id|name|label|value "name[media_field_data.user_name]" not found.
    /builds/issue/drupal-3113989/vendor/behat/mink/src/WebAssert.php:731
    /builds/issue/drupal-3113989/core/tests/Drupal/Tests/UiHelperTrait.php:85
    /builds/issue/drupal-3113989/core/modules/media/tests/src/Functional/MediaOverviewPageTest.php:219
    FAILURES!
    Tests: 2, Assertions: 58, Failures: 1.
    

    Manually testing editing the view I'm seeing the new filters.

    Believe this is good

  • 🇬🇧United Kingdom catch
  • Status changed to Needs work 6 months ago
  • 🇳🇿New Zealand quietone

    There are no unanswered questions here.

    After reading the IS I expected to see a new plugin of some type, but there isn't one. The IS says there are no UI changes but there are so there should be screenshots available from the Issue summary.

    I then read the CR and saw that the screenshots are out of date. For that I applied the diff to make new ones. I then saw that the description for the new filter, 'Author name' is that it is the user ID. That is not correct, it is the user name. Should this be doing the same as the Content view and use a title of "Authored by" and a description of "The username of the content author."?

    At the lest the description should change. Setting to NW.

  • First commit to issue fork.
  • Status changed to Needs review 6 months ago
  • 🇬🇧United Kingdom scott_euser
    1. Updated label and description to match /admin/content (agree with #112)
    2. Updated issue summary
    3. Updated screenshots
    4. Updated change record
  • 🇬🇧United Kingdom scott_euser

    Updated 'After' screenshot to reflect change to default label

  • Pipeline finished with Failed
    6 months ago
    Total: 599s
    #261036
  • Status changed to Needs work 5 months ago
  • 🇺🇸United States smustgrave

    Appears to have a relevant test failure

    Have not reviewed yet.

  • Pipeline finished with Canceled
    3 months ago
    Total: 449s
    #335764
  • Pipeline finished with Success
    3 months ago
    Total: 1073s
    #335775
  • Status changed to Needs review 3 months ago
  • 🇬🇧United Kingdom scott_euser

    Test coverage passing now; applies a filter on username (rather than uid) and returns expected media entities as results.

  • 🇺🇸United States smustgrave

    Ran test-only feature

    1) Drupal\Tests\media\Functional\MediaOverviewPageTest::testMediaOverviewAuthorFilter
    Behat\Mink\Exception\ElementNotFoundException: Form field with id|name|label|value "name[media_field_data.user_name]" not found.
    /builds/issue/drupal-3113989/vendor/behat/mink/src/WebAssert.php:731
    /builds/issue/drupal-3113989/core/tests/Drupal/Tests/UiHelperTrait.php:90
    /builds/issue/drupal-3113989/core/modules/media/tests/src/Functional/MediaOverviewPageTest.php:270
    FAILURES!
    Tests: 3, Assertions: 65, Failures: 1.
    Exiting with EXIT_CODE=1
    

    Resolved the open threads as they appears to be addressed

    Applied the MR before doing an install
    Followed the steps in the summary and am seeing the new filter "The username of the content author."
    Applied it to the Media Library view I can filter by usernames

    LGTM

  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    Committed and pushed 68013115a83 to 11.x and c3a9311a660 to 11.1.x. Thanks!

    • alexpott committed c3a9311a on 11.1.x
      Issue #3113989 by acbramley, mohit_aghera, maskedjellybean, scott_euser...
    • alexpott committed 68013115 on 11.x
      Issue #3113989 by acbramley, mohit_aghera, maskedjellybean, scott_euser...
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024