Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The current export links are rendered as feed icons on the bottom left of the view. This makes them hard to discover. It would be better for us to follow Drupal best practices and create local actions for actions related to the current view.
Proposed resolution
Add local actions instead of feed icons.
Remaining tasks
/
Comment | File | Size | Author |
---|---|---|---|
#18 | composer.json — workspace 2024-02-02 11-08-32.png | 35.39 KB | realityloop |
Issue fork views_data_export-3414095
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedI have written a working prototype that adds local actions instead of feed buttons, but there's one issue: if the view has AJAX enabled and exposed filters are changed, the URL in the local action is not updated, which causes filters to not be passed to the export.
A couple possible solutions:
Comment #3
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedMore (possible) todo's:
Comment #5
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedI changed the local action name to use the display title, to fix the issue as described in #3397914: Multiple export download links should be distinguishable.
Comment #6
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedI fixed the issue where the local action title is not updated if the display title changes. Pretty sure the local action cache still needs to be invalidated when a new view is created, in order for the new local action to be generated, but I haven't tested this yet.
Comment #7
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedWhen removing the old feed icons I discovered we'll have to re-implement the auto download functionality - not sure what exactly it does though.
Comment #8
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedComment #9
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedI added some JS that keeps the local action query params up to date with the current page's query params.
Comment #10
solideogloria CreditAttribution: solideogloria commentedIf I remember correctly, the auto-download works using a CSS selector in the message shown with the download link. JavaScript selects the link from the message and downloads the file.
Comment #11
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedComment #12
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedIt looks like the 'Include query string parameters on redirect' option currently only applies to batched exports. By updating the query params in JS, it will also work for direct exports.
Comment #13
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedNever mind, the redirect functionality is obviously not available for direct downloads.
Comment #14
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedComment #15
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedComment #16
solideogloria CreditAttribution: solideogloria commentedThere is a failing test.
Comment #17
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedComment #18
realityloopI don't know why but this diff will not apply..
Comment #19
realityloopComment #20
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedMR's are based on the latest dev commit, not the latest tagged release. You can use the dev release (
composer require drupal/views_data_export:dev-1.x
) or you can try to rebase the branch against the latest tagged release and create a patch from that.Comment #21
solideogloria CreditAttribution: solideogloria commentedI'm not able to get the local download action to show. I can't figure out how to add the block to my page layout.
Comment #22
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedI'm sorry, but that sounds like an issue with your website, not with this MR. This MR shows local tasks just like core and every other contrib module does.
Comment #23
solideogloria CreditAttribution: solideogloria commentedI disagree. I have local tasks already showing, but your added tasks do not show. That in itself shows that this would be a breaking change
Comment #24
solideogloria CreditAttribution: solideogloria commentedI installed the dev version, applied the patch, cleared the cache, and yet I do not see any "Download CSV export" task link on the page where previously the Download CSV button showed. I am still able to see the standard View, Edit, Delete, Layout, and Revisions local tasks.
Comment #25
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedOh okay, so the issue is not about adding a block to your page layout. The local tasks of this issue should show in the same place as other local tasks do. Is the problem fixed after you clear caches? Did you change the 'Attach to' setting to include the display you want the local task to appear on?
Comment #26
solideogloria CreditAttribution: solideogloria commentedYes, the "attach to" option is correctly set. No, the download option doesn't show after clearing the cache.
Comment #27
solideogloria CreditAttribution: solideogloria commentedAh, I think the problem is that you added the link as an action, rather than as a task. I don't use the actions module.
This solution/change won't work for anyone who doesn't use actions.
Comment #28
solideogloria CreditAttribution: solideogloria commentedI think this should be thought through. If you look at examples in Core/Contrib, most action links are "Add X". In fact, I have yet to find one that isn't an "Add".
All the other local-type links are tasks.
Comment #29
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedRight, good catch. I still believe it makes sense to keep it a local action since downloading is an action: it doesn't even link to a separate page, it just downloads something. Local tasks are shown as tabs, they are links to separate pages. It would be confusing if clicking a tab wouldn't navigate to another page, but instead would download a file. Here's some info about local actions vs local tasks (tabs).
By the way, you don't need the actions module to be able to show local actions. Local actions are a core feature that can't be disabled. You might need to place the local actions block if you haven't yet, but I can't imagine a lot of people aren't using that block. It places useful links all throughout the admin interface.
Comment #30
solideogloria CreditAttribution: solideogloria commentedI have the block placed... in the admin theme. The download action on views is not going to be in the admin theme for most views with exposed filters, at least not in my case. My views with data export are on the user-facing non-admin part of the site.
Comment #31
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedOkay, so how do you propose going forward? Should we give the option to either show the old icon or the new local action? Or do you have something else in mind?
Comment #32
solideogloria CreditAttribution: solideogloria commentedI think if we have a config setting to either use a local action or a download button, that would work well.
Though I think it'd be better to add in the solution from #3379233: Increase size of download buttons instead of using the prior images. Images don't go well with site themes, and making them buttons works well.