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

MFE runtime configuration #103

Closed
6 tasks done
Tracked by #67 ...
dcoa opened this issue May 24, 2022 · 9 comments
Closed
6 tasks done
Tracked by #67 ...

MFE runtime configuration #103

dcoa opened this issue May 24, 2022 · 9 comments
Assignees
Labels
enhancement Relates to new features or improvements to existing features release blocker Blocks the upcoming release (fix needed)
Milestone

Comments

@dcoa
Copy link

dcoa commented May 24, 2022

Description

This is the first step of exploration to make MFE easy to configure from an instance.
And is part of a conversation that took place in the BTR WG reference here

You can check this document for a better context, and we appreciate your feedback.

Problem we try to hack

MFEs are only configured at build time. We need to be able to configure them at runtime to avoid needing a re-build for every MFE with every change in configuration.

How we can solve this
A proposal is to make a call API to set the configuration variables.

  1. In the MFE can set the environment variable MFE_CONFIG_API_URL, which is optional and people can choose if use the env file or call the API (setting the variable).

  2. The configuration could be set by site configuration in an object like this:

{
"MFE_CONFIG": {
        "SITE_NAME": "Test Site",
        "LOGO_URL": "https://testimage.com/logo.svg",
        "LOGO_TRADEMARK_URL": "https://testimage.com/logo.svg",
        "LOGO_WHITE_URL": "https://testimage.com/logo.svg",
        "FAVICON_URL": "https://testimage.com/favicon.ico",
        "CSRF_TOKEN_API_PATH": "/csrf/api/v1/token",
        "LANGUAGE_PREFERENCE_COOKIE_NAME": "openedx-language-preference",
        "LOGIN_URL": "http://testsite.example.com/login",
        "LOGOUT_URL": "http://testsite.example.com/logout",
        "STUDIO_BASE_URL": "http://studio.example.com",
        "MARKETING_SITE_BASE_URL": "http://testsite.example.com",
        "ORDER_HISTORY_URL": "http://testsite.example.com/orders",
        "REFRESH_ACCESS_TOKEN_ENDPOINT": "http://testsite.example.com/login_refresh",
    }
}

This object is read in the initialize function and if it's all okay, start the frontend application.

Pull request based on this proposal

  1. Frontend-Platform: Create a new function that is only activated if MFE_CONFIG_API_URL is set and make an API call to set the configuration variables.

  2. Edx-Platform: Create the API configuration service to read the site configuration and return the MFE_CONFIG.

  3. Enable runtime config in frontend-apps (favicon and title tag using Helmet and i18n):

  • Account (we want to open the discussion with one app and make the same changes eventually in the next ones) due to the new npm ci validation is necessary to upgrade tensorflow/tfjs-converter and tensorflow/tfjs-core
  • Learning due to new npm ci validation is necessary upgrade @edx/frontend-lib-special-exams
  • Profile
  • Gradebook

Pending MFEs

@dcoa dcoa changed the title MFE runtime configuration (proposal) MFE runtime configuration May 26, 2022
kdmccormick added a commit to kdmccormick/frontend-app-account that referenced this issue Aug 23, 2022
Recently, a capability was added to this MFE that allows it
to load configuration from an the LMS's MFE Config
API instead of requiring it to be baked-in to the webpack
build.

When enabled, though, this capability blocks any render
of the MFE until the Config API responds. So, in order to
minimize the amount of time that the MFE is waiting
on the Config API response, we preload the API
response via a in the section
of index.html, which recommends to the browser
to immediately begin loading the MFE Config API
response as soon as index.html is loaded. Otherwise,
the Config API wouldn't be called until React and
frontend-platform are loaded.
Recently, a capability was added to MFE that allows it
to load configuration from an LMS API (the "MFE Config
API") instead of requiring it to be baked-in to the webpack
build.

Related to:
* https://github.com/overhangio/2u-tutor-adoption/issues/87
* openedx/wg-frontend#103
@arbrandes arbrandes moved this to In review in Frontend Working Group Sep 30, 2022
@arbrandes
Copy link

@dcoa, is there any chance somebody on your team could add runtime configuration support to frontend-app-course-authoring and/or frontend-app-ora-grading in the next couple of weeks? These are the ones we're considering for Olive, but they're missing dynamic config support.

@dcoa
Copy link
Author

dcoa commented Nov 8, 2022

Hi, @arbrandes I'm working on ORA support, for course authoring frontend-platform is already in version > 2.5.0, and understanding this https://discuss.openedx.org/t/mfe-runtime-configuration/8495/14?u=dcoa runtime should be able to use.

@dcoa
Copy link
Author

dcoa commented Nov 8, 2022

This is ORA PR openedx/frontend-app-ora-grading#144

@arbrandes
Copy link

Thanks a bunch, @dcoa! Let's hope we get that one reviewed and merged in time. (The repo is not in the openedx org yet, unfortunately.)

@arbrandes
Copy link

@dcoa, it looks like frontend-app-discussions might make it in as well (they fixed the bugs). It's already on [email protected], but do you want to work your favicon magic as well?

@dcoa
Copy link
Author

dcoa commented Nov 12, 2022

I think for this case the same comment from the authing app https://discuss.openedx.org/t/mfe-runtime-configuration/8495/14?u=dcoa, if this change isn't mandatory, we can do it later.

arbrandes pushed a commit to openedx/frontend-app-learning that referenced this issue Nov 14, 2022
Allows frontend-app-learning to be configured at
runtime using the LMS's new MFE Configuration API.

Part of openedx/wg-frontend#103
arbrandes pushed a commit to openedx/frontend-app-gradebook that referenced this issue Nov 14, 2022
Allows frontend-app-gradebook to be configured at
runtime using the LMS's new MFE Configuration API.

Part of openedx/wg-frontend#103
@arbrandes
Copy link

@dcoa, mind taking a look at this one? We've identified a problem when getConfig() gets "cached" by the MFE and doesn't react to changes after being initially set.

Have you seen things like this in other MFEs?

arbrandes pushed a commit to openedx/frontend-app-profile that referenced this issue Nov 22, 2022
Allows frontend-app-profile to be configured at
runtime using the LMS's new MFE Configuration API.

Part of openedx/wg-frontend#103
@arbrandes
Copy link

Looks like we're good as far as all candidate MFEs for Olive are concerned! The last one was authn. Thanks for all the work here, so far!

@arbrandes arbrandes added enhancement Relates to new features or improvements to existing features release blocker Blocks the upcoming release (fix needed) labels Dec 6, 2022
@arbrandes
Copy link

Looks like we're done here, finally! @dcoa, congrats, and thanks for your patience in getting this through!! 🎉

Repository owner moved this from In review to Done in Build-Test-Release Working Group Dec 7, 2022
@arbrandes arbrandes moved this from In progress to Closed in Frontend Working Group Dec 7, 2022
dcoa added a commit to eduNEXT/frontend-app-learning that referenced this issue Jan 3, 2024
Allows frontend-app-learning to be configured at
runtime using the LMS's new MFE Configuration API.

Part of openedx/wg-frontend#103
dcoa added a commit to eduNEXT/frontend-app-learning that referenced this issue Jan 11, 2024
* feat: allow runtime configuration (openedx#955)

Allows frontend-app-learning to be configured at
runtime using the LMS's new MFE Configuration API.

Part of openedx/wg-frontend#103

* refactor: install alpha dependencies and update lint rules

* refactor: update code according with paragon alpha 22

* fix: test wasn't passing correctly

* chore: fix header alias

---------

Co-authored-by: bra-i-am <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Relates to new features or improvements to existing features release blocker Blocks the upcoming release (fix needed)
Projects
Status: Closed
Development

No branches or pull requests

2 participants