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

Update navigateTo for non-custom HTML5 apps #8134

Merged
merged 3 commits into from
Jun 14, 2021

Conversation

marcellamaki
Copy link
Member

Summary

This PR creates a function for managing navigateTo events emitted from HTML5 apps but when they are used outside of a custom navigation context, such as if a user does not have access to these custom contexts but is still able to access the channel. There is a necessary parallel PR to update and KDS to add the corresponding listener on KContentRenderer that is required for this to work. I will add the PR link as a comment once I create the PR.

It also updates the navigateTo function for custom navigation contexts.

Note: The title in the content overlay in the custom channel view isn't updating and thought I've spent some time trying to troubleshoot it, I can't figure out why the value isn't updating. I'm hoping it's obvious that I am just overlooking and someone will have a simple suggestion 😄

Custom Nav Context
navigate-to-custom-context

"Regular" Context
navigate-to-regular-channel

Fixes #8098

Reviewer guidance

Before running devserver,
export KOLIBRI_CENTRAL_CONTENT_BASE_URL=https://hotfixes.studio.learningequality.org
and download the test channel using token favim-zinul. If you have already downloaded this channel, you will need to get the most recent changes to the channel, which now include using the navigateTo() hashi API function within part of the HTML5 app.

To test outside a custom context

  1. Navigate to Custom Nav channel
  2. Open "Interlinking Content Test"
  3. Click the link to the video
  4. You should be redirected to a content page with video content, and the URL should update

To test with a custom context

  1. To enable custom channels, in your terminal run export KOLIBRI_ENABLE_CUSTOM_CHANNEL_NAV=True
  2. Restart the dev server
  3. Navigate to Custom Nav channel
  4. Open "Interlinking Content Test"
  5. Click the link to the video
  6. The modal content should be replaced with the video content

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

@marcellamaki
Copy link
Member Author

Corresponding KDS PR

@marcellamaki marcellamaki requested a review from sairina June 2, 2021 14:33
return ContentNodeResource.fetchModel({ id })
.then(contentNode => {
let routeBase, path;
if (contentNode && contentNode.kind !== 'topic') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the contentNode.isLeaf field available from this endpoint? If so, this should also work:

Suggested change
if (contentNode && contentNode.kind !== 'topic') {
if (contentNode && contentNode.isLeaf) {

Copy link
Member

Choose a reason for hiding this comment

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

Yes, should be.

.then(contentNode => {
let routeBase, path;
if (contentNode && contentNode.kind !== 'topic') {
routeBase = '/topics/c';
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer to a route object here. this route is equivalent to { name: 'TOPICS_CONTENT' m ...}, I think (see the router file in the learn plugin).

Copy link
Contributor

@sairina sairina left a comment

Choose a reason for hiding this comment

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

Manual testing looks good

@@ -123,6 +123,9 @@
this.hashi.onStateUpdate(data => {
this.$emit('updateContentState', data);
});
this.hashi.on('navigateto', message => {
this.$emit('navigateToRegularContext', message);
Copy link
Member

Choose a reason for hiding this comment

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

I think just navigateTo seems fine here as an event - it's up to the context embedding the content renderer to decide what to do with that.

// in a custom context, within an overlay, switch the overlay
// content to the new content
this.overlayIsOpen = false;
console.log('new node', contentNode.title);
Copy link
Member

Choose a reason for hiding this comment

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

Stray log

@@ -193,8 +193,19 @@
routeBase = '/topics/t';
Copy link
Member

Choose a reason for hiding this comment

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

@jonboiser's suggestions about using is_leaf and a route object apply here too.

} else if (contentNode && this.overlayIsOpen == true) {
// in a custom context, within an overlay, switch the overlay
// content to the new content
this.overlayIsOpen = false;
Copy link
Member

Choose a reason for hiding this comment

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

Given that you are not waiting for $nextTick here, I'm not sure that setting false and then true on overlayIsOpen is doing anything. Better off ensuring the overlay renderer is properly reactive to changing its content node, which I think it probably is.

}
})
.catch(err => {
console.log(err);
Copy link
Member

Choose a reason for hiding this comment

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

Should use the standard API error handling logic here if there's an unexpected error.

@jonboiser jonboiser merged commit cf82939 into learningequality:develop Jun 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build on navigateTo() for hashi navigation between resources
4 participants