Problem/Motivation
The REST export (\Drupal\rest\Plugin\views\display\RestExport) ViewsDisplay plugin allows paths to be configured for displays, but does not allow menu entries. While menu entries may not make sense for JSON serialization, there are use cases for other types.
For example, https://www.drupal.org/project/csv_serialization and https://www.drupal.org/project/xls_serialization allow users to create a View and have it create a CSV or XLS file. A user may want to make these available as a menu entry (eg, a menu of all of the XLS reports that can be generated from a site). Right now, you can add the path manually to a menu, but this means path changes need to be updated in multiple places and can cause quirks with permission changes made in views. You can also make a similar case for XML exports (I have had clients where we have done lots of manually trading XML back and forth).
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#27 | interdiff-24-26.txt | 10.04 KB | mpdonadio |
#27 | 2848971-26.patch | 52.38 KB | mpdonadio |
#25 | interdiff-18-24.txt | 10.92 KB | mpdonadio |
#25 | 2848971-24.patch | 44.5 KB | mpdonadio |
#18 | 2848971-18.patch | 34.12 KB | jofitz |
Comments
Comment #2
mpdonadioUntested, but mirroring what \Drupal\views\Plugin\views\display\Page does. Just want to see what explodes.
May also want contextual links?
Comment #4
shadcn CreditAttribution: shadcn at Chapter Three commentedWe had a similar use case in a recent project. So this make sense.
Missing defineOptions, buildOptionsForm et al. Looks like a lot of these are encapsulated inside
Page
plugin.Maybe extract these to a PagePluginPage?
Comment #5
mpdonadioCan't find what I am missing to make the menu option appear.
Comment #6
mpdonadioComment #8
Wim LeersComment #9
Wim LeersThis is closely related to #2778569: REST views: Consider implementing `attachTo` method in `RestExport` display plugin, in that this too would allow for a better UX for views with CSV/XLS/… exports.
I think this is a similarly rare need that this also deserves minor priority.
Comment #10
Wim LeersPinged @mpdonadio.
Comment #11
mpdonadioStill stuck on what the bug is in #5.
This will need a reroll for the array syntax change.
Comment #12
Wim LeersYay!
Comment #13
jofitz CreditAttribution: jofitz at ComputerMinds commentedPatch #5 no longer applies. Re-roll updating array syntax.
Comment #15
mpdonadioBot fail aside, I am at a loss why the menu option isn't appearing. I keep comparing the RestExport plugin against the page one and don't see what is missing.
Comment #17
jofitz CreditAttribution: jofitz at ComputerMinds commentedPatch in #13 no longer applies. Re-rolled.
Comment #18
jofitz CreditAttribution: jofitz at ComputerMinds commentedCorrect test failures and coding standards errors.
Comment #20
Wim LeersNice!
But, sorry, I still don't see test coverage. Also, I'm not a Views maintainer. This will need a review from one of them. Keeping at NR for now. Please ping one of the Views maintainers for a review!
Comment #21
Wim LeersBetter yet… let's move it to the Views module component to get a review.
This is making significant changes to
PathPluginBase
, which is definitely Views module material. Updating title to clarify that.Comment #22
mpdonadioThis doesn't apply to 8.4.x anymore, so I can't check it on the site where I was running into this problem, but last time I tried a patch on this issue the menu path wasn't appearing on the config page for this display view. So, we definitely need a functional test to cover this.
Comment #24
Wim LeersComment #25
mpdonadioOK, it turns out the menu option was hiding in the advanced tab...
First pass at a test. This fails because the menu entry for the REST display doesn't include the _format query. Not 100% sure why.
Probably want to update the test to do a proper simulation of adding the menu entry, but wanted to get this working first.
Comment #27
mpdonadioThis will be green and reviewable.
Comment #29
mpdonadioWell, the tests I ran were green :) Still would appreciate feedback on the patch while I look at the side effects from it.
Also tentatively raising to Major, as I think this will help mitigate #2937942: REST views: regression in 8.5.x: view with display using 'csv' format now returns a 406 response, need to add ?_format=csv to URL to make it work in the long run.
Comment #30
Wim LeersThis especially needs reviews from Views maintainers.