From 1d27341ffb1207f9eed00a1799e3ced9bb6e8189 Mon Sep 17 00:00:00 2001 From: Braden MacDonald Date: Wed, 16 Oct 2024 22:40:15 -0700 Subject: [PATCH 1/5] feat: view for comparing published version of library block to previous --- src/index.jsx | 8 +++- .../LibraryBlock/LibraryBlock.tsx | 7 +++- .../CompareChangesWidget.tsx | 37 +++++++++++++++++++ src/library-authoring/index.tsx | 1 + .../PreviewChangesEmbed.tsx | 33 +++++++++++++++++ 5 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 src/library-authoring/component-comparison/CompareChangesWidget.tsx create mode 100644 src/library-authoring/legacy-integration/PreviewChangesEmbed.tsx diff --git a/src/index.jsx b/src/index.jsx index 29d0a9ac5e..933e67f401 100755 --- a/src/index.jsx +++ b/src/index.jsx @@ -16,7 +16,12 @@ import { initializeHotjar } from '@edx/frontend-enterprise-hotjar'; import { logError } from '@edx/frontend-platform/logging'; import messages from './i18n'; -import { ComponentPicker, CreateLibrary, LibraryLayout } from './library-authoring'; +import { + ComponentPicker, + CreateLibrary, + LibraryLayout, + PreviewChangesEmbed, +} from './library-authoring'; import initializeStore from './store'; import CourseAuthoringRoutes from './CourseAuthoringRoutes'; import Head from './head/Head'; @@ -56,6 +61,7 @@ const App = () => { } /> } /> } /> + } /> } /> } /> {getConfig().ENABLE_ACCESSIBILITY_PAGE === 'true' && ( diff --git a/src/library-authoring/LibraryBlock/LibraryBlock.tsx b/src/library-authoring/LibraryBlock/LibraryBlock.tsx index dd49206123..efdfd5b56a 100644 --- a/src/library-authoring/LibraryBlock/LibraryBlock.tsx +++ b/src/library-authoring/LibraryBlock/LibraryBlock.tsx @@ -7,6 +7,7 @@ import messages from './messages'; interface LibraryBlockProps { onBlockNotification?: (event: { eventType: string; [key: string]: any }) => void; usageKey: string; + version?: 'published' | 'draft' | number; } /** * React component that displays an XBlock in a sandboxed IFrame. @@ -17,7 +18,7 @@ interface LibraryBlockProps { * cannot access things like the user's cookies, nor can it make GET/POST * requests as the user. However, it is allowed to call any XBlock handlers. */ -const LibraryBlock = ({ onBlockNotification, usageKey }: LibraryBlockProps) => { +const LibraryBlock = ({ onBlockNotification, usageKey, version }: LibraryBlockProps) => { const iframeRef = useRef(null); const [iFrameHeight, setIFrameHeight] = useState(600); const studioBaseUrl = getConfig().STUDIO_BASE_URL; @@ -62,6 +63,8 @@ const LibraryBlock = ({ onBlockNotification, usageKey }: LibraryBlockProps) => { }; }, []); + const queryStr = version ? `?version=${version}` : ''; + return (
{