You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: revert default content to live in host MFE (#41)
* feat: convert default content to be defined in PluginSlot
* docs: update README to reflect use of default content
* fix: add error handling for if pluginSlots does not exist in config
The priority property determines where the widgets should be placed based on a 1-100 scale. A widget with a priority of 10
160
+
will appear above a widget with a priority of 20.
161
+
162
162
Default Content
163
163
```````````````
164
164
165
-
The default content of a plugin slot is defined in ``env.config.js``, with some differing properties being needed for
166
-
a Direct Plugin over an iFrame plugin. Note: this configuration will change soon so that the default content lives in
167
-
the Host MFE as opposed to a config document.
165
+
The component that is wrapped by a Plugin Slot is referred to as the "default content". In order to render this content,
166
+
the ``keepDefault`` boolean in the slot should be set to ``true``. For organizations who aren't using the Plugin Slot
167
+
(and therefore aren't defining a slot via JS config), ``keepDefault`` will default to ``true``, thus ensuring that the developer
168
+
experience isn't affected; the only change to note is that the component is now wrapped in a Plugin Slot.
168
169
169
-
.. code-block::
170
+
If you need to use a plugin operation (e.g. Wrap, Hide, Modify) on default content, the ``widgetId`` you would use to refer to the content is ``defaults_contents``.
170
171
171
-
/*
172
-
* {String} id - The widget id needed for referencing when using Modify/Wrap/Hide
173
-
* {String} type - The type of plugin being used
174
-
* {Number} priority - The place to insert the widget based on the priority of other widgets (between 1 - 100)
175
-
* {Function} RenderWidget - The React component to be used for a Direct Plugin
176
-
* {Object} [content] - Any props to pass into the RenderWidget component
177
-
* {String} url - The URL from a Child MFE to fetch the widget component
178
-
* {String} title - The title of the iFrame that is read aloud with screen readers
179
-
*/
180
-
181
-
defaultContents: [
182
-
{
183
-
id: 'default_sidebar_widget',
184
-
type: DIRECT_PLUGIN,
185
-
priority: 10,
186
-
RenderWidget: SideBar,
187
-
content: {
188
-
propExampleA: 'Open edX Sidebar',
189
-
propExampleB: SomeIcon,
190
-
}
191
-
},
192
-
{
193
-
id: 'iFrame_widget',
194
-
type: IFRAME_PLUGIN,
195
-
priority: 15,
196
-
url: 'http://{child_mfe_url}/plugin_iframe',
197
-
title: 'Login with XYZ',
198
-
}
199
-
]
200
-
201
-
Priority
202
-
````````
203
-
204
-
The priority property determines where the widgets should be placed based on a 1-100 scale. A widget with a priority of 10
205
-
will appear above a widget with a priority of 20. The default content will have a priority of 50, allowing for any plugins
206
-
to appear before or after the default content.
172
+
Note: The default content will have a priority of 50, allowing for any plugins to appear before or after the default content.
207
173
208
174
Plugin Operations
209
175
`````````````````
@@ -282,8 +248,8 @@ or its priority. The operation requires the id of the widget that will be modifi
282
248
*/
283
249
284
250
{
285
-
op: PLUGIN_OPERATIONS.Insert,
286
-
widgetId: 'default_content_in_slot',
251
+
op: PLUGIN_OPERATIONS.Modify,
252
+
widgetId: 'sidebar_plugin',
287
253
fn: modifyWidget,
288
254
}
289
255
@@ -329,7 +295,7 @@ The Hide operation will simply hide whatever content is desired. This is general
329
295
330
296
{
331
297
op: PLUGIN_OPERATIONS.Hide,
332
-
widgetId: 'default_content_in_slot',
298
+
widgetId: 'some_undesired_plugin',
333
299
}
334
300
335
301
Using a Child Micro-frontend (MFE) for iFrame-based Plugins and Fallback Behavior
0 commit comments