From 2bff31b5b5dac5b5e39a1511e64042186bf9d34f Mon Sep 17 00:00:00 2001 From: Ghassan Maslamani Date: Wed, 9 Nov 2022 21:28:17 +0200 Subject: [PATCH] squash: reponse to PR review _only minor issues resolved_ --- .../patches/openedx-lms-development-settings | 37 +++++++++++++++++++ .../patches/openedx-lms-production-settings | 8 ++-- tutormfe/plugin.py | 18 --------- tutormfe/templates/mfe/build/mfe/Dockerfile | 3 +- 4 files changed, 43 insertions(+), 23 deletions(-) diff --git a/tutormfe/patches/openedx-lms-development-settings b/tutormfe/patches/openedx-lms-development-settings index 19418256..bad6af20 100644 --- a/tutormfe/patches/openedx-lms-development-settings +++ b/tutormfe/patches/openedx-lms-development-settings @@ -17,3 +17,40 @@ CORS_ORIGIN_WHITELIST.append("http://{{ MFE_HOST }}:{{ app["port"] }}") LOGIN_REDIRECT_WHITELIST.append("{{ MFE_HOST }}:{{ app["port"] }}") CSRF_TRUSTED_ORIGINS.append("{{ MFE_HOST }}:{{ app["port"] }}") {% endfor %} + +# Start of Dynamic config API settings + +ENABLE_MFE_CONFIG_API = True + +MFE_CONFIG = { + "BASE_URL": "{{ MFE_HOST }}", + "CREDENTIALS_BASE_URL": "/csrf/api/v1/token", + "DISCOVERY_API_BASE_UR": "{% if DISCOVERY_HOST is defined %}{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ DISCOVERY_HOST }}{% endif %}", + "ENABLE_NEW_RELIC": False, + "FAVICON_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/favicon.ico", + "LANGUAGE_PREFERENCE_COOKIE_NAME": "openedx-language-preference", + "LMS_BASE_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}", + "LOGIN_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/login", + "LOGO_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/theming/asset/images/logo.png", + "LOGO_TRADEMARK_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/theming/asset/images/logo.png", + "LOGOUT_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/logout", + "MARKETING_SITE_BASE_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}", + "REFRESH_ACCESS_TOKEN_ENDPOINT": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/login_refresh", + "SITE_NAME": "{{ PLATFORM_NAME }}", + "STUDIO_BASE_URL": "{{ "https" if ENABLE_HTTPS else "http" }}://{{ CMS_HOST }}", + "USER_INFO_COOKIE_NAME": "user-info" +} + + +MFE_CONFIG_OVERRIDES = { +{% for app in iter_values_named(suffix="MFE_APP") %} +"{{ app['name'] }}": { +{%- for key, value in app.get("env", {}).get("development", {}).items() %} + + "{{ key }}": "{{ value }}", + +{%- endfor %} +}, +{% endfor %} +} +# Ends Dynamic config API settings diff --git a/tutormfe/patches/openedx-lms-production-settings b/tutormfe/patches/openedx-lms-production-settings index 685827e7..a441f2dd 100644 --- a/tutormfe/patches/openedx-lms-production-settings +++ b/tutormfe/patches/openedx-lms-production-settings @@ -15,11 +15,11 @@ LOGIN_REDIRECT_WHITELIST.append("{{ MFE_HOST }}") CORS_ORIGIN_WHITELIST.append("{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}") CSRF_TRUSTED_ORIGINS.append("{{ MFE_HOST }}") -# Starts of Dynamic config API settings +ALLOWED_HOSTS.append("{{ MFE_HOST }}") -ENABLE_MFE_CONFIG_API = True +# Start of Dynamic config API settings -ALLOWED_HOSTS.append("{{ MFE_HOST }}") +ENABLE_MFE_CONFIG_API = True MFE_CONFIG = { "BASE_URL": "{{ MFE_HOST }}", @@ -43,7 +43,7 @@ MFE_CONFIG = { MFE_CONFIG_OVERRIDES = { {% for app in iter_values_named(suffix="MFE_APP") %} -"{{app.get('name')}}": { +"{{ app['name'] }}": { {%- for key, value in app.get("env", {}).get("production", {}).items() %} "{{ key }}": "{{ value }}", diff --git a/tutormfe/plugin.py b/tutormfe/plugin.py index e34fb8ed..d7626904 100644 --- a/tutormfe/plugin.py +++ b/tutormfe/plugin.py @@ -17,33 +17,16 @@ "name": "account", "repository": "https://github.com/edx/frontend-app-account", "port": 1997, - "env": { - "production": { - "COACHING_ENABLED": "", - "ENABLE_DEMOGRAPHICS_COLLECTION": "", - "APP_ID":"account", - }, - }, }, "GRADEBOOK_MFE_APP": { "name": "gradebook", "repository": "https://github.com/edx/frontend-app-gradebook", "port": 1994, - "env":{ - "production":{ - "APP_ID": "gradebook", - }, - }, }, "LEARNING_MFE_APP": { "name": "learning", "repository": "https://github.com/edx/frontend-app-learning", "port": 2000, - "env":{ - "production":{ - "APP_ID": "learning", - }, - }, }, "PROFILE_MFE_APP": { "name": "profile", @@ -52,7 +35,6 @@ "env": { "production": { "ENABLE_LEARNER_RECORD_MFE": "true", - "APP_ID": "profile", }, }, }, diff --git a/tutormfe/templates/mfe/build/mfe/Dockerfile b/tutormfe/templates/mfe/build/mfe/Dockerfile index e10ec150..74555f66 100644 --- a/tutormfe/templates/mfe/build/mfe/Dockerfile +++ b/tutormfe/templates/mfe/build/mfe/Dockerfile @@ -53,6 +53,7 @@ COPY --from={{ app["name"] }}-src /openedx/app /openedx/app COPY --from={{ app["name"] }}-i18n /openedx/app/src/i18n/messages /openedx/app/src/i18n/messages ENV PUBLIC_PATH='/{{ app["name"] }}/' EXPOSE {{ app['port'] }} +ENV APP_ID={{ app["name"] }} COPY ./env/production /openedx/env/production {%- set overrides = app.get("env", {}).get("production", {}) %} @@ -78,7 +79,7 @@ RUN echo "setting development overrides..." \ CMD ["/bin/bash", "-c", "set -a && \ source /openedx/env/production && \ source /openedx/env/development && \ - npm run start --- --config ./webpack.dev-tutor.config.js"] + APP_ID={{ app["name"] }} npm run start --- --config ./webpack.dev-tutor.config.js"] {% endfor %} # Production images are last to accelerate dev image building