Skip to content

feat: extend the account fields with the already existing extended_profile_fields #1193

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

Closed
wants to merge 16 commits into from

Conversation

bra-i-am
Copy link

@bra-i-am bra-i-am commented Feb 17, 2025

Description

This PR aims to allow the extension of the default account fields by using the extended_profile_fields feature with a custom form app like the example

Main changes

How Has This Been Tested?

  1. Init a Sumac environment
  2. Git clone and mount this MFE with tutor mounts add /path/to/cloned/mfe
  3. Git clone this custom form app which counts with checkbox, select and text fields
  4. Mount the custom form app with tutor mounts add lms:/path/to/cloned/custom-form-app:/openedx/extra-deps/custom-form-app and install it using tutor dev exec lms pip install -e ../extra-deps/custom-form-app
  5. Add the following env variables
    # lms.env.yml
    ADDL_INSTALLED_APPS:
      - "custom_reg_form"
    ENABLE_COMBINED_LOGIN_REGISTRATION: true
    REGISTRATION_EXTENSION_FORM: "custom_reg_form.forms.ExtraInfoForm"
    
    # cms.env.yml
    ENABLE_COMBINED_LOGIN_REGISTRATION: true
  6. Add the following settings to the Site Configurations > local.openedx.io:8000:
    {
          "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"
    ],
    }
  7. Run tutor dev restart
  8. When you go to your account (Account MFE), you'll be able to interact with the extended fields added through the custom form app

Screenshots/sandbox (optional):

image
image

@openedx-webhooks
Copy link

openedx-webhooks commented Feb 17, 2025

Thanks for the pull request, @bra-i-am!

This repository is currently maintained by @openedx/2u-infinity.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.


Where 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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Feb 17, 2025
@bra-i-am bra-i-am changed the title [WIP] feat: extend the account fields with the already existing extended_profile_fields feat: extend the account fields with the already existing extended_profile_fields Feb 17, 2025
@mphilbrick211 mphilbrick211 added the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Feb 19, 2025
Copy link

codecov bot commented Feb 21, 2025

Codecov Report

Attention: Patch coverage is 74.19355% with 24 lines in your changes missing coverage. Please review.

Project coverage is 60.31%. Comparing base (92b7c58) to head (78d4b73).
Report is 21 commits behind head on master.

Files with missing lines Patch % Lines
src/account-settings/data/service.js 0.00% 6 Missing ⚠️
src/account-settings/AccountSettingsPage.jsx 16.66% 5 Missing ⚠️
src/account-settings/EditableCheckboxField.jsx 82.75% 5 Missing ⚠️
src/account-settings/data/reducers.js 0.00% 4 Missing and 1 partial ⚠️
src/account-settings/EditableField.jsx 78.57% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1193      +/-   ##
==========================================
+ Coverage   58.55%   60.31%   +1.76%     
==========================================
  Files         119      121       +2     
  Lines        2413     2505      +92     
  Branches      665      692      +27     
==========================================
+ Hits         1413     1511      +98     
+ Misses        934      931       -3     
+ Partials       66       63       -3     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@e0d
Copy link

e0d commented Feb 21, 2025

@bra-i-am looks like this PR introduces some code coverage issues, can you please have a look?

@e0d e0d removed the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Feb 21, 2025
@bra-i-am bra-i-am force-pushed the bc/add-extended-profile-fields branch from 191fca6 to 9301a87 Compare February 25, 2025 00:07
@bra-i-am bra-i-am force-pushed the bc/add-extended-profile-fields branch from 97fba46 to 946eb1b Compare February 26, 2025 19:54
@bra-i-am
Copy link
Author

@e0d, I tried to cover all the code lines required to achieve the codecov check; there are some more warnings, but many are in lines so specific that I didn't get them with my changes.

Please let me know if covering the whole code is required or if having the codecov check is enough.

Thanks a lot! 🙏

@bra-i-am bra-i-am force-pushed the bc/add-extended-profile-fields branch from 946eb1b to e3f6977 Compare March 5, 2025 19:27
@bra-i-am bra-i-am force-pushed the bc/add-extended-profile-fields branch from e3f6977 to 9054b03 Compare April 21, 2025 19:34
@bra-i-am
Copy link
Author

@awais-ansari @sundasnoreen12, I hope you are doing great!

I've been considering that this merge request might encounter issues during the merge due to the incorporation of a new feature. However, I also believe it would serve as a good recovery from the features lost in the transition to the MFEs (I planted this solution motivated by https://discuss.openedx.org/t/custom-fields-in-profile-form/6116/2, indeed).

In any case, I'm waiting for your comments to plan how I could proceed. Beforehand, thank you so much for your time!


import messages from './AccountSettingsPage.messages';

const ExtendedProfileField = (props) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I not sure if this is necessary at the end is a wrapper, why not instead being a section in the account page (something like profile extra information or extension) or a subsection in the profile information section (as is shown in your implementation) that given the extended_profile information, render the corresponding fields?

Copy link
Author

@bra-i-am bra-i-am May 8, 2025

Choose a reason for hiding this comment

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

I made it only to avoid the component AccountSettingsPage from being bigger than it is at this moment. Additionally, maybe in the future we would add more field.type options, which could make the switch statement increase in size

Do you think it makes sense? :s

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that the AccountSettingsPage, should not be larger, and if you are going to make this a slot extension I think having a section that group all the logic is better, what that means:

<AccountSettingsPage>
   ....
   <ExtendedProfile extendedData={extendedFilds}>
   ....
</AccountSettingsPage>

And then inside the component make the map, validate the data type and return the components needed

@bra-i-am bra-i-am force-pushed the bc/add-extended-profile-fields branch from 0f16067 to b41b11e Compare May 8, 2025 21:52
@bra-i-am
Copy link
Author

bra-i-am commented May 26, 2025

@dcoa @awais-ansari @sundasnoreen12, I hope you are doing well

I'm closing this PR in favor of #1254, which creates a plugin slot to improve the handling of this

thanks ✨

@bra-i-am bra-i-am closed this May 26, 2025
@github-project-automation github-project-automation bot moved this from Waiting on Author to Done in Contributions May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants