From 4c018bbae1532fdb1c68498699a56fa1cd343e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Tue, 16 Nov 2021 17:51:49 +0100 Subject: [PATCH] feat: upgrade to maple - Previously, it was not possible to make the MFEs use the themed logo from the LMS. This changed when this PR was merged: https://github.com/edx/edx-platform/pull/29503 In Maple, the /theming/asset/images/logo.png url now redirects to the themed logo. Close #25. - We disable New Relic globally by upgrading frontend-build for some packages. Close openedx/frontend-wg/issues/14 --- README.rst | 2 +- setup.py | 2 +- tutormfe/__about__.py | 2 +- tutormfe/patches/local-docker-compose-dev-services | 4 ++-- tutormfe/patches/openedx-lms-development-settings | 2 +- tutormfe/templates/mfe/build/mfe/Dockerfile | 9 +++++++-- tutormfe/templates/mfe/build/mfe/env/development | 4 ++-- tutormfe/templates/mfe/build/mfe/env/production | 7 ++++--- 8 files changed, 19 insertions(+), 13 deletions(-) diff --git a/README.rst b/README.rst index 9e2f3af..618a7c9 100644 --- a/README.rst +++ b/README.rst @@ -7,7 +7,7 @@ In addition, this plugin comes with a few MFEs which are enabled by default: - `Account `__ - `Gradebook `__ -- `Gradebook `__ +- `Learning `__ - `Profile `__ Instructions for using each of these MFEs are given below. diff --git a/setup.py b/setup.py index beabdcc..e4f9dc1 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,7 @@ def load_about(): packages=find_packages(exclude=["tests*"]), include_package_data=True, python_requires=">=3.5", - install_requires=["tutor>=12.0.0,<13.0.0"], + install_requires=["tutor>=13.0.0,<14.0.0"], entry_points={"tutor.plugin.v0": ["mfe = tutormfe.plugin"]}, classifiers=[ "Development Status :: 3 - Alpha", diff --git a/tutormfe/__about__.py b/tutormfe/__about__.py index 13b4a72..1311252 100644 --- a/tutormfe/__about__.py +++ b/tutormfe/__about__.py @@ -1 +1 @@ -__version__ = "12.1.0" +__version__ = "13.0.0" diff --git a/tutormfe/patches/local-docker-compose-dev-services b/tutormfe/patches/local-docker-compose-dev-services index 31266ff..73d6c3d 100644 --- a/tutormfe/patches/local-docker-compose-dev-services +++ b/tutormfe/patches/local-docker-compose-dev-services @@ -17,7 +17,7 @@ {%- for key, value in app.get("env", {}).get("production", {}).items() %} - "{{ key }}={{ value }}" {% endfor %} - {% for key, value in app.get("env", {}).get("development", {}).items() %} + {%- for key, value in app.get("env", {}).get("development", {}).items() %} - "{{ key }}={{ value }}" - {% endfor %} + {%- endfor %} {% endfor %} diff --git a/tutormfe/patches/openedx-lms-development-settings b/tutormfe/patches/openedx-lms-development-settings index e566cac..1941825 100644 --- a/tutormfe/patches/openedx-lms-development-settings +++ b/tutormfe/patches/openedx-lms-development-settings @@ -5,7 +5,7 @@ ACCOUNT_MICROFRONTEND_URL = "http://{{ MFE_HOST }}:{{ MFE_ACCOUNT_MFE_APP["port" WRITABLE_GRADEBOOK_URL = "http://{{ MFE_HOST }}:{{ MFE_GRADEBOOK_MFE_APP["port"] }}/{{ MFE_GRADEBOOK_MFE_APP["name"] }}" {% endif %} {% if MFE_LEARNING_MFE_APP %} -LEARNING_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}:{{ MFE_LEARNING_MFE_APP["port"] }}/{{ MFE_LEARNING_MFE_APP["name"] }}" +LEARNING_MICROFRONTEND_URL = "http://{{ MFE_HOST }}:{{ MFE_LEARNING_MFE_APP["port"] }}/{{ MFE_LEARNING_MFE_APP["name"] }}" {% endif %} {% if MFE_PROFILE_MFE_APP %} PROFILE_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}:{{ MFE_PROFILE_MFE_APP["port"] }}/{{ MFE_PROFILE_MFE_APP["name"] }}/u/" diff --git a/tutormfe/templates/mfe/build/mfe/Dockerfile b/tutormfe/templates/mfe/build/mfe/Dockerfile index 00c2662..acf768d 100644 --- a/tutormfe/templates/mfe/build/mfe/Dockerfile +++ b/tutormfe/templates/mfe/build/mfe/Dockerfile @@ -35,8 +35,13 @@ FROM base AS {{ app["name"] }}-dev COPY --from={{ app["name"] }}-src /openedx/app/package.json /openedx/app/package.json COPY --from={{ app["name"] }}-src /openedx/app/package-lock.json /openedx/app/package-lock.json ARG NPM_REGISTRY=https://registry.npmjs.org/ +# Install updated frontend-build to disable new relic, where possible +# https://github.com/edx/frontend-build/pull/215 +# This low-tech (i.e: ugly), manual patch should be removed in later versions +RUN sed -i "s/@edx\/frontend-build\": \"8.0.4\"/@edx\/frontend-build\": \"8.2.0\"/g" package.json {{ patch("mfe-dockerfile-pre-npm-install") }} -RUN npm install --no-audit --no-fund --registry=$NPM_REGISTRY && rm -rf ~/.npm +RUN npm install --no-audit --no-fund --registry=$NPM_REGISTRY \ + && rm -rf ~/.npm {{ patch("mfe-dockerfile-post-npm-install") }} COPY --from={{ app["name"] }}-src /openedx/app /openedx/app COPY --from={{ app["name"] }}-i18n /openedx/app/src/i18n/messages /openedx/app/src/i18n/messages @@ -48,7 +53,7 @@ FROM {{ app["name"] }}-dev AS {{ app["name"] }} COPY ./env/production /openedx/env/production RUN touch /openedx/env/production.override \ {%- for key, value in app.get("env", {}).get("production", {}).items() %} - && echo "{{ key }}={{ value }}" >> /openedx/env/production.override \ + && echo "{{ key }}='{{ value }}'" >> /openedx/env/production.override \ {%- endfor %} && echo "done setting production overrides" RUN bash -c "set -a && source /openedx/env/production && source /openedx/env/production.override && npm run build" diff --git a/tutormfe/templates/mfe/build/mfe/env/development b/tutormfe/templates/mfe/build/mfe/env/development index e8753d0..cb410af 100644 --- a/tutormfe/templates/mfe/build/mfe/env/development +++ b/tutormfe/templates/mfe/build/mfe/env/development @@ -1,8 +1,8 @@ DISCOVERY_API_BASE_URL='{% if DISCOVERY_HOST is defined %}http://{{ DISCOVERY_HOST }}:8381{% endif %}' LMS_BASE_URL='http://{{ LMS_HOST }}:8000' LOGIN_URL='http://{{ LMS_HOST }}:8000/login' -LOGO_URL='http://{{ LMS_HOST }}:8000/static/images/logo.png' -LOGO_TRADEMARK_URL='http://{{ LMS_HOST }}:8000/static/images/logo.png' +LOGO_URL='http://{{ LMS_HOST }}:8000/theming/asset/images/logo.png' +LOGO_TRADEMARK_URL='http://{{ LMS_HOST }}:8000/theming/asset/images/logo.png' LOGOUT_URL='http://{{ LMS_HOST }}:8000/logout' MARKETING_SITE_BASE_URL='http://{{ LMS_HOST }}:8000' NODE_ENV=development diff --git a/tutormfe/templates/mfe/build/mfe/env/production b/tutormfe/templates/mfe/build/mfe/env/production index 2033f13..74729ce 100644 --- a/tutormfe/templates/mfe/build/mfe/env/production +++ b/tutormfe/templates/mfe/build/mfe/env/production @@ -1,16 +1,17 @@ -{# https://edx.readthedocs.io/projects/edx-developer-docs/en/latest/developers_guide/micro_frontends_in_open_edx.html#configuration-with-environment-variables #} +{# https://edx.readthedocs.io/projects/edx-developer-docs/en/latest/micro_frontends/index.html#required-environment-variables #} ACCESS_TOKEN_COOKIE_NAME='edx-jwt-cookie-header-payload' BASE_URL='{{ MFE_HOST }}' CSRF_TOKEN_API_PATH='/csrf/api/v1/token' CREDENTIALS_BASE_URL='' DISCOVERY_API_BASE_URL='{% if DISCOVERY_HOST is defined %}{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ DISCOVERY_HOST }}{% endif %}' ECOMMERCE_BASE_URL='' +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 }}/static/images/logo.png' -LOGO_TRADEMARK_URL='{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/static/images/logo.png' +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' LOGO_WHITE_URL='' 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 }}'