Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use query parameters for additional search views in Nuxt #3866

Merged
merged 6 commits into from
Mar 8, 2024

Conversation

obulat
Copy link
Contributor

@obulat obulat commented Mar 3, 2024

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 and source/_vue) with a single collection.vue page (which is duplicated for each media type). The parsing and setting of collectionParams was removed from the setup function and moved to the collection middleware.

Store

getCollectionPath function is updated to create a path using collection 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 with unstable__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 new VMediaCollection component from #3831, and fix this problem.

Testing Instructions

Make sure that additional_search_views is on 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

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • I ran the DAG documentation generator (if applicable).

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@obulat obulat changed the title Additional search views/frontend query params Use query parameters for additional search views in Nuxt Mar 3, 2024
@github-actions github-actions bot added 🧱 stack: frontend Related to the Nuxt frontend 🧱 stack: mgmt Related to repo management and automations labels Mar 3, 2024
@openverse-bot openverse-bot added 🟧 priority: high Stalls work on the project or its dependents ✨ goal: improvement Improvement to an existing user-facing feature 💻 aspect: code Concerns the software code in the repository labels Mar 3, 2024
@obulat obulat marked this pull request as ready for review March 3, 2024 14:43
@obulat obulat requested review from a team as code owners March 3, 2024 14:43
@obulat obulat force-pushed the additional_search_views/frontend-query-params branch from 71af024 to 1fe5805 Compare March 4, 2024 15:14
Copy link
Member

@zackkrida zackkrida left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was very easy to follow and looks great! I've requested some changes. I tried to make it clear what suggestions feel optional; let me know if you have questions.

@zackkrida zackkrida requested review from fcoveram and removed request for fcoveram March 6, 2024 00:07
@obulat obulat force-pushed the additional_search_views/frontend-query-params branch 2 times, most recently from 449b4c6 to 36a0bd9 Compare March 6, 2024 10:58
@obulat obulat requested review from zackkrida and removed request for fcoveram March 6, 2024 11:05
@obulat obulat force-pushed the additional_search_views/frontend-query-params branch from 4645b7b to c840209 Compare March 6, 2024 16:37
@obulat obulat self-assigned this Mar 6, 2024
@obulat obulat force-pushed the additional_search_views/frontend-query-params branch from c840209 to 29f254e Compare March 6, 2024 16:47
@obulat obulat removed the request for review from stacimc March 6, 2024 16:48
Copy link
Member

@zackkrida zackkrida left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works great locally 🎉 LGTM!

@openverse-bot
Copy link
Collaborator

Based on the high urgency of this PR, the following reviewers are being gently reminded to review this PR:

@AetherUnbound
This reminder is being automatically generated due to the urgency configuration.

Excluding weekend1 days, this PR was ready for review 3 day(s) ago. PRs labelled with high urgency are expected to be reviewed within 2 weekday(s)2.

@obulat, if this PR is not ready for a review, please draft it to prevent reviewers from getting further unnecessary pings.

Footnotes

  1. Specifically, Saturday and Sunday.

  2. For the purpose of these reminders we treat Monday - Friday as weekdays. Please note that the operation that generates these reminders runs at midnight UTC on Monday - Friday. This means that depending on your timezone, you may be pinged outside of the expected range.

Copy link
Collaborator

@AetherUnbound AetherUnbound left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a lot of notes on the code itself, but one thing I've noticed: the collection pages seem to be using the default text (e.g. "Openly Licensed Images, Audio and More | Openverse"). It feels like that should be specific per collections page, as in "tag: cat | Openverse" or something?

@obulat
Copy link
Contributor Author

obulat commented Mar 7, 2024

I don't have a lot of notes on the code itself, but one thing I've noticed: the collection pages seem to be using the default text (e.g. "Openly Licensed Images, Audio and More | Openverse"). It feels like that should be specific per collections page, as in "tag: cat | Openverse" or something?

I should have added more details on the scope of this PR.

The main goal here is to make the creator/tag values with special characters work by making the store and the media-service use the URI-encoded query parameters, since URI-encoding path parameters is not feasible. So, it's important to see that you can visit the pages for creators with special characters in their names (I did add some special characters to the creator in the tapes in e2e tests to test that), and that the links (source/creator and tag links on the single result page and the source links in the sources table) work correctly, set the values in the store correctly, and decode the values for display so that the links don't have %20 in them instead of spaces.

This PR actually breaks some things like loading of the images (on server-rendered pages), and it does not fix the SEO-related. That should be done in a separate PR.
It also does not fetch the exact matches from the API since the requests using query parameters use the full-text search in the API right now.

Copy link
Collaborator

@AetherUnbound AetherUnbound left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this locally and the functionality as described works as expected! 🥳

@obulat obulat merged commit 154109c into main Mar 8, 2024
42 checks passed
@obulat obulat deleted the additional_search_views/frontend-query-params branch March 8, 2024 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 aspect: code Concerns the software code in the repository ✨ goal: improvement Improvement to an existing user-facing feature 🟧 priority: high Stalls work on the project or its dependents 🧱 stack: frontend Related to the Nuxt frontend 🧱 stack: mgmt Related to repo management and automations
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Replace Additional search views path parameters with query parameters
4 participants