= ({ returnToL
// eslint-disable-next-line import/prefer-default-export
export const ComponentPicker = () => {
- const intl = useIntl();
- const [searchParams] = useSearchParams();
- let parentLocator = searchParams.get('parentLocator');
-
- // istanbul ignore if: this should never happen
- if (!parentLocator) {
- throw new Error('parentLocator is required');
- }
-
- // URLSearchParams decodes '+' to ' ', so we need to convert it back
- parentLocator = parentLocator.replaceAll(' ', '+');
-
const [currentStep, setCurrentStep] = useState('select-library');
const [selectedLibrary, setSelectedLibrary] = useState('');
+ const handleLibrarySelection = (library: string) => {
+ setCurrentStep('pick-components');
+ setSelectedLibrary(library);
+ };
+
const returnToLibrarySelection = () => {
setCurrentStep('select-library');
setSelectedLibrary('');
@@ -49,23 +39,14 @@ export const ComponentPicker = () => {
activeKey={currentStep}
>
-
+
-
+
-
-
-
-
-
-
-
);
};
diff --git a/src/library-authoring/component-picker/SelectLibrary.test.tsx b/src/library-authoring/component-picker/SelectLibrary.test.tsx
index 90681b9fb..cc06fa3af 100644
--- a/src/library-authoring/component-picker/SelectLibrary.test.tsx
+++ b/src/library-authoring/component-picker/SelectLibrary.test.tsx
@@ -8,18 +8,6 @@ import {
} from '../data/api.mocks';
import { ComponentPicker } from './ComponentPicker';
-jest.mock('react-router-dom', () => ({
- ...jest.requireActual('react-router-dom'),
- useSearchParams: () => {
- const [params] = [new URLSearchParams({
- parentLocator: 'block-v1:edX+DemoX+Demo_Course+type@vertical+block@vertical1',
- })];
- return [
- params,
- ];
- },
-}));
-
describe('', () => {
beforeEach(() => {
initializeMocks();
diff --git a/src/library-authoring/component-picker/SelectLibrary.tsx b/src/library-authoring/component-picker/SelectLibrary.tsx
index 4c4f1754c..e6d97c559 100644
--- a/src/library-authoring/component-picker/SelectLibrary.tsx
+++ b/src/library-authoring/component-picker/SelectLibrary.tsx
@@ -7,7 +7,7 @@ import {
SearchField,
Stack,
} from '@openedx/paragon';
-import { useCallback, useEffect, useState } from 'react';
+import { useCallback, useState } from 'react';
import Loading from '../../generic/Loading';
import AlertError from '../../generic/alert-error';
@@ -36,10 +36,6 @@ const SelectLibrary = ({ selectedLibrary, setSelectedLibrary }: SelectLibraryPro
const [searchQuery, setSearchQuery] = useState('');
const [currentPage, setCurrentPage] = useState(1);
- useEffect(() => {
- setSelectedLibrary('');
- }, [currentPage, searchQuery]);
-
const handleSearch = useCallback((search: string) => {
setSearchQuery(search);
setCurrentPage(1);
diff --git a/src/library-authoring/components/ComponentCard.tsx b/src/library-authoring/components/ComponentCard.tsx
index c8df6c202..5dd56381a 100644
--- a/src/library-authoring/components/ComponentCard.tsx
+++ b/src/library-authoring/components/ComponentCard.tsx
@@ -93,7 +93,6 @@ const ComponentCard = ({ contentHit }: ComponentCardProps) => {
const {
openComponentInfoSidebar,
componentPickerMode,
- parentLocator,
} = useLibraryContext();
const {
@@ -111,7 +110,6 @@ const ComponentCard = ({ contentHit }: ComponentCardProps) => {
const handleAddComponentToCourse = () => {
window.parent.postMessage({
- parentLocator,
usageKey,
type: 'pickerComponentSelected',
category: blockType,