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
Separate component for Recommendations #1133
Conversation
@MonkeyDo @shivam-kapila I shared the screenshot on IRC, I don't understand why the recommendation card is not getting rendered, From the first look I understand that all the cards are overlapping each other, hence, we can see only one card, might be an issue of table reference, not sure. |
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.
This is a coarse review. I will review again once classes are over.
listenbrainz/webserver/static/js/src/recommendations/RecommendationCard.tsx
Outdated
Show resolved
Hide resolved
listenbrainz/webserver/static/js/src/recommendations/RecommendationControl.tsx
Outdated
Show resolved
Hide resolved
listenbrainz/webserver/static/js/src/recommendations/Recommendations.tsx
Outdated
Show resolved
Hide resolved
I have reused @shivam-kapila 's code in this PR at places, Thank you. I have tried to keep everything separate for recommendations (from less file to recommendation controls) so that it is easy to update things in future. |
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.
We need tests
listenbrainz/webserver/static/js/src/recommendations/RecommendationCard.tsx
Outdated
Show resolved
Hide resolved
listenbrainz/webserver/static/js/src/recommendations/RecommendationCard.tsx
Outdated
Show resolved
Hide resolved
listenbrainz/webserver/static/js/src/recommendations/Recommendations.tsx
Outdated
Show resolved
Hide resolved
listenbrainz/webserver/static/js/src/recommendations/Recommendations.tsx
Outdated
Show resolved
Hide resolved
listenbrainz/webserver/static/js/src/recommendations/Recommendations.tsx
Outdated
Show resolved
Hide resolved
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.
LGTM overall. Tests needed.
listenbrainz/webserver/static/js/src/recommendations/RecommendationCard.tsx
Show resolved
Hide resolved
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.
Not sure if I was meant to review the styles of the recommendation card component, I had to modify similar_artist.html to point to recommendations.js instead of main.js in order to see them.
listenbrainz/webserver/static/js/src/recommendations/Recommendations.tsx
Outdated
Show resolved
Hide resolved
listenbrainz/webserver/static/js/src/recommendations/RecommendationCard.tsx
Outdated
Show resolved
Hide resolved
listenbrainz/webserver/static/js/src/recommendations/RecommendationCard.tsx
Show resolved
Hide resolved
@vansika kindly run lint.sh to fix the build |
@MonkeyDo I think I am happy with this PR now, I am not touching listened_at for Listens type (people freaking out), that means I will have to supply listened_at with recommendations which is okay for me. If you feel the changes are okay, I will want to write tests and merge it. |
@MonkeyDo here is a screenshot for your reference :) |
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 we should change BrainzPlayer to not require a listened_at prop instead of changing the recommendation type to keep a listened at there.
@paramsingh I will not be doing that in this PR. In another Pr, for sure |
@paramsingh why not open a ticket :) will help me track |
OK, sounds like a plan. |
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.
We'll need to go over the CSS, but it's not blocking for merging this PR.
|
||
declare type Listen = BaseListenFormat & { | ||
listened_at_iso?: string | null; | ||
playing_now?: boolean | null; | ||
score?: number; |
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 wonder if this is relevant anywhere.
Doesn't need to be addressed in this PR, but maybe have a closer look at it when we tackle listened_at/BP changes.
score?: number; | ||
}; | ||
|
||
declare type Recommendation = BaseListenFormat; |
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.
That'll work nicely, and means you can easily extend the type with more fields as you need in the future, without having to change anything else( like we're gonna have to do for BP).
Yay future-proofing !
@@ -0,0 +1,61 @@ | |||
#recommendations { | |||
&:extend(#listens); | |||
padding: 10px; |
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 this less file will need a good refactor soon (and the listens-page file along with it), as there is still some duplicated css rules and a few things I'd like to change.
However, it ends up as just a few lines of extra unused CSS, which is not a blocker for this PR.
Considering how the rec styles are in flux, let's keep it for another PR.
> .col-xs-9, .col-xs-11 { | ||
|
||
> .col-xs-9, .col-xs-11 { |
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 you based this styling on what was there before, but a worthy comment:
Among the things that need changing that I mentioned above (for another PR), this use of bootstrap classes that are meant for layout to be used for styling should be replaced.
The reason is that for example if we decide to change the size of the columns but not the styling, we'll have to modify the less rules even though we haven't changed any of the styling.
Instead, we'll want them to be decoupled by using separate classes for styling and layout (like you do below with .smile, .laugh, .angry, .disappoint, .meh
instead of > span
).
padding: 15px; | ||
margin-bottom: 7px; | ||
max-height: 72px; |
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.
don't modify bootstrap classes in recommendation-page.less
* recommendation componeent and recommendation card * CSS for recommendation component * shift recommendationPaginationControl to main method don't modify bootstrap classes in recommendation-page.less * fix utils.tsx error * html emoticons for rec feddback * update func name * revamp listens and recommendations type * tests for recommendation component * tests for rec component
* recommendation componeent and recommendation card * CSS for recommendation component * shift recommendationPaginationControl to main method don't modify bootstrap classes in recommendation-page.less * fix utils.tsx error * html emoticons for rec feddback * update func name * revamp listens and recommendations type * tests for recommendation component * tests for rec component
* schema for storing recommendation feedback (#1126) * schema for recommendation feedback * rename enum strings and enum name * Separate component for Recommendations (#1133) * recommendation componeent and recommendation card * CSS for recommendation component * shift recommendationPaginationControl to main method don't modify bootstrap classes in recommendation-page.less * fix utils.tsx error * html emoticons for rec feddback * update func name * revamp listens and recommendations type * tests for recommendation component * tests for rec component * Refactor RecentListens - Remove recommendations code (#1146) * refactor recentListens * fix indentation * remove unused const * Recommendation feedback [DB + API] (#1143) * recommendation feedback model * use enum vals as feeeback to store in db * db and api script for recommendation feedback * PEP-8 fixes * tests feedback (db) * tests feedback (API) * tests update * don't create two objects * Sync recommendation feedback with emoticons (#1149) * tests feedback (db) * tests update * sync feedback * add missing props to test file * simplify get feedback for multiple recording query * keep recommendationFeedback type same as recommendationFeedback enum don't mutate the previous state * add event.stopPagination to stop closing of dropdown when submitting feedback * use Icon + text for feedback * use regular font awsome icons in place of stroke * if feedback given render corresponding feedback solid * remove redundant log statements * don't use prevState value in currRecPage * remove componentDidUpdate * adjust alignement of feedback for mobile view * capitalize feedback text * don't show feedbacks options for user != currentUser * define mediaquery after regular padding * tests for feedback * don't overwrite afterRecommendationDisplay in tests * add comment to instruct eslint to ignore import issue * tests for db * check for html elements before and after updating feedback * test interdependency of button and dropdown * format tests - nitpicks * remove bad_recommendation feddback type * adjust spacing between emoticons
Separate component to render recommendations.