Skip to content

Commit

Permalink
feat: Add a plugin slot for the content iframe loader (#1453)
Browse files Browse the repository at this point in the history
  • Loading branch information
hajorg authored Sep 11, 2024
1 parent 82b27e5 commit b63508d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/courseware/course/sequence/Unit/ContentIFrame.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from 'react';
import { ErrorPage } from '@edx/frontend-platform/react';
import { StrictDict } from '@edx/react-unit-test-utils';
import { ModalDialog, Modal } from '@openedx/paragon';
import { PluginSlot } from '@openedx/frontend-plugin-framework';

import PageLoading from '@src/generic/PageLoading';
import * as hooks from './hooks';
Expand Down Expand Up @@ -35,6 +36,7 @@ const ContentIFrame = ({
elementId,
onLoaded,
title,
courseId,
}) => {
const {
handleIFrameLoad,
Expand Down Expand Up @@ -82,7 +84,17 @@ const ContentIFrame = ({
return (
<>
{(shouldShowContent && !hasLoaded) && (
showError ? <ErrorPage /> : <PageLoading srMessage={loadingMessage} />
showError ? <ErrorPage /> : (
<PluginSlot
id="content_iframe_loader_slot"
pluginProps={{
defaultLoaderComponent: <PageLoading srMessage={loadingMessage} />,
courseId,
}}
>
<PageLoading srMessage={loadingMessage} />
</PluginSlot>
)
)}
{shouldShowContent && (
<div className="unit-iframe-wrapper">
Expand Down Expand Up @@ -124,11 +136,13 @@ ContentIFrame.propTypes = {
elementId: PropTypes.string.isRequired,
onLoaded: PropTypes.func,
title: PropTypes.node.isRequired,
courseId: PropTypes.string,
};

ContentIFrame.defaultProps = {
iframeUrl: null,
onLoaded: () => ({}),
courseId: '',
};

export default ContentIFrame;
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ exports[`Unit component output snapshot: not bookmarked, do not show content 1`]
id="test-props-id"
/>
<ContentIFrame
courseId="test-course-id"
elementId="unit-iframe"
id="test-props-id"
loadingMessage="Loading learning sequence..."
Expand Down
1 change: 1 addition & 0 deletions src/courseware/course/sequence/Unit/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const Unit = ({
onLoaded={onLoaded}
shouldShowContent={!shouldDisplayHonorCode && !examAccess.blockAccess}
title={unit.title}
courseId={courseId}
/>
</div>
);
Expand Down

0 comments on commit b63508d

Please sign in to comment.