Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
Overhang.IO committed Oct 6, 2023
2 parents 2fc1ead + b55bdc0 commit 120e18a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Feature] The new CONFIG_LOADED action checks if MFE_HOST is a subdomain of LMS_HOST. If not, display a warning message to the user. (by @CodeWithEmad)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def load_about():
packages=find_packages(exclude=["tests*"]),
include_package_data=True,
python_requires=">=3.8",
install_requires=["tutor>=16.0.0,<17.0.0"],
install_requires=["tutor>=16.1.2,<17.0.0"],
entry_points={"tutor.plugin.v1": ["mfe = tutormfe.plugin"]},
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand Down
20 changes: 19 additions & 1 deletion tutormfe/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

import pkg_resources

from tutor import fmt
from tutor import hooks as tutor_hooks
from tutor.hooks import priorities

from tutor.types import Config, get_typed
from .__about__ import __version__, __version_suffix__
from .hooks import MFE_ATTRS_TYPE, MFE_APPS

Expand Down Expand Up @@ -258,3 +259,20 @@ def _build_3rd_party_dev_mfes_on_launch(
tutor_hooks.Filters.CONFIG_OVERRIDES.add_items(
list(config.get("overrides", {}).items())
)


# Actions
@tutor_hooks.Actions.CONFIG_LOADED.add()
def _check_mfe_host(config: Config) -> None:
"""
This will check if the MFE_HOST is a subdomain of LMS_HOST.
if not, prints a warning to notify the user.
"""

lms_host = get_typed(config, "LMS_HOST", str, "")
mfe_host = get_typed(config, "MFE_HOST", str, "")
if not mfe_host.endswith("." + lms_host):
fmt.echo_alert(
f'Warning: MFE_HOST="{mfe_host}" is not a subdomain of LMS_HOST="{lms_host}". '
"This configuration is not typically recommended and may lead to unexpected behavior."
)

0 comments on commit 120e18a

Please sign in to comment.