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

feat: whole course translations #1330

Merged
merged 17 commits into from
Mar 27, 2024
Merged

Conversation

leangseu-edx
Copy link
Contributor

@leangseu-edx leangseu-edx commented Mar 20, 2024

What changed:

  • implementation of whole course translation
  • use frontend plugin framework's pattern
  • NOTE: most of the existing code in src/ doesn't get much changed. The reason there were a lot of files was because I tried to fix the warning message during tests. It used to print way too many error and warning messages. It was too tedious to debug/write more tests. This doesn't remove all of the warning but it should take care of the common and unnecessary one.

Copy link

codecov bot commented Mar 20, 2024

Codecov Report

Attention: Patch coverage is 68.88889% with 14 lines in your changes are missing coverage. Please review.

Project coverage is 88.23%. Comparing base (3917262) to head (77fa47d).

❗ Current head 77fa47d differs from pull request most recent head c1879ea. Consider uploading reports for the commit c1879ea to get more accurate results

Files Patch % Lines
src/generic/plugin-store/hooks.js 0.00% 7 Missing and 1 partial ⚠️
src/generic/plugin-store/slice.js 42.85% 3 Missing and 1 partial ⚠️
src/courseware/course/sequence/Sequence.jsx 95.65% 1 Missing ⚠️
src/index.jsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1330      +/-   ##
==========================================
- Coverage   88.42%   88.23%   -0.20%     
==========================================
  Files         291      293       +2     
  Lines        4969     4988      +19     
  Branches     1263     1266       +3     
==========================================
+ Hits         4394     4401       +7     
- Misses        561      571      +10     
- Partials       14       16       +2     

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

@leangseu-edx leangseu-edx force-pushed the feat/whole-course-translations branch 2 times, most recently from 3ad314c to 77fa47d Compare March 20, 2024 18:29
Copy link
Member

@BrandonHBodine BrandonHBodine left a comment

Choose a reason for hiding this comment

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

Left a couple questions. Since it's top of mind for me; I noticed there's a conflict between paragon versions @edx/paragon and @openedx/paragon.

env.config.jsx Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@jsnwesson
Copy link

Solely inputting on the Plugin framework implementation: this looks good! The implementation looks good, including the env.config.jsx example (assuming that the actual file was intended to be .gitignored). If the limitation for gitignoring it is because the default content is living in env.config, would I be able to recommend that you try the @openedx/frontend-plugin-framework package?

The main change you'd see is that defaultContents wouldn't be defined in env.config.jsx, but instead you can leave the default component inside the PluginSlot wrapper (see README for setup).

What ends up taking the place of defaultContents is a boolean keepDefault that you can use to determine if you'd want to use the default component in your deploy.

Note: there is an intention to make the default content more easily customizable when several components are involved (as was the intended feature with defining the content in env.config) but that implementation shouldn't require a drastic change in the setup you have now.

@leangseu-edx
Copy link
Contributor Author

Solely inputting on the Plugin framework implementation: this looks good! The implementation looks good, including the env.config.jsx example (assuming that the actual file was intended to be .gitignored). If the limitation for gitignoring it is because the default content is living in env.config, would I be able to recommend that you try the @openedx/frontend-plugin-framework package?

The main change you'd see is that defaultContents wouldn't be defined in env.config.jsx, but instead you can leave the default component inside the PluginSlot wrapper (see README for setup).

What ends up taking the place of defaultContents is a boolean keepDefault that you can use to determine if you'd want to use the default component in your deploy.

Note: there is an intention to make the default content more easily customizable when several components are involved (as was the intended feature with defining the content in env.config) but that implementation shouldn't require a drastic change in the setup you have now.

So I added a pr to make the package build correctly openedx/frontend-plugin-framework#48. However, I still run into issue of unavailable context. When I used the transpiled code, the react component that replaced the slot lost the application context. I can't access application data.

Copy link
Contributor

@Rodra Rodra left a comment

Choose a reason for hiding this comment

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

Just one question, but apart from that this looks AWESOME

@leangseu-edx leangseu-edx force-pushed the feat/whole-course-translations branch from d2d1744 to fe6b041 Compare March 25, 2024 14:12
@Rodra Rodra force-pushed the feat/whole-course-translations branch from fe6b041 to 4feff37 Compare March 25, 2024 14:19
leangseu-edx and others added 10 commits March 27, 2024 13:27
chore: update tests so we have less error message

test: update test

* test: update tests

* chore: remove duplicate translation

* chore: lint for console

* chore: remove comments

* chore: make sure the affect url frame refresh after the language selection change
Add unit tests

Fix snapshot

Clean Sequence component logEvent calls

Clean unit test

Put feedback widget behind whole course translation flag

Fix useFeedbackWidget test
chore: update plugin instruction
Connect FeedbackWidget with backend services

Move feedback widget to unit translation plugin
chore: rewrite and test the api request

chore: rebase

chore: update translation feedback

chore: test

chore: add more tests
@leangseu-edx leangseu-edx force-pushed the feat/whole-course-translations branch from 69aef75 to c1879ea Compare March 27, 2024 17:32
@leangseu-edx leangseu-edx changed the title Feat/whole course translations feat: whole course translations Mar 27, 2024
@leangseu-edx leangseu-edx merged commit 36b3c36 into master Mar 27, 2024
5 checks passed
@leangseu-edx leangseu-edx deleted the feat/whole-course-translations branch March 27, 2024 17:39
Copy link

@arbrandes arbrandes left a comment

Choose a reason for hiding this comment

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

Can't thank you enough for adopting FPF and using it for AI translations, @leangseu-edx. Otherwise, beyond it being unfortunate that there are a lot of unrelated changes in this PR (I'd've preferred them in a separate one), there is a big stickler here: we can't have the plugin live in the repository itself. It'll have to be removed from master this week so that it doesn't land in Redwood.

There's also a specifc place (sequence-container) that will need to be converted to a slot. See comment.

</div>
{enableNewSidebar === 'true' ? <NewSidebar /> : <Sidebar />}
</div>
<div id="whole-course-translation-feedback-widget" />

Choose a reason for hiding this comment

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

We will likely have to convert sequence-container to a plugin slot so you can insert this div as part of the plugin. Thoughts?

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 was thinking of doing that as well. It require an extra fetch to the server for the same response. If that is a prefer way, I don't mind.

Copy link

@arbrandes arbrandes Apr 9, 2024

Choose a reason for hiding this comment

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

If a plugin needs to make extra requests, that is not only fine, but expected. I would avoid introducing extra requests to the default experience, though.

To be clear, all I mean to suggest is for sequence-container to either be wrapped in a <PluginSlot /> or contain one or more of them, not that it should become a plugin itself. In other words, what exists today should at most be "default content".

unitId: PropTypes.string.isRequired,
};

export default UnitTranslationPlugin;

Choose a reason for hiding this comment

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

We're going to have to move this plugin out of this repository in the next couple of weeks, before redwood.master is created.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I start the process for make a monorepo or do we have one already?

Choose a reason for hiding this comment

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

@leangseu-edx, this plugin can live anywhere at 2U's discretion, with one exception: it can't be in the openedx org. Otherwise, it's up to you folks whether it is even public.

@@ -0,0 +1,24 @@
import UnitTranslationPlugin from '@plugins/UnitTranslationPlugin';

Choose a reason for hiding this comment

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

It's great for documentation to have an example plugin defined, but it's unfortunate that we won't be able to leave it pointing to this particular plugin.

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 thought we would leave this as an example.

Choose a reason for hiding this comment

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

Sure, but let's at least make it clearly fictitious. Or even better, maybe make a skeleton sample plugin that lives in plugins, and point to that.

This is not the most urgent bit, though.

@@ -4,6 +4,7 @@
NODE_ENV='production'

ACCESS_TOKEN_COOKIE_NAME=''
AI_TRANSLATIONS_URL=''

Choose a reason for hiding this comment

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

We won't be able to leave this in master for much longer. See other comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can be move to env.config.js

Choose a reason for hiding this comment

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

To 2U's own version of it, yes, but preferably not the example one that lives in this repository.

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.

None yet

5 participants