-
Notifications
You must be signed in to change notification settings - Fork 80
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
feat: Send message after update tags on content [FC-0036] #800
feat: Send message after update tags on content [FC-0036] #800
Conversation
Thanks for the pull request, @ChrisChV! 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. |
Thanks for the pull request, @ChrisChV! 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. This is currently a draft pull request. When it is ready for our review and all tests are green, click "Ready for Review", or remove "WIP" from the title, as appropriate. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #800 +/- ##
=======================================
Coverage 89.28% 89.28%
=======================================
Files 551 551
Lines 9740 9744 +4
Branches 2101 2101
=======================================
+ Hits 8696 8700 +4
Misses 996 996
Partials 48 48 ☔ View full report in Codecov by Sentry. |
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! Great work @ChrisChV ! Just had 1 suggestion
- I tested this: (I testing by following the steps in the related edx-platform PR)
- 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'sconfiguration-secure
repository.
...data, | ||
}; | ||
window.top?.postMessage( | ||
`[Manage tags drawer] Tags updated: ${JSON.stringify(messageJson)}`, |
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 like this new message format, it might make sense to also change the closeManageTagsDrawer
message to match the same format to keep things consistent?
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 it would be better to add it when necessary, when it is used. Also, as Braden says, these messages are temporary.
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'm not sure why this message data is being passed as a string and then processed. You can simply pass JSON data. This is used in a couple of places and it generally follows the format of: window.top?.postMessage({ type: 'authoring.events.tags.updated', payload: data })
Then you can use code like this to handle it on the other side.
getConfig().STUDIO_BASE_URL, | ||
); | ||
}); | ||
getContentTaxonomyTagsCountData(contentId).then((data) => { |
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.
It would be simpler to just send a message that the count has changed, with only the contentId
and to let the parent frame call the API to retrieve the updated count if it wants to. That will keep the code here simpler. What do you think?
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 have also thought the same thing, but I feel that it is simpler to make and handle the API calls here and just send the data to be displayed in the template. Also I don't think there is much problem with the code here since it is temporary
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.
Yep, I just don't want people to copy this pattern when they move it into the MFE. If we just use React-Query in the MFE it will update without any special code, as long as we do the "query invalidation" correctly.
@@ -142,5 +144,30 @@ export const useContentTaxonomyTagsUpdater = (contentId, taxonomyId) => { | |||
onSettled: () => { | |||
queryClient.invalidateQueries({ queryKey: ['contentTaxonomyTags', contentId] }); | |||
}, | |||
onSuccess: () => { |
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 notification is just temporary. In the future, the course outline page and course unit page will be part of the frontend-app-course-authoring, so there will be no need to send a change notification nor to refresh the counts - React Query will handle that all automatically :)
So: I want to make sure everyone who sees this code understands that. Please add a comment that says something like "In the future, when the Course Outline Page and Unit Page are integrated into this MFE, they should just use React Query to load the tag counts, and React Query will automatically refresh those counts when the mutation invalidates them. So this postMessage is just a temporary feature to support the legacy Django template courseware page."
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.
Updated here: 78db929
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.
Nice, thanks!
@ChrisChV Can this PR merge before the edx-platform PR? |
@bradenmacdonald Yes, in this case the order does not matter. Nothing breaks |
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 code generally looks good, but I don't like the usage of postMessage
. You can send JSON data with postmessage, so I don't see a reason to mash it into a string and then use regex on the other side. These are messages that the user will not see so we can use something that's easier to parse.
...data, | ||
}; | ||
window.top?.postMessage( | ||
`[Manage tags drawer] Tags updated: ${JSON.stringify(messageJson)}`, |
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'm not sure why this message data is being passed as a string and then processed. You can simply pass JSON data. This is used in a couple of places and it generally follows the format of: window.top?.postMessage({ type: 'authoring.events.tags.updated', payload: data })
Then you can use code like this to handle it on the other side.
@xitij2000 Thanks for the review. Yes, you are right, I will make the changes |
@xitij2000 I made the changes on this commit: 2170664 Also I open this PR with edx-platform changes: openedx/edx-platform#34223 |
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 not working for me on tutor without changes described in openedx/edx-platform#34223
Once that is fixed, this is good to go.
Good news/bad news: With the major progress we're making lately on the MFE pages, and the plan to shift focus entirely to the MFEs for now, I think it may make more sense to pause this PR. If the outline/unit MFE pages don't end up being ready for Redwood, we can merge this, but it's looking pretty likely that those will be done by Redwood and we won't need this at all. |
Ok, make sense 👍 |
Closing this as we're focusing development on the MFE. |
@ChrisChV Even though your pull request wasn’t merged, please take a moment to answer a two question survey so we can improve your experience in the future. |
Description
Blocked: Check this #800 (comment)
This adds a feature to send tags of a content after the update mutation.
Supporting information
Internal ticket: FAL-3601
Github issue: openedx/modular-learning#167
Related PR: openedx/edx-platform#34059
Testing instructions