I'm working on "porting" the media_browse_plus module (folders branch) to the latest dev of media. While doing so I struggled over this jQuery selector for the action-links in the admin ui:

// Configure the "Add file" link to fire the media browser popup.
    $('ul.action-links li', context).remove();

Unfortunately this selector removes not only the "Add file" link but all potential action-links.
I suggest we change the selector to this to avoid that:

// Configure the "Add file" link to fire the media browser popup.
    $('ul.action-links li', context).has('a.media-launcher').remove();

This way the links of other modules will stay untouched.

Comments

Status: Needs review » Needs work

The last submitted patch, media-use-more-specific-selector-to-replace-add-file-link.patch, failed testing.

Sebastian.Buesing’s picture

not quite there yet:

<ul class="action-links">
<li><a href="/drupal-7.2/admin/content/media/import">Import media</a></li>
<li><a href="/drupal-7.2/admin/content/media/browser">Media browser</a></li>
<li><a href="http://172.19.3.3/drupal-7.2/drupal-7.2/?q=admin/content/media/filter" id="media-filter-launch">Apply Filter</a></li>
<li><a href="/drupal-7.2/admin/content/media/folder_list">Folder Management</a></li>
<li><a href="#" class="media-launcher">Add file</a></li>
</ul>

Thats what I get with the patch :-)

dlumberg’s picture

Check this out http://drupal.org/node/1163100

I think it might accomplish what you're looking for.

das-peter’s picture

Status: Needs work » Needs review
StatusFileSize
new574 bytes

Just struggled over the same thing.
Unfortunately I don't really know from where the links, that should be replaced, come from. The attached patch now replaces them by using the link target. But I'd prefer to replace them by a class or id instead.
If someone has a hint I'll extend the patch.

Sebastian.Buesing’s picture

Does now work fine with media_browser_plus!

Pisco’s picture

Rerolled and adapted the patch (remove versus hide).

Pisco’s picture

Where's the patch??!?! … here it is. Sorry for that!

Pisco’s picture

Would be nice to have this patch included quickly as it kind of blocks Media browser plus.

Sebastian.Buesing’s picture

I totally agree with Pisco here and would love to see it committted.

ParisLiakos’s picture

Status: Needs review » Reviewed & tested by the community

Dont know whether this applies in 7.x-2.x too.
Will give it a check later,but its RTBC for 7.x-1.x

dave reid’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.87 KB

So I reviewed #7 and I'm wondering why we need to hide any action links at all? The 'Add file' link does not already exist in local actions, so the only thing this code does is hide the 'Import media' local action.

Someone please test what happens when we just get rid of $('ul.action-links li', context).hide(); because that seems to be the better solution here (and is in line with what the current media.admin.js does in 7.x-2.x).

dave reid’s picture

I tested this with an additional local action of admin/content/media/test-action and it appears and works with the patch in #11.

ParisLiakos’s picture

Status: Needs review » Reviewed & tested by the community

Tested it and works indeed!
seems i missed Add file's removal from hook_menu() (cool) !

The best solution would be adding an id to this link through the hook_menu() to this link but since this is currently impossible (see #1043906: Document how to possible to add link options when defining local tasks and actions) this is the best solution. thanks Dave

dave reid’s picture

Status: Reviewed & tested by the community » Fixed
das-peter’s picture

Awesome, thank you very much. Now we're definitely heading for the next beta of media browser plus.

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