feat: add slot to extend the profile fields#1211
feat: add slot to extend the profile fields#1211brian-smith-tcril merged 15 commits intoopenedx:masterfrom
Conversation
|
Thanks for the pull request, @bra-i-am! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1211 +/- ##
=========================================
Coverage ? 81.49%
=========================================
Files ? 51
Lines ? 827
Branches ? 225
=========================================
Hits ? 674
Misses ? 146
Partials ? 7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jignaciopm
left a comment
There was a problem hiding this comment.
I was testing this PluginSlot, thanks to README It was easy. I like this kind of contributions.We need to expand our range of plugin slots and it is good to have this example base
Asespinel
left a comment
There was a problem hiding this comment.
Everything in the PR looks good to me overall. One suggestion: it might be better to update the plugin so that it only installs the form for the profile/account MFE. This would help keep things more scoped and prevent unnecessary installations. couldn't replicate the changes locally due to some environment configs not loading, but the logic looks solid.
I tested with this plugin and I could build the MFE images with no problems:
from tutormfe.hooks import PLUGIN_SLOTS
from tutor import hooks
hooks.Filters.ENV_PATCHES.add_item(
(
"mfe-dockerfile-post-npm-install-profile",
"""
# npm package
RUN npm install '@edunext/frontend-component-extended-fields@latest' --force
""",
)
)
hooks.Filters.ENV_PATCHES.add_item(
(
"mfe-dockerfile-post-npm-install-account",
"""
# npm package
RUN npm install '@edunext/frontend-component-extended-fields@latest' --force
""",
)
)
hooks.Filters.ENV_PATCHES.add_item(
(
"mfe-env-config-buildtime-imports-profile",
"""
import { ExtendedProfileFields } from '@edunext/frontend-component-extended-fields';
""",
)
)
hooks.Filters.ENV_PATCHES.add_item(
(
"mfe-env-config-buildtime-imports-account",
"""
import { ExtendedProfileFields } from '@edunext/frontend-component-extended-fields';
""",
)
)
PLUGIN_SLOTS.add_items(
[
(
"profile",
"extended_profile_fields_slot",
"""
{
op: PLUGIN_OPERATIONS.Insert,
widget: {
id: 'extended_profile_fields',
type: DIRECT_PLUGIN,
RenderWidget: ExtendedProfileFields,
},
}""",
),
]
)|
I want to take this opportunity to mention a few things in the steps to test this development: There is no mention of the use of this branch in our Local TutorAdd the next script to tutor plugin to override the branch of Profle MFE from tutormfe.hooks import MFE_APPS
@MFE_APPS.add()
def _add_my_mfe(mfes):
mfes["profile"] = {
"repository": "https://github.com/edunext/frontend-app-profile.git",
"port": 1995,
"version": "bc/add-extra-fields-slot",
}Another way we can do this in the queue is by using
import { PLUGIN_OPERATIONS, DIRECT_PLUGIN } from '@openedx/frontend-plugin-framework';
import { ExtendedProfileFields } from '@edunext/frontend-component-extended-fields';
// Load environment variables from .env file
const config = {
...process.env,
pluginSlots: {
extended_profile_fields_slot: {
plugins: [
{
op: PLUGIN_OPERATIONS.Insert,
widget: {
id: 'extended_profile_fields',
type: DIRECT_PLUGIN,
RenderWidget: ExtendedProfileFields,
},
},
],
},
},
};
export default config;Problem with backend to update valuesI think this problem is not associate with this PR, but maybe we have to mention this in troubleshooting section Install dependency only in Profile and Account MFEWhat Andres mentions is important, we don't have to install Finally @bra-i-am I don't see anything about the PR of |
|
@Asespinel, thank you for your review. I'll be working on the change of the plugin you mentioned! I hope the issue is gone, and you can test it properly. Please let me know any other comments/questions you have ✨ |
|
@jignaciopm, thank you again for your review 🙏✨
You're right, I forgot to mention that really important thing... with your permission, I'll paste the steps you give in the cover letter of this PR 😅
I already reviewed this: it was an error with the handling I was doing in the
Yees, you are right... I'll be checking this out
Honestly, I didn't create any PR for those things... but the repositories are not too big, so if you take a look at them, it would be great! |
4900dd4 to
7d59b6c
Compare
7d59b6c to
a622578
Compare
|
Hello @arbrandes or @brian-smith-tcril, this PR has been waiting for quite a while for a review from infinity. I'm escalating this to the people I know. The PR is basic in essence. We are adding a UISlot so that it is possible to extend the profile page by adding new fields in this space. This app has not received many UI slots yet, we believe this is the next most necessary one. Also the NAU project is very keen on using this for their install. |
brian-smith-tcril
left a comment
There was a problem hiding this comment.
Overall I'm in favor of adding this functionality via a slot.
I left a few comments with specific questions/suggestions.
Thanks for this PR! Let me know if you have any questions/need anything from me!
…and documentation
dd11ffd to
40f3dc4
Compare
brian-smith-tcril
left a comment
There was a problem hiding this comment.
This is looking great!
One last comment about the div being added to wrap the slot, but once we figure out a good way to handle that this should be good to go!
src/profile/ProfilePage.jsx
Outdated
| /> | ||
| )} | ||
|
|
||
| <div className="pt-40px"> |
|
@brian-smith-tcril, thank you so much for your feedback! 🫶 I applied this setting directly in the AdditionalProfileFields implementation to avoid creating unnecessary conditionals in both the ProfilePage and the Slot files Please let me know your thoughts, and thanks again |
brian-smith-tcril
left a comment
There was a problem hiding this comment.
LGTM!
Thanks for your patience throughout the review process!
* feat: add extended profile fields functionality with context and form components * refactor: replace string literals with FORM_MODE constants in profile fields components * feat: implement BaseField component and refactor field elements to use it * chore: remove unused webpack development configuration file * feat: refactor extended profile fields implementation and remove unused components * feat: update dependencies for frontend-plugin-framework and remove unused dompurify * refactor: simplify pluginProps structure in ExtendedProfileFieldsSlot component * feat: add README and example images for Extended Profile Fields slot * refactor: improve performance & keep consistency * feat: add Additional Profile Fields slot with example implementation and documentation * feat: update custom fields image for Additional Profile Fields slot * fix: reorder import of AdditionalProfileFieldsSlot for consistency * test: fix snapshot * fix: adjust margin in example to avoid oddities on mobile * fix: remove unnecessary empty divs from ProfilePage snapshots
* feat: add extended profile fields functionality with context and form components * refactor: replace string literals with FORM_MODE constants in profile fields components * feat: implement BaseField component and refactor field elements to use it * chore: remove unused webpack development configuration file * feat: refactor extended profile fields implementation and remove unused components * feat: update dependencies for frontend-plugin-framework and remove unused dompurify * refactor: simplify pluginProps structure in ExtendedProfileFieldsSlot component * feat: add README and example images for Extended Profile Fields slot * refactor: improve performance & keep consistency * feat: add Additional Profile Fields slot with example implementation and documentation * feat: update custom fields image for Additional Profile Fields slot * fix: reorder import of AdditionalProfileFieldsSlot for consistency * test: fix snapshot * fix: adjust margin in example to avoid oddities on mobile * fix: remove unnecessary empty divs from ProfilePage snapshots



Description
This PR creates a slot
ExtendedProfileFieldsSlotand inserts it intoProfilePage.jsx. The main goal of this change is to allow the extension of the profile fields.This use case is required by NAU and can be validated by @igobranco
Screenshots
How Has This Been Tested?
In case you want to test my implementation, I'll leave you a little guide down below:
Have a tutor environment (I used
Tutor Main)You have to mount this MFE on the branch of this PR so you can use the slot:
a. Add this script to the following tutor plugin to override the branch of
Profle MFEb. Another way we can do this in the queue is by
tutor mounts addthe MFE in our Tutor local env. To do this, we must:Install the
@edunext/frontend-component-extended-fields@latestpackage in our MFE Profile.Create an
env.config.jsxfile in the root of the MFE with the following configuration:Create a tutor plugin and enable it:
Run
tutor images build mfe --no-cacheAdd this in the
config.ymlto add the custom form:Add the following env variables
Run
tutor images build openedx --no-cacheRun
tutor local startAdd the following settings to the
Site Configurations > local.openedx.io:{ "ENABLE_PROFILE_MICROFRONTEND": "true", "ENABLE_DYNAMIC_REGISTRATION_FIELDS": "true", "MFE_CONFIG": { "ENABLE_DYNAMIC_REGISTRATION_FIELDS": "true" }, "REGISTRATION_EXTRA_FIELDS": { "employment_situation": "required", "data_authorization": "required", "allow_newsletter": "required", "terms_of_service": "hidden", "honor_code": "hidden", "full_name": "required", "bio": "required", "wants_newsletter": "required", "favorite_language": "required", "password_hint": "required", "terms_accepted": "required" }, "extended_profile_fields": [ "data_authorization", "full_name", "bio", "wants_newsletter", "favorite_language", "password_hint", "terms_accepted" ] }Run
tutor local restartto update the settings