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

New feature: Remote download on content pages #10558

Merged
merged 15 commits into from
May 10, 2023

Conversation

MisRob
Copy link
Member

@MisRob MisRob commented Apr 25, 2023

Summary

  • Fix: a remote content page now loads
  • Fix: a new download request is now saved where it was meant to in useDownloadRequests
  • New feature: Adds frontend part of download logic to content pages when browsing remote content. Note that the download action is mocked (see follow-ups and code comments)
(1) All actions as icons (2) Actions hidden in the menu (3) Actions partially hidden in the menu
Peek 2023-04-27 13-32 mobile mobile2

Notice somewhat strange UX in (3) as the download option disappears and later the bookmark option appears. We may need to re-think the logic around displaying icons/menu items in the LearningActivityBar to be able to improve this. Unless someone has a better idea, I can open an issue for that.

References

Follow-ups and related issues

Reviewer guidance

Taking into account the number of related issues, some of them in need of implementation before this feature is complete, I think it'd make more sense to do a more thorough QA of download as a whole as soon we have everything in place. In this PR, we can focus on:

  • Download/bookmark buttons and loader UX
  • Code review
  • Review of related KDS PR Add an option to freeze loader kolibri-design-system#433
  • QA of conditions for displaying download and bookmark buttons on remote content page:
    • Neither bookmark nor download button is displayed when logged out
    • For content that was imported by an admin, the bookmark button is displayed and the download button is not
    • For content that was downloaded by a learner, the bookmark button is displayed and the download button is not (download is mocked)
    • For content that wasn't imported by an admin nor downloaded by a learner yet, the bookmark button is not displayed and the download button is displayed
  • QA of regressions on non-remote content pages
    • Bookmarking still working?

To test remote content, you can navigate to Library -> Mr Tibbles' Classroom Server -> Kolibri QA Channel as a learner

Comments


Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

PR process

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

MisRob added 4 commits April 19, 2023 13:21
To fix the topic content page not being properly loaded.

This is most likely a temporary fix since the composable is
work in progress. In the long term, it seems that pagination
parameters will be optional.
for smoother user experience when
showing/hiding download/bookmark button
and the download loader
@github-actions github-actions bot added APP: Learn Re: Learn App (content, quizzes, lessons, etc.) SIZE: large labels Apr 25, 2023
@MisRob MisRob force-pushed the content-renderer-download-2 branch from b42c4c9 to f7a394d Compare April 26, 2023 04:28
- remove obsolete code
- improve test cases independence
- refactor redundant code
- re-organize the test suite to be better readable
@@ -119,11 +119,18 @@ export default function useDownloadRequests(store) {
status: 'QUEUED',
date_added: new Date(),
};
// TODO: Remove and replace by real progress implementation
Copy link
Member Author

Choose a reason for hiding this comment

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

Follow-up issue #10564

return false;
}
const downloadRequest = downloadRequestMap.downloads[this.content.id];
// TODO: Get real progress from `downloadRequest` as soon as backend is ready
Copy link
Member Author

Choose a reason for hiding this comment

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

Follow-up issue #10564

return false;
}
const downloadRequest = downloadRequestMap.downloads[this.content.id];
// TODO: Get real progress from `downloadRequest` as soon as backend is ready
Copy link
Member Author

Choose a reason for hiding this comment

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

Follow-up issue #10564

@MisRob
Copy link
Member Author

MisRob commented Apr 28, 2023

@jtamiace
Copy link
Member

jtamiace commented May 2, 2023

@MisRob for (1) and (3) the icons shifting around feels a bit unexpected and distracting. For (1), is it possible to make the spinner replace the location of the download icon so that either the loading spinner or the bookmark icon is showing but not both? So something like:

Screenshot 2023-05-02 at 2 37 03 PM

For how this adapts on mobile displays (2) and (3), I am not sure what technical solution makes sense, but here is an option that would require some different logic than full width displays but could eliminate the icon shifts. Keeping the download status outside of the menu seems like a nice way to communicate the system status:
Screenshot 2023-05-02 at 2 54 00 PM

^Although I guess disabling could also be used for the desktop view?

@MisRob
Copy link
Member Author

MisRob commented May 8, 2023

Thank you, @jtamiace, that's right. I used the "disabled" state for both mobile and desktop as it was a bit more straightforward to implement. Looking much better now:

recording-mobile

recording-desktop

@MisRob
Copy link
Member Author

MisRob commented May 8, 2023

Related learningequality/kolibri-design-system#433 has been merged and KDS reference in this PR updated to point to the latest KDS develop

@LianaHarris360
Copy link
Member

@MisRob For some resources the KCircularLoader seems to be continuous and is displayed before I have hit download. On other resources, it functions as expected.

InfiniteLoading.mov

@MisRob
Copy link
Member Author

MisRob commented May 9, 2023

@LianaHarris360 Ah, I should have mentioned this - resources with ids 2ea9bda8703241be89b5b9fd87f88815 and 9e53d545aaf44c3787a29a34b189c56a are currently hardcoded in useDownloadRequests so if you're seeing this behavior only for these two, that should be fine for now, because they're indefinitely being downloaded due to that mock. Did you observe it for any other resources (you could have a look in URL where a resource ID can be found and compare to those I mentioned)?

@LianaHarris360
Copy link
Member

Ok, this behavior does only happen for those two hardcoded resources, which makes complete sense. Thank you!

Copy link
Member

@marcellamaki marcellamaki left a comment

Choose a reason for hiding this comment

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

Thanks @MisRob - I've added just a couple of non-blocking comments from the code read through, but all can be discussed/addressed later. I also think it makes sense to have more robust manual QA happen here after I finish the non-mocked version of the content download request viewset work, so I think we're good to go with @LianaHarris360's manual QA and the QA team can pick up the testing once more of the backend is connected up (cc @radinamatic)

@@ -41,6 +41,8 @@ export function showTopicsContent(store, id, deviceId = null) {
if (deviceId) {
return setCurrentDevice(deviceId).then(device => {
const baseurl = device.base_url;
const { fetchUserDownloadRequests } = useDownloadRequests(store);
fetchUserDownloadRequests({ page: 1, pageSize: 100 });
Copy link
Member

Choose a reason for hiding this comment

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

Non-blocking, and can definitely be adjusted in follow up as needed, but do we want the default page size to be 100 here? That seems like a lot to me and like we want smaller pagination segments.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good point. I don't know if we'll use pagination parameters here on this page, but it's currently how fetchUserDownloadRequests is implemented so better to be ready for it. I will resolve it in a follow-up PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Follow-up PR #10683

<Transition name="downloading-loader">
<!--
wrapping span needed here because
(1) tooltip doesn't display when `ref` is on `KCircularLoader`
Copy link
Member

Choose a reason for hiding this comment

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

  1. tooltip doesn't display when ref is on `KCircularLoader

Today I learned!

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know if it's the case generally, it's possible that the new show prop I added to KCircularLoader plays a role in this but I didn't find time to investigate more closely. It's near the end of my TODOs list though :)

!this.$refs.timerButton.$el.contains(event.target) &&
!this.$refs.timer.$el.contains(event.target)
!this.$refs.timerButton?.$el.contains(event.target) &&
!this.$refs.timer?.$el.contains(event.target)
Copy link
Member

Choose a reason for hiding this comment

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

I am not clear on what this change, and the one above on line 500 and 501 is doing

Copy link
Member Author

Choose a reason for hiding this comment

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

That comes from this commit 5ae63b5. At some point, I noticed "Cannot read properties of undefined" console errors and found out it was caused by references not being present at the time of attempting to access them here in some situations. Most likely it was a little bug not directly related to the new code. I added safeguards to resolve that. If you were asking about the syntax, that's Optional chaining.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
APP: Learn Re: Learn App (content, quizzes, lessons, etc.) SIZE: large TODO: needs review Waiting for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants