Missing select media source option

Created on 14 March 2023, almost 2 years ago
Updated 24 April 2023, over 1 year ago

With the latest version of the module, when I select either the DAM or Drupal as the media source, the option disappears and I no longer can change it.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom Ok4p1 Glasgow

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

Comments & Activities

  • Issue created by @Ok4p1
  • πŸ‡²πŸ‡©Moldova sandzel Chisinau

    I met the same issue. I attached the patch with the fix.

  • πŸ‡²πŸ‡©Moldova sandzel Chisinau

    The patch #2 is fixing the issue but it generates 2 more warnings which I will try to fix them
    Warning: Undefined array key "#links" in Drupal\acquia_dam\AssetLibraryBuilder->addSourceMenu() (line 510 of /var/www/docroot/modules/contrib/acquia_dam/src/AssetLibraryBuilder.php)

    and

    Warning: foreach() argument must be of type array|object, null given in Drupal\acquia_dam\AssetLibraryBuilder->addSourceMenu() (line 510 of /var/www/docroot/modules/contrib/acquia_dam/src/AssetLibraryBuilder.php)

  • πŸ‡²πŸ‡©Moldova sandzel Chisinau

    Please use this new patch instead of the old one. I fixed the warnings as well.

  • πŸ‡²πŸ‡©Moldova sandzel Chisinau

    If I have chosen a media field to be able to add Media Types such as Image and DAM Image, my expectation is that when I open the Media Library, the 'Select media source' field should allow me to switch between the 'DAM' and 'Media Types' Media Sources and vice versa. However, this is no longer happening since the modifications in https://www.drupal.org/project/acquia_dam/issues/3338385 πŸ› PHP errors caused by media library popup Fixed .

    The patch I added fixes this issue. The idea is to display the 'Select Media Source' field and omit displaying the menu with the Media types when not needed.

  • Assigned to mglaman
  • Status changed to Needs review almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

    Thanks, @sandzel. Reviewing

  • @mglaman opened merge request.
  • The last submitted patch, 4: acquia_dam-3347862-3.patch, failed testing. View results β†’
    - codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

  • Status changed to Needs work almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

    I see, because each tab has one (DAM Image, Drupal Image) and $state->get('media_library_content') === '1' is triggered, which \Drupal\media_library\MediaLibraryUiBuilder::buildUi then just returns

        if ($state->get('media_library_content') === '1') {
          return $this->buildLibraryContent($state);
        }
    
  • πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

    Actually, it wasn't due to media_library_content . Thanks for calling out that earlier issue.

    This important part was missed:

        // If there is only one source for the media types, no need to render the
        // source selector.
        if (count($grouped_allowed_types) === 1) {
          return parent::buildUi($state);
        }
    

    I shouldn't have checked for an empty menu. We know the selector needs to be added if this is called, as earlier the builder determines if there are multiple media type sources.

  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

    This should do it. Fixed the tests – if I had called buildUi instead of addSourceMenu this would have been caught. Thanks @sandzel, again.

    • mglaman β†’ authored 58dfa490 on 1.0.x
      Issue #3347862 by sandzel: Missing select media source option
      
      DIT-1183...
  • πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

    Thanks! Merged.

  • Status changed to Fixed over 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024