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: allow runtime configuration #955

Merged
merged 6 commits into from
Oct 27, 2022

Conversation

dcoa
Copy link
Contributor

@dcoa dcoa commented Jul 13, 2022

Description

This PR is part of the work to make it possible to configure the frontend applications at runtime (you can referer to this openedx/wg-frontend#103).

Changes

  • Update frontend-platform to version 2.5.0
  • Update the footer and header to avoid peer dependency errors.
  • Change the favicon in runtime.
  • Update test according to i18n v5.

How to test

module.exports = {
    localModules: [
        { moduleName: '@edx/frontend-lib-special-exams', dir: '../frontend-lib-special-exams', dist: 'dist' },
    ],
};
  • The API should respond with a JSON with the config values, something like:
{
  "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",
}
  • The initialize process should work normally.
    Note: You can combine buildtime and runtime configuration

@openedx-webhooks
Copy link

Thanks for the pull request, @dcoa! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jul 13, 2022
@dcoa
Copy link
Contributor Author

dcoa commented Jul 15, 2022

Tests are failing because of a peer dependency error, to solve this is necessary an update of @edx/frontend-lib-special-exams (I create a PR there to upgrade frontend-platform openedx/frontend-lib-special-exams#70)

@natabene
Copy link

@dcoa Thank you for your contribution. Is this ready for our review?

@dcoa
Copy link
Contributor Author

dcoa commented Jul 22, 2022

Hi @natabene, yes it's able to start the review process.

@natabene natabene changed the title feat: allow runtieme configuration feat: allow runtime configuration Aug 18, 2022
@ghassanmas
Copy link
Member

@dcoa
I have tried is branch on nutmeg but I got an error and I also tried to rebuild again while using your change of special exam lib ref openedx/frontend-lib-special-exams/pull/70, same result:
Here is the error: (Note that the learning load norammly then it crashes and console show this error).

Error: Minified React error #321; visit https://reactjs.org/docs/error-decoder.html?invariant=321 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    at Y (react.production.min.js:20:384)
    at useMemo (react.production.min.js:23:164)
    at d (connectAdvanced.js:111:22)
    at Va (react-dom.production.min.js:153:146)
    at Ri (react-dom.production.min.js:175:309)
    at Ti (react-dom.production.min.js:175:139)
    at ki (react-dom.production.min.js:174:178)
    at bu (react-dom.production.min.js:268:238)
    at ds (react-dom.production.min.js:246:265)
    at fs (react-dom.production.min.js:246:194)

@itsjeyd
Copy link

itsjeyd commented Oct 12, 2022

Hi @dcoa! Just checking in to see where things are at with this PR :) Are you still interested in pursuing it?

@dcoa
Copy link
Contributor Author

dcoa commented Oct 12, 2022

Hi, @itsjeyd yes I'm still interested to make this PR merged.

@kdmccormick
Copy link
Member

@dcoa I'd love to merge this soon! Would you mind rebasing and seeing if you can get tests to pass?

@dcoa
Copy link
Contributor Author

dcoa commented Oct 12, 2022

Hi @ghassanmas
I'm not able to reproduce your error.

I test it in devstack using webpack local module to "install" @edx/frontend-lib-special-exams and works

image

@ghassanmas
Copy link
Member

ghassanmas commented Oct 12, 2022 via email

@dcoa
Copy link
Contributor Author

dcoa commented Oct 12, 2022

@dcoa I'd love to merge this soon! Would you mind rebasing and seeing if you can get tests to pass?

hi @kdmccormick I can't make test past until @edx/frontend-lib-special-exams is updated (this PR solves that openedx/frontend-lib-special-exams#70)

@dcoa
Copy link
Contributor Author

dcoa commented Oct 12, 2022

  • What are the node/npm version you are using

I'm using node v16.15.1 (npm v8.11.0)

@MaferMazu
Copy link

MaferMazu commented Oct 12, 2022

I tested it. I needed the fix in frontend-lib-special-exams, but It's working.

@ghassanmas
Copy link
Member

I tried this many many times in production mode with tutor but it I can't make it to work when using the speficed version of special-exam.

the way I installed your version is by changing the pacakge.json i.e. "@edx/frontend-lib-special-exams": "file:../frontend-lib-special-exams",.

The only case when this work is when I forced npm to ignore peer depedency error i.e. npm install --legacy-peer-deps (In this case I didn't use your version of special-exam).

So I guess the fail probably is not due to changes in this PR rather for frontend-lib-special-exams.

@kdmccormick
Copy link
Member

@dcoa frontend-lib-special-exams should be all set now!

@arbrandes arbrandes linked an issue Oct 20, 2022 that may be closed by this pull request
6 tasks
@hurtstotouchfire hurtstotouchfire requested review from Tj-Tracy and removed request for Tj-Tracy October 21, 2022 17:17
@kdmccormick
Copy link
Member

@dcoa now that frontend-lib-special-exams is all set, could you get this PR's test passing?

@dcoa dcoa force-pushed the dcoa/runtime-favicon-title branch from 5e9dcae to 29964ac Compare October 21, 2022 21:40
@dcoa
Copy link
Contributor Author

dcoa commented Oct 21, 2022

@kdmccormick I was working on that, and now all passed.

@codecov
Copy link

codecov bot commented Oct 21, 2022

Codecov Report

Base: 84.13% // Head: 84.13% // No change to project coverage 👍

Coverage data is based on head (acaa7ce) compared to base (759d154).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #955   +/-   ##
=======================================
  Coverage   84.13%   84.13%           
=======================================
  Files         264      264           
  Lines        4519     4519           
  Branches     1158     1158           
=======================================
  Hits         3802     3802           
  Misses        697      697           
  Partials       20       20           
Impacted Files Coverage Δ
...ourseware/course/sequence/content-lock/messages.js 100.00% <ø> (ø)
src/index.jsx 0.00% <ø> (ø)
src/alerts/course-start-alert/CourseStartAlert.jsx 100.00% <100.00%> (ø)
...ine-tab/alerts/course-end-alert/CourseEndAlert.jsx 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@dcoa dcoa force-pushed the dcoa/runtime-favicon-title branch from 29964ac to 351a096 Compare October 21, 2022 21:55
@kdmccormick
Copy link
Member

@dcoa @MaferMazu @ghassanmas Now that the special-exams PR is merged, could any you folks please confirm that this PR works as expected (using Tutor) and that the issues we saw before are resolved? Once that is confirmed, I am happy to merge this!

@ghassanmas
Copy link
Member

I have test this using tutor/olive in production: you can access it at: https://apps.olive.zaat.dev/learning/course/course-v1:zaatdev+101+1/home Note: this is not the official open testing instance

Copy link
Member

@kdmccormick kdmccormick 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 testing Ghassan!

Sorry @dcoa , one tiny thing I just noticed 😛 Otherwise this looks great.

@@ -32,7 +32,7 @@ describe('Sequence Content', () => {
expect(screen.queryByText('Loading locked content messaging...')).not.toBeInTheDocument();
expect(container.querySelector('svg')).toHaveClass('fa-lock');
expect(screen.getByText(
`You must complete the prerequisite: '${gatedContent.prereqSectionName}' to access this content.`,
`You must complete the prerequisite: ' ${gatedContent.prereqSectionName} ' to access this content.`,
Copy link
Member

Choose a reason for hiding this comment

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

Is this string change intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I did it intentionally because react-intl not rendering the single quotes but I found out the real fix here is adding another single quote like this formatjs/formatjs#3870

Thanks, @kdmccormick I'll fix it

@dcoa
Copy link
Contributor Author

dcoa commented Oct 25, 2022

Hi @kdmccormick I fix it, but codecov is failing and I am not sure why, seems like some messing configuration, may be re-running workflows this could be solved.

[2022-10-25T16:54:08.711Z] ['error'] There was an error running the uploader: Error uploading to [https://codecov.io:](https://codecov.io/) Error: There was an error fetching the storage URL during POST: 404 - {'detail': ErrorDetail(string='Unable to locate build via Github Actions API. Please upload with the Codecov repository upload token to resolve issue.', code='not_found')} Error: Codecov: Failed to properly upload: The process '/home/runner/work/_actions/codecov/codecov-action/v3/dist/codecov' failed with exit code 255

@zacharis278
Copy link
Contributor

Is this good to merge? I've got a special-exams lib release that can't be pulled in without this now that we've bumped the platform version in that lib to match this PR.

Copy link
Member

@kdmccormick kdmccormick 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 the nudge @zacharis278 , I didn't realize that codecov had finally passed.

Thanks again @dcoa !

@kdmccormick kdmccormick merged commit be72e36 into openedx:master Oct 27, 2022
@openedx-webhooks
Copy link

@dcoa 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@zacharis278
Copy link
Contributor

@kdmccormick looks like this PR is possibly causing failures in the edx.org deployment pipeline. Not sure where the issue lies yet, it's yelling about an old version of the footer component that isn't even in this package-lock.

npm ERR! Could not resolve dependency:
npm ERR! peer @edx/frontend-platform@"^1.15.2" from @edx/[email protected]
npm ERR! node_modules/@edx/frontend-component-footer
npm ERR!   @edx/frontend-component-footer@"npm:@edx/frontend-component-footer-edx@^3.1.3" from the root project

@dcoa
Copy link
Contributor Author

dcoa commented Oct 28, 2022

Hi @zacharis278 this occurred because footer component is overridden (using a npm package alias) with frontend-component-footer-edx (version 3.x only support frontend-platform 1.x) this could be solved using frontend-component-footer-edx in a version >= 4.1.0 edx/[email protected] (that support frontend-platform v2.x)

@zacharis278
Copy link
Contributor

Thank you! I didn't even realize there was a separate version of this component

arbrandes pushed a commit that referenced this pull request 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
dcoa added a commit to eduNEXT/frontend-app-learning that referenced this pull request 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 pull request 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
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

8 participants