Skip to content

Conversation

bra-i-am
Copy link
Contributor

@bra-i-am bra-i-am commented May 23, 2025

Description

This PR creates a slot ExtendedProfileFieldsSlot and inserts it into AccountSettingPage.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

Before After
default_fields custom_fields

How Has This Been Tested?

In case you want to test my implementation, I'll leave you a little guide down below:

  1. Have a tutor environment (I used Tutor Main)

  2. 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 Account MFE

    from tutormfe.hooks import MFE_APPS
    
    @MFE_APPS.add()
    def _add_my_mfe(mfes):
    mfes["account"] = {
         "repository": "https://github.com/edunext/frontend-app-account.git",
         "port": 1997,
         "version": "bc/add-extra-fields-slot",
     }

    b. Another way we can do this in the queue is by tutor mounts add the MFE in our Tutor local env. To do this, we must:

    • Install the @edunext/frontend-component-extended-fields@latest package in our MFE Profile.

    • Create an env.config.jsx file in the root of the MFE with the following configuration:

      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_account_fields_slot: {
            plugins: [
              {
                op: PLUGIN_OPERATIONS.Insert,
                widget: {
                  id: 'extended_account_fields',
                  type: DIRECT_PLUGIN,
              RenderWidget: ExtendedProfileFields,
                },
              },
            ],
          },
        },
      };
      
      export default config;
  3. Create a tutor plugin and enable it:

    from tutormfe.hooks import PLUGIN_SLOTS
    from tutor import hooks
    
    hooks.Filters.ENV_PATCHES.add_item(
        (
            "mfe-dockerfile-post-npm-install",
            """
    # npm package
    RUN npm install '@edunext/frontend-component-extended-fields@latest'
    """,
        )
    )
    
    hooks.Filters.ENV_PATCHES.add_item(
        (
            "mfe-env-config-buildtime-imports",
            """
    import { ExtendedProfileFields } from '@edunext/frontend-component-extended-fields';
    """,
        )
    )
    
    PLUGIN_SLOTS.add_items(
        [
            (
                "account",
                "extended_account_fields_slot",
                """
            {
              op: PLUGIN_OPERATIONS.Insert,
              widget: {
                id: 'extended_account_fields',
    		    type: DIRECT_PLUGIN,
    		    RenderWidget: ExtendedProfileFields,
              },
            }""",
            ),
        ]
    )
  4. Run tutor images build mfe --no-cache

  5. Add this in the config.yml to add the custom form:

    OPENEDX_EXTRA_PIP_REQUIREMENTS:
    - git+https://github.com/bra-i-am/custom-form-app.git
  6. 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
  7. Run tutor images build openedx --no-cache

  8. Run tutor local start

  9. Add 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"
        ]
    }
  10. Run tutor local restart to update the settings

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label May 23, 2025
@openedx-webhooks
Copy link

openedx-webhooks commented May 23, 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.

@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions May 23, 2025
@bra-i-am bra-i-am changed the title feat: add ExtendedProfileFieldsSlot component and update AccountSetti… feat: add slot to extend the profile fields May 23, 2025
Copy link

codecov bot commented May 23, 2025

Codecov Report

❌ Patch coverage is 21.42857% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.93%. Comparing base (3394656) to head (32b63c2).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...lots/AdditionalProfileFieldsSlot/example/index.jsx 0.00% 20 Missing ⚠️
...plugin-slots/AdditionalProfileFieldsSlot/index.jsx 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1254      +/-   ##
==========================================
- Coverage   60.39%   59.93%   -0.47%     
==========================================
  Files         118      120       +2     
  Lines        2343     2371      +28     
  Branches      670      675       +5     
==========================================
+ Hits         1415     1421       +6     
- Misses        868      890      +22     
  Partials       60       60              

☔ 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.

@mphilbrick211 mphilbrick211 moved this from Needs Triage to In Eng Review in Contributions May 27, 2025
Copy link

@jignaciopm jignaciopm left a comment

Choose a reason for hiding this comment

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

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.

I only have a doubt if I need to add new extra fields I just have to add them here https://github.com/bra-i-am/custom-form-app/blob/master/custom_reg_form/forms.py and the https://www.npmjs.com/package/@edunext/frontend-component-extended-fields is in charge of doing the GET and rendering them

@bra-i-am
Copy link
Contributor Author

bra-i-am commented Jun 4, 2025

@jignaciopm, thank you so much for your review 🙏

I only have a doubt if I need to add new extra fields I just have to add them here https://github.com/bra-i-am/custom-form-app/blob/master/custom_reg_form/forms.py...

Yeah, that's how it works!

Just to clarify: in the forms.py you can modify the attributes of each field (restrictions, options, messages, etc.), but if you need to add a new field, you have to modify the models.py and apply migrations

Copy link

@Asespinel Asespinel left a comment

Choose a reason for hiding this comment

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

Everything looks good to me. The implementation is clean and follows the expected patterns to add a slot. No issues from my testing on my local env. Great work!

@dcoa dcoa requested a review from a team June 10, 2025 04:51
@felipemontoya
Copy link
Member

Hello @arbrandes and @brian-smith-tcril, I just tagged you in a related PR for the profile page that just as this has also been waiting for a review for a few Months.

This PR would be the other side of the coin, the extensibility to add components in the account page so that info is stored for the user can also be edited by the user.

As well as profile, this app has not received many UI slots yet. This slot would be closely aligned with the main reason of being for this MFE.

Copy link
Contributor

@brian-smith-tcril brian-smith-tcril left a comment

Choose a reason for hiding this comment

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

Thanks for this PR!

Overall this looks good! Left a few comments (most are quite similar to my comments here openedx/frontend-app-profile#1211 (review)).

Copy link
Contributor

@brian-smith-tcril brian-smith-tcril left a comment

Choose a reason for hiding this comment

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

Thank you so much for addressing my change requests!

It looks like this branch has some conflicts and tests didn't run. Would you be able to rebase it (I'm hoping that will also trigger a CI run)?

Once conflicts are resolved and CI is passing I'll be happy to approve/merge!

@@ -0,0 +1,87 @@
# Extended Profile Fields
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Extended Profile Fields
# Additional Profile Fields

@bra-i-am bra-i-am force-pushed the bc/add-extra-fields-slot branch from f579c34 to ff81465 Compare August 12, 2025 19:15
@bra-i-am
Copy link
Contributor Author

bra-i-am commented Aug 12, 2025

hey @brian-smith-tcril, thanks a lot for your review!! ✨
Sorry for the delayed response, but I was waiting to address all the comments and to solve the tests before leaving a comment

I remember you asked about why I located the AdditionalProfileFieldsSlot inside the Profile Information, and that's because I saw that place as the best for the final goal of this slot, which aims to extend specifically those fields that refer to users' information that came (and can be managed) from the registration form. Nevertheless, reading your recommendation, I found it convenient to create a new subsection Additional Information or something like that. What do you think? 🤔

image

On the other hand, I have a question: the coverage is failing because of the plugin slot and the example. Would I test those parts too? 🤔

Thanks for your help!

@brian-smith-tcril
Copy link
Contributor

I remember you asked about why I located the AdditionalProfileFieldsSlot inside the Profile Information, and that's because I saw that place as the best for the final goal of this slot, which aims to extend specifically those fields that refer to users' information that came (and can be managed) from the registration form.

I think moving away from using the extended_account_fields_slot alias (which didn't mention profile at all) clarified it for me. It makes sense to have the slot for adding additional fields to the profile section.

Nevertheless, reading your recommendation, I found it convenient to create a new subsection Additional Information or something like that. What do you think? 🤔

That could definitely be cool! I think that would be a nice thing to consider for a future PR, and we can keep this one focused on the "Profile Information" section.

@brian-smith-tcril
Copy link
Contributor

the coverage is failing because of the plugin slot and the example. Would I test those parts too? 🤔

It looks like the main issue is with the example file. I'm happy to merge this with that uncovered (most examples just live directly in the markdown and aren't covered).

@brian-smith-tcril brian-smith-tcril merged commit 587e3f2 into openedx:master Aug 13, 2025
6 of 8 checks passed
@github-project-automation github-project-automation bot moved this from In Eng Review to Done in Contributions Aug 13, 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.

7 participants