feat: add plugin slot for content iframe error component (#1771)

* feat: add plugin slot for content iframe error component

* style: quality

* fix: copilot suggestions
This commit is contained in:
Jansen Kantor
2025-10-20 12:03:07 -04:00
committed by GitHub
parent 7318fb3ef7
commit f91af211f6
3 changed files with 60 additions and 2 deletions

View File

@@ -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';
@@ -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">

View File

@@ -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;
```

View File

@@ -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>
);