From 0ed58010f1a7b8fba99a5d34cf21df320565a060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Wed, 6 Dec 2023 17:42:34 +0100 Subject: [PATCH 1/3] chore: remove deprecated settings ECOMMERCE_MFE_APP and ECOMMERCE_PAYMENT_MFE_APP where obsolete since Palm. --- .../patches/openedx-lms-development-settings | 6 ++++- .../patches/openedx-lms-production-settings | 2 +- tutorecommerce/plugin.py | 23 ------------------- .../apps/ecommerce/settings/development.py | 14 +++++++---- .../templates/ecommerce/tasks/ecommerce/init | 8 +++++-- 5 files changed, 21 insertions(+), 32 deletions(-) diff --git a/tutorecommerce/patches/openedx-lms-development-settings b/tutorecommerce/patches/openedx-lms-development-settings index 9f38689e..4079bfcd 100644 --- a/tutorecommerce/patches/openedx-lms-development-settings +++ b/tutorecommerce/patches/openedx-lms-development-settings @@ -1,6 +1,10 @@ # Ecommerce +{% for app_name, app in iter_mfes() %} +{% if app_name == "orders" %} ECOMMERCE_PUBLIC_URL_ROOT = "http://{{ ECOMMERCE_HOST }}:8130" ECOMMERCE_API_URL = ECOMMERCE_PUBLIC_URL_ROOT + "/api/v2" -ORDER_HISTORY_MICROFRONTEND_URL = "http://{{ MFE_HOST }}:{{ ECOMMERCE_MFE_APP['port'] }}/{{ ECOMMERCE_MFE_APP['name'] }}/orders" +ORDER_HISTORY_MICROFRONTEND_URL = "http://{{ MFE_HOST }}:{{ app['port'] }}/{{ app_name }}/orders" MFE_CONFIG["ECOMMERCE_BASE_URL"] = ECOMMERCE_PUBLIC_URL_ROOT MFE_CONFIG["ORDER_HISTORY_URL"] = ORDER_HISTORY_MICROFRONTEND_URL +{% endif %} +{% endfor %} diff --git a/tutorecommerce/patches/openedx-lms-production-settings b/tutorecommerce/patches/openedx-lms-production-settings index 36eb632a..61116c6e 100644 --- a/tutorecommerce/patches/openedx-lms-production-settings +++ b/tutorecommerce/patches/openedx-lms-production-settings @@ -1,6 +1,6 @@ # Ecommerce ECOMMERCE_PUBLIC_URL_ROOT = "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ ECOMMERCE_HOST }}" ECOMMERCE_API_URL = ECOMMERCE_PUBLIC_URL_ROOT + "/api/v2" -ORDER_HISTORY_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ MFE_HOST }}/{{ ECOMMERCE_MFE_APP['name'] }}/orders" +ORDER_HISTORY_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ MFE_HOST }}/orders/orders" MFE_CONFIG["ECOMMERCE_BASE_URL"] = ECOMMERCE_PUBLIC_URL_ROOT MFE_CONFIG["ORDER_HISTORY_URL"] = ORDER_HISTORY_MICROFRONTEND_URL diff --git a/tutorecommerce/plugin.py b/tutorecommerce/plugin.py index a8d0cedf..989858fb 100644 --- a/tutorecommerce/plugin.py +++ b/tutorecommerce/plugin.py @@ -31,29 +31,6 @@ "OAUTH2_KEY_SSO": "ecommerce-sso", "OAUTH2_KEY_SSO_DEV": "ecommerce-sso-dev", "WORKER_JWT_ISSUER": "ecommerce-worker", # TODO do we need to keep this? - # Micro frontend applications - "MFE_APP": { - "name": "orders", - "repository": "https://github.com/edx/frontend-app-ecommerce", - "port": 1996, - }, - "PAYMENT_MFE_APP": { - "name": "payment", - "repository": "https://github.com/edx/frontend-app-payment", - "port": 1998, - "env": { - "production": { - # Hardcoded in edx-platform - "CURRENCY_COOKIE_NAME": "edx-price-l10n", - # TODO set customizable value - "CYBERSOURCE_URL": "https://testsecureacceptance.cybersource.com/silent/pay", - "SUPPORT_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/support", - }, - "development": { - "SUPPORT_URL": "http://{{ LMS_HOST }}:8000/support", - }, - }, - }, }, "unique": { "MYSQL_PASSWORD": "{{ 8|random_string }}", diff --git a/tutorecommerce/templates/ecommerce/apps/ecommerce/settings/development.py b/tutorecommerce/templates/ecommerce/apps/ecommerce/settings/development.py index bf5a0cfa..30542e10 100644 --- a/tutorecommerce/templates/ecommerce/apps/ecommerce/settings/development.py +++ b/tutorecommerce/templates/ecommerce/apps/ecommerce/settings/development.py @@ -2,11 +2,15 @@ {% include "ecommerce/apps/ecommerce/settings/partials/common.py" %} -CORS_ORIGIN_WHITELIST = list(CORS_ORIGIN_WHITELIST) + [ - "http://{{ MFE_HOST }}:{{ ECOMMERCE_MFE_APP['port'] }}", - "http://{{ MFE_HOST }}:{{ ECOMMERCE_PAYMENT_MFE_APP['port'] }}", -] -CSRF_TRUSTED_ORIGINS = ["{{ MFE_HOST }}:{{ ECOMMERCE_MFE_APP['port'] }}"] +CORS_ORIGIN_WHITELIST = list(CORS_ORIGIN_WHITELIST) +{% for app_name, app in iter_mfes() %} +{% if app_name == "orders" %} +CORS_ORIGIN_WHITELIST.append("http://{{ MFE_HOST }}:{{ app['port'] }}") +CSRF_TRUSTED_ORIGINS = ["{{ MFE_HOST }}:{{ app['port'] }}"] +{% elif app_name == "payment" %} +CORS_ORIGIN_WHITELIST.append("http://{{ MFE_HOST }}:{{ app['port'] }}") +{% endif %} +{% endfor %} SOCIAL_AUTH_EDX_OAUTH2_PUBLIC_URL_ROOT = "http://{{ LMS_HOST }}:8000" diff --git a/tutorecommerce/templates/ecommerce/tasks/ecommerce/init b/tutorecommerce/templates/ecommerce/tasks/ecommerce/init index 7de70b11..9219b9a3 100644 --- a/tutorecommerce/templates/ecommerce/tasks/ecommerce/init +++ b/tutorecommerce/templates/ecommerce/tasks/ecommerce/init @@ -1,6 +1,8 @@ ./manage.py migrate --noinput ./manage.py oscar_populate_countries --initial-only +{% for app in iter_mfes() %} +{% if app["name"] == "payment" %} ./manage.py create_or_update_site \ --site-id=1 \ --site-domain={{ ECOMMERCE_HOST }}:8130 \ @@ -19,7 +21,7 @@ --payment-support-url="http://{{ LMS_HOST }}:8000/support" \ --discovery_api_url=http://{{ DISCOVERY_HOST }}:8381/api/v1/ \ --enable-microfrontend-for-basket-page=true \ - --payment-microfrontend-url="http://{{ MFE_HOST }}:{{ ECOMMERCE_PAYMENT_MFE_APP['port'] }}/{{ ECOMMERCE_PAYMENT_MFE_APP['name'] }}" + --payment-microfrontend-url="http://{{ MFE_HOST }}:{{ app['port'] }}/{{ app['name'] }}" # Production site ./manage.py create_or_update_site \ @@ -41,7 +43,9 @@ --payment-support-url="{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/support" \ --discovery_api_url={% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ DISCOVERY_HOST }}/api/v1/ \ --enable-microfrontend-for-basket-page=true \ - --payment-microfrontend-url="{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ MFE_HOST }}/{{ ECOMMERCE_PAYMENT_MFE_APP['name'] }}" + --payment-microfrontend-url="{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ MFE_HOST }}/{{ app['name'] }}" +{% endif %} +{% endfor %} if [ ! -e /openedx/ecommerce/node_modules ] then From ccd2beedf05dd1f9b94b4940ea464d1de35f31fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Wed, 6 Dec 2023 17:46:05 +0100 Subject: [PATCH 2/3] fix: orders clashes with learner dashboard port The learner dashboard that was enabled in nightly also uses port 1996. This causes a conflict, that we resolve by switching the orders port to 7296. Close #56 --- changelog.d/20231206_174503_regis_orders_port.md | 1 + tutorecommerce/plugin.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog.d/20231206_174503_regis_orders_port.md diff --git a/changelog.d/20231206_174503_regis_orders_port.md b/changelog.d/20231206_174503_regis_orders_port.md new file mode 100644 index 00000000..9b1d3e44 --- /dev/null +++ b/changelog.d/20231206_174503_regis_orders_port.md @@ -0,0 +1 @@ +- [Bugfix] Switch ecommerce MFE port from 1996 to 7296, as it clashes with the new learner dashboard. (by @regisb) diff --git a/tutorecommerce/plugin.py b/tutorecommerce/plugin.py index 989858fb..6bec0705 100644 --- a/tutorecommerce/plugin.py +++ b/tutorecommerce/plugin.py @@ -72,7 +72,7 @@ def _add_ecommerce_mfe_apps( { "orders": { "repository": "https://github.com/edx/frontend-app-ecommerce", - "port": 1996, + "port": 7296, }, "payment": { "repository": "https://github.com/edx/frontend-app-payment", From 434dfd7a382873e0380da0bcc463267c3058f364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Fri, 8 Dec 2023 10:52:29 +0100 Subject: [PATCH 3/3] v16.0.1 --- CHANGELOG.md | 9 +++++++++ changelog.d/20230320_152027_regis_changelog.md | 1 - changelog.d/20230519_161836_regis.md | 12 ------------ changelog.d/20230919_104436_regis_auto_mount.md | 1 - changelog.d/20231118_174413_codewithemad.md | 1 - changelog.d/20231123_114642_ivo.branco.md | 1 - changelog.d/20231206_174503_regis_orders_port.md | 1 - tutorecommerce/__about__.py | 2 +- 8 files changed, 10 insertions(+), 18 deletions(-) delete mode 100644 changelog.d/20230320_152027_regis_changelog.md delete mode 100644 changelog.d/20230519_161836_regis.md delete mode 100644 changelog.d/20230919_104436_regis_auto_mount.md delete mode 100644 changelog.d/20231118_174413_codewithemad.md delete mode 100644 changelog.d/20231123_114642_ivo.branco.md delete mode 100644 changelog.d/20231206_174503_regis_orders_port.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 291b2f3b..b4f9ed5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,3 +18,12 @@ instructions, because git commits are used to generate release notes: --> + + +## v16.0.1 (2023-12-08) + +- [Improvement] Add a changelog file to this plugin. (by @regisb) +- [Feature] Improve support of auto-mounted ecommerce repository. (by @regisb) +- [Improvement] Added Typing to code, Makefile and test action to the repository and formatted code with Black and isort. (by @CodeWithEmad) +- [Feature] Add patch ecommerce-dockerfile-pre-assets. (by @igobranco) +- [Bugfix] Switch ecommerce MFE port from 1996 to 7296, as it clashes with the new learner dashboard. (by @regisb) diff --git a/changelog.d/20230320_152027_regis_changelog.md b/changelog.d/20230320_152027_regis_changelog.md deleted file mode 100644 index 8971794e..00000000 --- a/changelog.d/20230320_152027_regis_changelog.md +++ /dev/null @@ -1 +0,0 @@ -- [Improvement] Add a changelog file to this plugin. (by @regisb) diff --git a/changelog.d/20230519_161836_regis.md b/changelog.d/20230519_161836_regis.md deleted file mode 100644 index a1bc2f75..00000000 --- a/changelog.d/20230519_161836_regis.md +++ /dev/null @@ -1,12 +0,0 @@ - - - - - \ No newline at end of file diff --git a/changelog.d/20230919_104436_regis_auto_mount.md b/changelog.d/20230919_104436_regis_auto_mount.md deleted file mode 100644 index 2e051b24..00000000 --- a/changelog.d/20230919_104436_regis_auto_mount.md +++ /dev/null @@ -1 +0,0 @@ -- [Feature] Improve support of auto-mounted ecommerce repository. (by @regisb) diff --git a/changelog.d/20231118_174413_codewithemad.md b/changelog.d/20231118_174413_codewithemad.md deleted file mode 100644 index 952a3831..00000000 --- a/changelog.d/20231118_174413_codewithemad.md +++ /dev/null @@ -1 +0,0 @@ -- [Improvement] Added Typing to code, Makefile and test action to the repository and formatted code with Black and isort. (by @CodeWithEmad) \ No newline at end of file diff --git a/changelog.d/20231123_114642_ivo.branco.md b/changelog.d/20231123_114642_ivo.branco.md deleted file mode 100644 index 6dad610c..00000000 --- a/changelog.d/20231123_114642_ivo.branco.md +++ /dev/null @@ -1 +0,0 @@ -- [Feature] Add patch ecommerce-dockerfile-pre-assets. (by @igobranco) \ No newline at end of file diff --git a/changelog.d/20231206_174503_regis_orders_port.md b/changelog.d/20231206_174503_regis_orders_port.md deleted file mode 100644 index 9b1d3e44..00000000 --- a/changelog.d/20231206_174503_regis_orders_port.md +++ /dev/null @@ -1 +0,0 @@ -- [Bugfix] Switch ecommerce MFE port from 1996 to 7296, as it clashes with the new learner dashboard. (by @regisb) diff --git a/tutorecommerce/__about__.py b/tutorecommerce/__about__.py index 5e5e9109..610c1115 100644 --- a/tutorecommerce/__about__.py +++ b/tutorecommerce/__about__.py @@ -1 +1 @@ -__version__ = "16.0.0" +__version__ = "16.0.1"