From ca7bc7d35945c961a0bfec6b3d745bf8d98ef4a0 Mon Sep 17 00:00:00 2001 From: "Adolfo R. Brandes" Date: Wed, 14 Jun 2023 09:37:59 -0300 Subject: [PATCH] feat: Runtime config support, take 2 Adds a couple of missing features for proper runtime configuration: 1. Favicon runtime configuration support via react-helmet 2. Placeholder values for APP_ID and MFE_CONFIG_API_URL in the sample .env files --- .env | 2 ++ .env.development | 2 ++ .env.test | 2 ++ package-lock.json | 23 +++++++++++++++++++++++ package.json | 1 + public/index.html | 1 - src/index.jsx | 6 +++++- 7 files changed, 35 insertions(+), 2 deletions(-) diff --git a/.env b/.env index 17a9b2f..bab3125 100644 --- a/.env +++ b/.env @@ -19,3 +19,5 @@ SEGMENT_KEY='' SITE_NAME='' USER_INFO_COOKIE_NAME='' SCHEDULE_EMAIL_SECTION='' +APP_ID='' +MFE_CONFIG_API_URL='' diff --git a/.env.development b/.env.development index 4ddc0f9..680ab33 100644 --- a/.env.development +++ b/.env.development @@ -20,3 +20,5 @@ SEGMENT_KEY='' SITE_NAME=localhost USER_INFO_COOKIE_NAME='edx-user-info' SCHEDULE_EMAIL_SECTION='true' +APP_ID='' +MFE_CONFIG_API_URL='' diff --git a/.env.test b/.env.test index 84077a9..049d08a 100644 --- a/.env.test +++ b/.env.test @@ -18,3 +18,5 @@ SEGMENT_KEY='' SITE_NAME=localhost USER_INFO_COOKIE_NAME='edx-user-info' SCHEDULE_EMAIL_SECTION='true' +APP_ID='' +MFE_CONFIG_API_URL='' diff --git a/package-lock.json b/package-lock.json index 5699f4c..50ecab5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,6 +29,7 @@ "prop-types": "15.8.1", "react": "16.14.0", "react-dom": "16.14.0", + "react-helmet": "^6.1.0", "react-redux": "7.2.9", "react-router": "5.3.4", "react-router-dom": "5.3.4", @@ -21098,6 +21099,20 @@ } } }, + "node_modules/react-helmet": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/react-helmet/-/react-helmet-6.1.0.tgz", + "integrity": "sha512-4uMzEY9nlDlgxr61NL3XbKRy1hEkXmKNXhjbAIOVw5vcFrsdYbH2FEwcNyWvWinl103nXgzYNlns9ca+8kFiWw==", + "dependencies": { + "object-assign": "^4.1.1", + "prop-types": "^15.7.2", + "react-fast-compare": "^3.1.1", + "react-side-effect": "^2.1.0" + }, + "peerDependencies": { + "react": ">=16.3.0" + } + }, "node_modules/react-intl": { "version": "5.25.1", "resolved": "https://registry.npmjs.org/react-intl/-/react-intl-5.25.1.tgz", @@ -21316,6 +21331,14 @@ "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, + "node_modules/react-side-effect": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/react-side-effect/-/react-side-effect-2.1.2.tgz", + "integrity": "sha512-PVjOcvVOyIILrYoyGEpDN3vmYNLdy1CajSFNt4TDsVQC5KpTijDvWVoR+/7Rz2xT978D8/ZtFceXxzsPwZEDvw==", + "peerDependencies": { + "react": "^16.3.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/react-style-singleton": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/react-style-singleton/-/react-style-singleton-2.2.1.tgz", diff --git a/package.json b/package.json index b786a24..bce1101 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "prop-types": "15.8.1", "react": "16.14.0", "react-dom": "16.14.0", + "react-helmet": "^6.1.0", "react-redux": "7.2.9", "react-router": "5.3.4", "react-router-dom": "5.3.4", diff --git a/public/index.html b/public/index.html index e2dd3ec..9f6891a 100644 --- a/public/index.html +++ b/public/index.html @@ -4,7 +4,6 @@ Communications | <%= process.env.SITE_NAME %> -
diff --git a/src/index.jsx b/src/index.jsx index eecb393..be5fb1a 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -2,7 +2,7 @@ import 'core-js/stable'; import 'regenerator-runtime/runtime'; import { - APP_INIT_ERROR, APP_READY, subscribe, initialize, mergeConfig, + APP_INIT_ERROR, APP_READY, subscribe, initialize, mergeConfig, getConfig, } from '@edx/frontend-platform'; import { AppProvider, AuthenticatedPageRoute, ErrorPage } from '@edx/frontend-platform/react'; import ReactDOM from 'react-dom'; @@ -10,6 +10,7 @@ import ReactDOM from 'react-dom'; import { messages as headerMessages } from '@edx/frontend-component-header'; import { messages as footerMessages } from '@edx/frontend-component-footer'; import { messages as paragonMessages } from '@edx/paragon'; +import { Helmet } from 'react-helmet'; import { Switch } from 'react-router-dom'; import appMessages from './i18n'; @@ -20,6 +21,9 @@ import PageContainer from './components/page-container/PageContainer'; subscribe(APP_READY, () => { ReactDOM.render( + + +