Skip to content

Commit 62fabc1

Browse files
authored
fix: update env.config.jsx according to tutor-mfe#240 PR (#109)
* fix: update env.config.jsx according to tutor-mfe#240 PR * chore: install tutor-mfe main branch
1 parent c97f383 commit 62fabc1

File tree

5 files changed

+73
-89
lines changed

5 files changed

+73
-89
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ jobs:
2020
- name: Install dependencies
2121
run: |
2222
pip install .[dev]
23+
pip install --upgrade --editable git+https://github.com/overhangio/tutor-mfe.git@main#egg=tutor-mfe
2324
- name: Test lint, types, and format
2425
run: make test

tutorindigo/templates/indigo/env.config.jsx renamed to tutorindigo/patches/mfe-env-config-buildtime-definitions

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import React, { useEffect } from 'react';
2-
import Cookies from 'universal-cookie';
31

4-
import Footer from '@edly-io/indigo-frontend-component-footer';
5-
import { getConfig } from '@edx/frontend-platform';
6-
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
72

83
let themeCookie = 'indigo-toggle-dark';
94
let themeCookieExpiry = 90; // days
@@ -70,35 +65,3 @@ const AddDarkTheme = () => {
7065

7166
return (<div />);
7267
};
73-
74-
const themePluginSlot = {
75-
keepDefault: false,
76-
plugins: [
77-
{
78-
op: PLUGIN_OPERATIONS.Insert,
79-
widget: {
80-
id: 'default_contents',
81-
type: DIRECT_PLUGIN,
82-
priority: 1,
83-
RenderWidget: <Footer />,
84-
},
85-
},
86-
{
87-
op: PLUGIN_OPERATIONS.Insert,
88-
widget: {
89-
id: 'read_theme_cookie',
90-
type: DIRECT_PLUGIN,
91-
priority: 2,
92-
RenderWidget: AddDarkTheme,
93-
},
94-
},
95-
],
96-
};
97-
98-
const config = {
99-
pluginSlots: {
100-
footer_slot: themePluginSlot,
101-
},
102-
};
103-
104-
export default config;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import React, { useEffect } from 'react';
2+
import Cookies from 'universal-cookie';
3+
4+
import { getConfig } from '@edx/frontend-platform';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
const { default: IndigoFooter } = await import('@edly-io/indigo-frontend-component-footer');

tutorindigo/plugin.py

Lines changed: 66 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
from __future__ import annotations
22

33
import os
4+
from glob import glob
45
import typing as t
56

67
import importlib_resources
78
from tutor import hooks
9+
from tutormfe.hooks import PLUGIN_SLOTS
810
from tutor.__about__ import __version_suffix__
911

1012
from .__about__ import __version__
@@ -102,70 +104,38 @@ def _override_openedx_docker_image(
102104
hooks.Filters.CONFIG_OVERRIDES.add_items(list(config["overrides"].items()))
103105

104106

107+
# MFEs that are styled using Indigo
108+
indigo_styled_mfes = [
109+
"learning",
110+
"learner-dashboard",
111+
"profile",
112+
"account",
113+
"discussions",
114+
]
115+
105116
hooks.Filters.ENV_PATCHES.add_items(
106117
[
107-
# MFE will install header version 3.0.x and will include indigo-footer as a
108-
# separate package for use in env.config.jsx
109118
(
110-
"mfe-dockerfile-post-npm-install-learning",
119+
f"mfe-dockerfile-post-npm-install-{mfe}",
111120
"""
112-
RUN npm install '@edx/brand@npm:@edly-io/indigo-brand-openedx@^2.1.1'
113-
RUN npm install '@edx/frontend-component-header@npm:@edly-io/indigo-frontend-component-header@^3.1.3'
121+
114122
RUN npm install @edly-io/indigo-frontend-component-footer@^2.0.0
115-
116-
COPY indigo/env.config.jsx /openedx/app/
117-
""",
118-
),
119-
(
120-
"mfe-dockerfile-post-npm-install-authn",
121-
"""
122-
RUN npm install '@edx/brand@npm:@edly-io/indigo-brand-openedx@^2.1.1'
123-
""",
124-
),
125-
# Tutor-Indigo v2.1 targets the styling updates in discussions and learner-dashboard MFE
126-
# brand-openedx is related to styling updates while others are for header and footer updates
127-
(
128-
"mfe-dockerfile-post-npm-install-discussions",
129-
"""
130-
RUN npm install '@edx/brand@npm:@edly-io/indigo-brand-openedx@^2.1.1'
131123
RUN npm install '@edx/frontend-component-header@npm:@edly-io/indigo-frontend-component-header@^3.1.3'
132-
RUN npm install @edly-io/indigo-frontend-component-footer@^2.0.0
133-
134-
COPY indigo/env.config.jsx /openedx/app/
135-
""",
136-
),
137-
(
138-
"mfe-dockerfile-post-npm-install-learner-dashboard",
139-
"""
140124
RUN npm install '@edx/brand@npm:@edly-io/indigo-brand-openedx@^2.1.1'
141-
RUN npm install @edly-io/indigo-frontend-component-footer@^2.0.0
142125
143-
COPY indigo/env.config.jsx /openedx/app/
144126
""",
145-
),
146-
(
147-
"mfe-dockerfile-post-npm-install-profile",
148-
"""
149-
RUN npm install '@edx/brand@npm:@edly-io/indigo-brand-openedx@^2.1.1'
150-
RUN npm install '@edx/frontend-component-header@npm:@edly-io/indigo-frontend-component-header@^3.1.3'
151-
RUN npm install @edly-io/indigo-frontend-component-footer@^2.0.0
152-
153-
COPY indigo/env.config.jsx /openedx/app/
154-
""",
155-
),
156-
(
157-
"mfe-dockerfile-post-npm-install-account",
158-
"""
159-
RUN npm install '@edx/brand@npm:@edly-io/indigo-brand-openedx@^2.1.1'
160-
RUN npm install '@edx/frontend-component-header@npm:@edly-io/indigo-frontend-component-header@^3.1.3'
161-
RUN npm install @edly-io/indigo-frontend-component-footer@^2.0.0
162-
163-
COPY indigo/env.config.jsx /openedx/app/
164-
""",
165-
),
127+
)
128+
for mfe in indigo_styled_mfes
166129
]
167130
)
168131

132+
hooks.Filters.ENV_PATCHES.add_item(
133+
(
134+
"mfe-dockerfile-post-npm-install-authn",
135+
"RUN npm install '@edx/brand@npm:@edly-io/indigo-brand-openedx@^2.1.1'",
136+
)
137+
)
138+
169139
# Include js file in lms main.html, main_django.html, and certificate.html
170140

171141
hooks.Filters.ENV_PATCHES.add_items(
@@ -204,3 +174,47 @@ def _override_openedx_docker_image(
204174
),
205175
]
206176
)
177+
178+
179+
# Apply patches from tutor-indigo
180+
for path in glob(
181+
os.path.join(
182+
str(importlib_resources.files("tutorindigo") / "patches"),
183+
"*",
184+
)
185+
):
186+
with open(path, encoding="utf-8") as patch_file:
187+
hooks.Filters.ENV_PATCHES.add_item((os.path.basename(path), patch_file.read()))
188+
189+
190+
for mfe in indigo_styled_mfes:
191+
PLUGIN_SLOTS.add_item(
192+
(
193+
mfe,
194+
"footer_slot",
195+
"""
196+
{
197+
op: PLUGIN_OPERATIONS.Hide,
198+
widgetId: 'default_contents',
199+
},
200+
{
201+
op: PLUGIN_OPERATIONS.Insert,
202+
widget: {
203+
id: 'default_contents',
204+
type: DIRECT_PLUGIN,
205+
priority: 1,
206+
RenderWidget: <IndigoFooter />,
207+
},
208+
},
209+
{
210+
op: PLUGIN_OPERATIONS.Insert,
211+
widget: {
212+
id: 'read_theme_cookie',
213+
type: DIRECT_PLUGIN,
214+
priority: 2,
215+
RenderWidget: AddDarkTheme,
216+
},
217+
},
218+
""",
219+
),
220+
)

0 commit comments

Comments
 (0)