Use query parameters for additional search views in Nuxt #3865
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes
Fixes #3864 by @obulat
Description
This PR updates the frontend implementation to use the query parameters instead of path parameters:
/image/tag/cat
->/image/collection?tag=cat
/image/source/wikimedia
->/image/collection?source=wikimedia
/image/source/wikimedia/creator/me
->/image/collection?source=wikimedia&creator=me
It updates pages, stores, collection middleware and API service.
Pages
The two pages (
tag/_tag.vue
andsource/_vue
) with a singlecollection.vue
page (which is duplicated for each media type). The parsing and setting ofcollectionParams
was removed from thesetup
function and moved to the collection middleware.Store
getCollectionPath
function is updated to create a path usingcollection
path part and relevant query parameters.This function is used for the source and creator link buttons, tags, the sources table.
API requests
The store collection parameters are converted to an API request URL. For now, before the API changes are implemented, we can use the search without
q
parameter: the full-text search within tags, creator and source.The following request URLS are used in this PR:
/images?unstable__collection=tag&tags=cat
/images?unstable__collection=source&source=flickr
/images?unstable__collection=creator&source=flickr&creator=me
The API currently ignores the
unstable__collection
parameter.When the API changes are implemented,
tags
will be replaced withunstable__tag
, and from then on the real collections with exact matches and sorted by newest will be returned.Important limitation
After these changes, the collection pages are not loaded on SSR because the
CollectionPage
sets the value of results before media is fetched, and server renders an empty result list. The follow-up PR that will use the newVMediaCollection
component from #3831, and fix this problem.Testing Instructions
Make sure that
additional_search_views
ison
on the/preferences
page.Navigate to tags, creator and source views from the single result pages. The client-side navigation should work correctly. Note that there will be times that the page renders only the loading skeletons. This problem will be solved in a separate PR.
Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin