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

fix: Video Gallery filters and sorting #368

Merged
merged 1 commit into from
Aug 23, 2023

Conversation

xitij2000
Copy link
Contributor

@xitij2000 xitij2000 commented Aug 7, 2023

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.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Aug 7, 2023
@openedx-webhooks
Copy link

openedx-webhooks commented Aug 7, 2023

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:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

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.

@xitij2000 xitij2000 force-pushed the kshitij/fix-video-sort-filter branch 3 times, most recently from cac1eed to 7ffc39a Compare August 12, 2023 03:39
@codecov
Copy link

codecov bot commented Aug 12, 2023

Codecov Report

Patch coverage: 98.38% and project coverage change: -0.09% ⚠️

Comparison is base (e9c0f6c) 90.35% compared to head (1b3c587) 90.27%.
Report is 1 commits behind head on main.

❗ Current head 1b3c587 differs from pull request most recent head fb7caff. Consider uploading reports for the commit fb7caff to get more accurate results

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     
Files Changed Coverage Δ
src/editors/containers/VideoGallery/utils.js 100.00% <ø> (ø)
src/editors/sharedComponents/BaseModal/index.jsx 100.00% <ø> (ø)
...rs/sharedComponents/SelectionModal/GalleryCard.jsx 100.00% <ø> (ø)
...ditors/sharedComponents/SelectionModal/messages.js 100.00% <ø> (ø)
src/editors/containers/VideoGallery/hooks.js 83.11% <96.42%> (-10.79%) ⬇️
src/editors/containers/EditorContainer/hooks.js 100.00% <100.00%> (ø)
src/editors/containers/VideoGallery/index.jsx 100.00% <100.00%> (ø)
src/editors/containers/VideoUploadEditor/hooks.js 100.00% <100.00%> (ø)
...ditors/sharedComponents/SelectionModal/Gallery.jsx 84.61% <100.00%> (-15.39%) ⬇️
...nents/SelectionModal/MultiSelectFilterDropdown.jsx 100.00% <100.00%> (ø)
... and 2 more

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@xitij2000 xitij2000 force-pushed the kshitij/fix-video-sort-filter branch 6 times, most recently from 5d86789 to 1b3c587 Compare August 16, 2023 15:32
@farhaanbukhsh farhaanbukhsh self-requested a review August 17, 2023 05:24
Comment on lines 36 to 42
export const uploader = () => {
const [textInputValue, settextInputValue] = module.state.textInputValue('');
const [textInputValue, setTextInputValue] = module.state.textInputValue('');
return {
textInputValue,
settextInputValue,
setTextInputValue,
};
};
Copy link
Member

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 :)

Copy link
Contributor Author

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.

Comment on lines 21 to 22
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);
Copy link
Member

Choose a reason for hiding this comment

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

👍🏾

Comment on lines +10 to +20
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 }),
);
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

@farhaanbukhsh farhaanbukhsh left a 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.

Comment on lines -31 to -33
if (!show) {
return null;
}
Copy link
Contributor Author

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.
@xitij2000 xitij2000 force-pushed the kshitij/fix-video-sort-filter branch from 1b3c587 to fb7caff Compare August 17, 2023 07:53
Copy link
Contributor

@kenclary kenclary left a 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.

@kenclary kenclary merged commit 45e4bc5 into openedx:main Aug 23, 2023
@openedx-webhooks
Copy link

@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.

@xitij2000 xitij2000 deleted the kshitij/fix-video-sort-filter branch August 24, 2023 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants