Skip to content

Commit 202e38b

Browse files
committed
feat: add plugin slot for content iframe error component
1 parent 6892633 commit 202e38b

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

src/courseware/course/sequence/Unit/ContentIFrame.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import PropTypes from 'prop-types';
22

3-
import { ErrorPage } from '@edx/frontend-platform/react';
43
import { ModalDialog } from '@openedx/paragon';
54
import { ContentIFrameLoaderSlot } from '../../../../plugin-slots/ContentIFrameLoaderSlot';
5+
import { ContentIFrameErrorSlot } from '../../../../plugin-slots/ContentIFrameErrorSlot';
66

77
import * as hooks from './hooks';
88

@@ -66,7 +66,11 @@ const ContentIFrame = ({
6666
return (
6767
<>
6868
{(shouldShowContent && !hasLoaded) && (
69-
showError ? <ErrorPage /> : <ContentIFrameLoaderSlot courseId={courseId} loadingMessage={loadingMessage} />
69+
showError ? (
70+
<ContentIFrameErrorSlot courseId={courseId} />
71+
) : (
72+
<ContentIFrameLoaderSlot courseId={courseId} loadingMessage={loadingMessage} />
73+
)
7074
)}
7175
{shouldShowContent && (
7276
<div className="unit-iframe-wrapper">
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Content iframe Loader Slot
2+
3+
### Slot ID: `org.openedx.frontend.learning.content_iframe_error.v1`
4+
5+
### Parameters: `courseId`
6+
7+
## Description
8+
9+
This slot is used to replace/modify the content iframe error page.
10+
11+
## Example
12+
13+
The following `env.config.jsx` will replace the error page with emojis.
14+
15+
```js
16+
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
17+
18+
const config = {
19+
pluginSlots: {
20+
'org.openedx.frontend.learning.content_iframe_error.v1': {
21+
keepDefault: false,
22+
plugins: [
23+
{
24+
op: PLUGIN_OPERATIONS.Insert,
25+
widget: {
26+
id: 'custom_error_page',
27+
type: DIRECT_PLUGIN,
28+
RenderWidget: (courseId) => (
29+
<h1>🚨🤖💥</h1>
30+
),
31+
},
32+
},
33+
]
34+
}
35+
},
36+
}
37+
38+
export default config;
39+
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { PluginSlot } from '@openedx/frontend-plugin-framework';
2+
import { ErrorPage } from '@edx/frontend-platform/react';
3+
4+
export const ContentIFrameErrorSlot : React.FC<Props> = ({courseId}) => (
5+
<PluginSlot
6+
id="org.openedx.frontend.learning.content_iframe_error.v1"
7+
pluginProps={{courseId}}
8+
>
9+
<ErrorPage />
10+
</PluginSlot>
11+
);
12+
13+
interface Props {
14+
courseId: string;
15+
}

0 commit comments

Comments
 (0)