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:
@@ -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">
|
||||
|
||||
39
src/plugin-slots/ContentIFrameErrorSlot/README.md
Normal file
39
src/plugin-slots/ContentIFrameErrorSlot/README.md
Normal 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;
|
||||
```
|
||||
15
src/plugin-slots/ContentIFrameErrorSlot/index.tsx
Normal file
15
src/plugin-slots/ContentIFrameErrorSlot/index.tsx
Normal 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>
|
||||
);
|
||||
Reference in New Issue
Block a user