Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/courseware/course/sequence/Unit/ContentIFrame.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import PropTypes from 'prop-types';

import { ErrorPage } from '@edx/frontend-platform/react';
import { ModalDialog } from '@openedx/paragon';
import { ContentIFrameLoaderSlot } from '../../../../plugin-slots/ContentIFrameLoaderSlot';
import { ContentIFrameErrorSlot } from '../../../../plugin-slots/ContentIFrameErrorSlot';

import * as hooks from './hooks';

Expand Down Expand Up @@ -66,7 +66,11 @@ const ContentIFrame = ({
return (
<>
{(shouldShowContent && !hasLoaded) && (
showError ? <ErrorPage /> : <ContentIFrameLoaderSlot courseId={courseId} loadingMessage={loadingMessage} />
showError ? (
<ContentIFrameErrorSlot courseId={courseId} />
) : (
<ContentIFrameLoaderSlot courseId={courseId} loadingMessage={loadingMessage} />
)
)}
{shouldShowContent && (
<div className="unit-iframe-wrapper">
Expand Down
39 changes: 39 additions & 0 deletions src/plugin-slots/ContentIFrameErrorSlot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Content iFrame Error Slot

### Slot ID: `org.openedx.frontend.learning.content_iframe_error.v1`

### Parameters: `courseId`

## Description

This slot is used to replace/modify the content iframe error page.

## Example

The following `env.config.jsx` will replace the error page with emojis.

```js
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';

const config = {
pluginSlots: {
'org.openedx.frontend.learning.content_iframe_error.v1': {
keepDefault: false,
plugins: [
{
op: PLUGIN_OPERATIONS.Insert,
widget: {
id: 'custom_error_page',
type: DIRECT_PLUGIN,
RenderWidget: ({courseId}) => (
<h1>🚨🤖💥</h1>
),
},
},
]
}
},
}

export default config;
```
15 changes: 15 additions & 0 deletions src/plugin-slots/ContentIFrameErrorSlot/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { PluginSlot } from '@openedx/frontend-plugin-framework';
import { ErrorPage } from '@edx/frontend-platform/react';

interface Props {
courseId: string;
}

export const ContentIFrameErrorSlot : React.FC<Props> = ({ courseId }: Props) => (
<PluginSlot
id="org.openedx.frontend.learning.content_iframe_error.v1"
pluginProps={{ courseId }}
>
<ErrorPage />
</PluginSlot>
);