Skip to content

Commit 18d4cfc

Browse files
committed
Revert "fix: Avoid Open library item info sidebar when selection from course or unit"
This reverts commit d0d6696.
1 parent 163e3bb commit 18d4cfc

7 files changed

Lines changed: 13 additions & 103 deletions

File tree

src/course-outline/outline-sidebar/AddSidebar.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ const ShowLibraryContent = () => {
304304
visibleTabs={[ContentType.home]}
305305
FiltersComponent={SidebarFilters}
306306
onComponentSelected={onComponentSelected}
307-
restrictOpenInfoSidebar
308307
/>
309308
</MultiLibraryProvider>
310309
);

src/course-unit/unit-sidebar/AddSidebar.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ const AddLibraryContent = () => {
311311
visibleTabs={[ContentType.home]}
312312
FiltersComponent={SidebarFilters}
313313
onComponentSelected={handleSelection}
314-
restrictOpenInfoSidebar
315314
/>
316315
</MultiLibraryProvider>
317316
);

src/library-authoring/common/context/ComponentPickerContext.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@ type NoComponentPickerType = {
2424
addComponentToSelectedComponents?: never;
2525
removeComponentFromSelectedComponents?: never;
2626
restrictToLibrary?: never;
27-
restrictOpenInfoSidebar?: never;
2827
extraFilter?: never;
2928
isLoading?: never;
3029
setIsLoading?: never;
3130
};
3231

3332
type BasePickerType = {
3433
restrictToLibrary: boolean;
35-
restrictOpenInfoSidebar: boolean;
3634
extraFilter: string[];
3735
isLoading?: boolean;
3836
setIsLoading?: React.Dispatch<React.SetStateAction<boolean>>;
@@ -66,7 +64,6 @@ const ComponentPickerContext = createContext<ComponentPickerContextData | undefi
6664

6765
type BasePickerProps = {
6866
restrictToLibrary?: boolean;
69-
restrictOpenInfoSidebar?: boolean;
7067
/** Only show published components */
7168
extraFilter?: string[];
7269
};
@@ -96,7 +93,6 @@ export const ComponentPickerProvider = ({
9693
children,
9794
componentPickerMode,
9895
restrictToLibrary = false,
99-
restrictOpenInfoSidebar = false,
10096
onComponentSelected,
10197
onChangeComponentSelection,
10298
extraFilter,
@@ -140,7 +136,6 @@ export const ComponentPickerProvider = ({
140136
return {
141137
componentPickerMode,
142138
restrictToLibrary,
143-
restrictOpenInfoSidebar,
144139
onComponentSelected,
145140
extraFilter: extraFilter || [],
146141
isLoading,
@@ -150,7 +145,6 @@ export const ComponentPickerProvider = ({
150145
return {
151146
componentPickerMode,
152147
restrictToLibrary,
153-
restrictOpenInfoSidebar,
154148
selectedComponents,
155149
addComponentToSelectedComponents,
156150
removeComponentFromSelectedComponents,

src/library-authoring/component-picker/ComponentPicker.test.tsx

Lines changed: 2 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ import {
1818
mockGetContainerMetadata,
1919
} from '../data/api.mocks';
2020

21-
import { ComponentPicker, LibraryAndComponentPicker } from './ComponentPicker';
22-
import { ContentType, allLibraryPageTabs } from '../routes';
23-
import { LibraryProvider } from '../common/context/LibraryContext';
21+
import { LibraryAndComponentPicker } from './ComponentPicker';
22+
import { ContentType } from '../routes';
2423

2524
jest.mock('react-router-dom', () => ({
2625
...jest.requireActual('react-router-dom'),
@@ -458,70 +457,3 @@ describe('<LibraryAndComponentPicker />', () => {
458457
expect(screen.queryByText(/never published/i)).not.toBeInTheDocument();
459458
});
460459
});
461-
462-
describe('<ComponentPicker restrictOpenInfoSidebar />', () => {
463-
const { libraryId } = mockContentLibrary;
464-
465-
const renderPicker = (restrictOpenInfoSidebar: boolean) => render(
466-
<LibraryProvider libraryId={libraryId}>
467-
<ComponentPicker
468-
componentPickerMode="single"
469-
restrictOpenInfoSidebar={restrictOpenInfoSidebar}
470-
visibleTabs={allLibraryPageTabs}
471-
/>
472-
</LibraryProvider>,
473-
);
474-
475-
beforeEach(() => {
476-
initializeMocks();
477-
mockSearchResult({ ...mockResult });
478-
});
479-
480-
it('should open component info sidebar on card click when restrictOpenInfoSidebar is false', async () => {
481-
const user = userEvent.setup();
482-
renderPicker(false);
483-
484-
const [componentCard] = await screen.findAllByText('Introduction to Testing');
485-
486-
// Click on the component card body
487-
await user.click(componentCard);
488-
489-
// Sidebar should open
490-
expect(await screen.findByTestId('library-sidebar')).toBeInTheDocument();
491-
});
492-
493-
it('should not open component info sidebar on card click when restrictOpenInfoSidebar is true', async () => {
494-
const user = userEvent.setup();
495-
renderPicker(true);
496-
497-
const [componentCard] = await screen.findAllByText('Introduction to Testing');
498-
499-
// Click on the component card body
500-
await user.click(componentCard);
501-
502-
// Sidebar should NOT open
503-
expect(screen.queryByTestId('library-sidebar')).not.toBeInTheDocument();
504-
});
505-
506-
it('should open container info sidebar on card click when restrictOpenInfoSidebar is false', async () => {
507-
const user = userEvent.setup();
508-
renderPicker(false);
509-
510-
// Click on the unit card body
511-
await user.click(await screen.findByText('Published Test Unit'));
512-
513-
// Sidebar should open
514-
expect(await screen.findByTestId('library-sidebar')).toBeInTheDocument();
515-
});
516-
517-
it('should not open container info sidebar on card click when restrictOpenInfoSidebar is true', async () => {
518-
const user = userEvent.setup();
519-
renderPicker(true);
520-
521-
// Click on the unit card body
522-
await user.click(await screen.findByText('Published Test Unit'));
523-
524-
// Sidebar should NOT open
525-
expect(screen.queryByTestId('library-sidebar')).not.toBeInTheDocument();
526-
});
527-
});

src/library-authoring/component-picker/ComponentPicker.tsx

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ type PickerProps = {
5858
extraFilter?: string[];
5959
visibleTabs?: ContentType[];
6060
componentPickerMode?: 'single' | 'multiple';
61-
restrictOpenInfoSidebar?: boolean;
6261
onComponentSelected?: ComponentSelectedEvent;
6362
onChangeComponentSelection?: ComponentSelectionChangedEvent;
6463
FiltersComponent?: React.ComponentType<FiltersProps>;
@@ -71,7 +70,6 @@ export const ComponentPicker = ({
7170
showOnlyPublished,
7271
extraFilter,
7372
componentPickerMode = 'single',
74-
restrictOpenInfoSidebar = false,
7573
visibleTabs = allLibraryPageTabs,
7674
/** This default callback is used to send the selected component back to the parent window,
7775
* when the component picker is used in an iframe.
@@ -89,19 +87,15 @@ export const ComponentPicker = ({
8987

9088
const restrictToLibrary = !!libraryId;
9189

92-
const componentPickerProviderProps = componentPickerMode === 'single' ?
93-
{
94-
componentPickerMode,
95-
onComponentSelected,
96-
restrictToLibrary,
97-
restrictOpenInfoSidebar,
98-
} :
99-
{
100-
componentPickerMode,
101-
onChangeComponentSelection,
102-
restrictToLibrary,
103-
restrictOpenInfoSidebar,
104-
};
90+
const componentPickerProviderProps = componentPickerMode === 'single' ? {
91+
componentPickerMode,
92+
onComponentSelected,
93+
restrictToLibrary,
94+
} : {
95+
componentPickerMode,
96+
onChangeComponentSelection,
97+
restrictToLibrary,
98+
};
10599

106100
return (
107101
<PublishedFilterContextProvider showOnlyPublished={calcShowOnlyPublished}>

src/library-authoring/components/ComponentCard.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type ComponentCardProps = {
1717

1818
const ComponentCard = ({ hit }: ComponentCardProps) => {
1919
const { openComponentInfoSidebar, openItemSidebar, sidebarItemInfo } = useSidebarContext();
20-
const { componentPickerMode, restrictOpenInfoSidebar } = useComponentPickerContext();
20+
const { componentPickerMode } = useComponentPickerContext();
2121
const { showOnlyPublished } = usePublishedFilterContext();
2222

2323
const {
@@ -38,10 +38,6 @@ const ComponentCard = ({ hit }: ComponentCardProps) => {
3838
if (!componentPickerMode) {
3939
openItemSidebar(usageKey, SidebarBodyItemId.ComponentInfo);
4040
} else {
41-
if (restrictOpenInfoSidebar) {
42-
// Do nothing on select
43-
return;
44-
}
4541
// In component picker mode, we want to open the sidebar
4642
// without changing the URL
4743
openComponentInfoSidebar(usageKey);

src/library-authoring/containers/ContainerCard.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ type ContainerCardProps = {
262262
};
263263

264264
const ContainerCard = ({ hit }: ContainerCardProps) => {
265-
const { componentPickerMode, restrictOpenInfoSidebar } = useComponentPickerContext();
265+
const { componentPickerMode } = useComponentPickerContext();
266266
const { showOnlyPublished } = usePublishedFilterContext();
267267
const { openContainerInfoSidebar, openItemSidebar, sidebarItemInfo } = useSidebarContext();
268268

@@ -293,10 +293,6 @@ const ContainerCard = ({ hit }: ContainerCardProps) => {
293293
const selectContainer = useCallback((e?: React.MouseEvent) => {
294294
const doubleClicked = (e?.detail || 0) > 1;
295295
if (componentPickerMode) {
296-
if (restrictOpenInfoSidebar) {
297-
// Do nothing on select
298-
return;
299-
}
300296
// In component picker mode, we want to open the sidebar
301297
// without changing the URL
302298
openContainerInfoSidebar(containerKey);

0 commit comments

Comments
 (0)