-
Notifications
You must be signed in to change notification settings - Fork 33
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
fix: Video Gallery filters and sorting #368
fix: Video Gallery filters and sorting #368
Conversation
Thanks for the pull request, @xitij2000! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
cac1eed
to
7ffc39a
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #368 +/- ##
==========================================
- Coverage 90.35% 90.27% -0.09%
==========================================
Files 226 227 +1
Lines 4022 4030 +8
Branches 798 799 +1
==========================================
+ Hits 3634 3638 +4
- Misses 369 372 +3
- Partials 19 20 +1
☔ View full report in Codecov by Sentry. |
5d86789
to
1b3c587
Compare
export const uploader = () => { | ||
const [textInputValue, settextInputValue] = module.state.textInputValue(''); | ||
const [textInputValue, setTextInputValue] = module.state.textInputValue(''); | ||
return { | ||
textInputValue, | ||
settextInputValue, | ||
setTextInputValue, | ||
}; | ||
}; |
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.
@xitij2000 you might want to undo this since I fixed it in my PR :)
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.
Sure! I think this entire function can be removed since it just proxies a call to React.useState in the end.
export const useSearchAndSortProps = () => { | ||
const [searchString, setSearchString] = React.useState(''); | ||
const [sortBy, setSortBy] = React.useState(sortKeys.dateNewest); | ||
const [filterBy, setFilterBy] = React.useState(filterKeys.videoStatus); | ||
const [hideSelectedVideos, setHideSelectedVideos] = React.useState(false); |
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.
👍🏾
export const VideoGallery = () => { | ||
const rawVideos = useSelector(selectors.app.videos); | ||
const isLoaded = useSelector( | ||
(state) => selectors.requests.isFinished(state, { requestKey: RequestKeys.fetchVideos }), | ||
); | ||
const isFetchError = useSelector( | ||
(state) => selectors.requests.isFailed(state, { requestKey: RequestKeys.fetchVideos }), | ||
); | ||
const isUploadError = useSelector( | ||
(state) => selectors.requests.isFailed(state, { requestKey: RequestKeys.uploadVideo }), | ||
); |
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 this pattern better than passing the selectors as a state to props?
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 older mechanism of passing them as props makes it harder to understand where the data is coming from since some params are magically filed in and others need to be provided. I find this more explicit.
Ideally, I'd also prefer if we had selectors like selectors.requests.fetchVideos
which return a status like 'in_progress', 'done' etc. and then functions called isFinished
etc to resolve that. That would make the above calls:
const isLoaded = isFinished(useSelector(selectors.requests.fetchVideos));
That seems a lot cleaner than the current status quo, however it was a bigger refactoring than I had time for.
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.
👍
Thanks @xitij2000 this an amazing improvement to what we had.
- ✅ I tested this: running on devstack
- ✅ I read through the code
- ❌ I checked for accessibility issues
- ❌ Includes documentation
- ❌ I made sure any change in configuration variables is reflected in the corresponding client's
configuration-secure
repository.
if (!show) { | ||
return null; | ||
} |
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 removed this because I didn't see a good reason this should be a prop. If a parent component wants to hide this component it can just not render it instead of passing this prop and having it not render itself.
The sort and filter UI of the video gallery was not working, this fixes that issue, and also adds a new UI for filering videos that allows filtering videos to include more than one status. It also fixes the hooks related to VideoGallery to avoid potential bugs in the future and updates tests to use react testing library instead of enzyme. It also reduces the padding in gallery page.
1b3c587
to
fb7caff
Compare
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.
ok, looks good enough.
@xitij2000 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
This PR fixes the filtering and sorting on the video gallery page and also adds support for a checkbox-based filtering mechanism allowing multiple filters to be selected.
Screenshots:
demo-of-video-filter.2023-08-14.14-22.mp4
Testing instructions:
The filtering and sorting should work, and all tests should pass.