-
Notifications
You must be signed in to change notification settings - Fork 218
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
Update VCollectionHeader.vue #3365
Conversation
Size Change: +902 B (0%) Total Size: 974 kB
ℹ️ View Unchanged
|
8f9d82b
to
4e6b00b
Compare
4e6b00b
to
8cc0cf3
Compare
Full-stack documentation: https://docs.openverse.org/_preview/3365 Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again. You can check the GitHub pages deployment action list to see the current status of the deployments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good and makes sense to me! One question about the translations, nothing to block a merge 🚀
audio: { | ||
zero: "No audio files by this creator in {source}", | ||
count: "{count} audio file by this creator in {source}|{count} audio files by this creator in {source}", | ||
countMore: "Over {count} audio files by this creator in {source}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These seem very similar, would it also be possible to interpolate the media type here too? Or is it just easier to define them separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to leave as much as possible fully written out because interpolation does not always work well for different languages, which might have very different pluralization and other grammar rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes make sense, LGTM. Why did the snapshots change from "10000 images" to "No image", is it possible to get 10000 and avoid the diffs?
resultCountLabel: { | ||
creator: { | ||
audio: { | ||
zero: "No audio files by this creator in {source}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is "track" a better word than "file" here? I would like us to identify a word that's more descriptive than "file" and use it consistently in the UI.
Signed-off-by: Olga Bulat <[email protected]>
8cc0cf3
to
af65ff8
Compare
Thank you for this comment, I did update the test to keep the number. The snapshots still had to be changed, though, due to the fact that I didn't add "over" in the original implementation, and instead of "Over 10000 results", it was just "10000 results" before 😢 |
Fixes
Updated implementation of #2729 by @obulat
Description
This PR is extracted from #3140 to make them easier to review.
When adding Nuxt page for the tag/source/creator collections in #3140, I first tried to add a single dynamic page for all of them to prevent code duplication.
I used a dynamic catch-all path
_mediaType/_collection/_.vue
, and thought that_mediaType
would catch theimage
oraudio
path parameter,_collection
would catch the first part of the path (tag
orsource
), and_.vue
would be the catch-all that collects the rest of the path parameters:tag/tagName
,source/sourceName
,source/sourceName/creator/creatorName
.However, this strategy catches more routes than expected. For instance, it would catch
/<localePrefix>/non-existent-page
, and would return the English error page because the collection page was seeing the locale prefix as_mediaType
, and path validation would fail because the locale prefix does not match the_mediaType
(image/audio).This is why I added 4 pages that used less dynamic path parameters (
/image/tag/_tag.vue
,/image/source/_.vue
).Previously, I planned to use the page to compute all the necessary parameters, and have
VCollectionHeader
as a simple presentational component. However, now that there are 4 page component, moving the computation to the store and the component makes more sense.Now
VCollectionHeader
accepts thecollectionParams
prop from the page component, and then computes the title, URL and the results label. There is a complication for the creator pages: we can only get the creator URL after we fetch the media, from the media item'screator_url
param. This is why thecreatorUrl
is still computed in the page (which handles media fetching) and is passed as a prop tocollectionParams
.This PR also converts the
CollectionParams
type to a discriminated union type to make it easier to narrow the type when handling it.Testing Instructions
Check the Storybook to see that
VCollectionHeader
is rendered correctly: https://docs.openverse.org/_preview/3365/storybook/?path=/story/components-vcollectionheader--all-collectionsTo run the Storybook locally, you may need to run
just frontend/run test:storybook
to run Storybook inside docker (it currently does not run locally on Mac due to ssl errors).Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin