{blockPreview}
@@ -176,6 +175,7 @@ const ContainerCard = ({ hit } : ContainerCardProps) => {
published,
publishStatus,
usageKey: unitId,
+ content,
} = hit;
const numChildrenCount = showOnlyPublished ? (
@@ -186,6 +186,10 @@ const ContainerCard = ({ hit } : ContainerCardProps) => {
showOnlyPublished ? formatted.published?.displayName : formatted.displayName
) ?? '';
+ const childUsageKeys: Array
= (
+ showOnlyPublished ? published?.content?.childUsageKeys : content?.childUsageKeys
+ ) ?? [];
+
const { navigateTo } = useLibraryRoutes();
const openContainer = useCallback(() => {
@@ -200,7 +204,7 @@ const ContainerCard = ({ hit } : ContainerCardProps) => {
}
+ preview={}
tags={tags}
numChildren={numChildrenCount}
actions={(
diff --git a/src/library-authoring/containers/ContainerOrganize.tsx b/src/library-authoring/containers/ContainerOrganize.tsx
index e6585785e2..5c336abc04 100644
--- a/src/library-authoring/containers/ContainerOrganize.tsx
+++ b/src/library-authoring/containers/ContainerOrganize.tsx
@@ -85,7 +85,7 @@ const ContainerOrganize = () => {
>
- {intl.formatMessage(messages.organizeTabTagsTitle, { count: tagsCount })}
+ {intl.formatMessage(messages.manageTabTagsTitle, { count: tagsCount })}
@@ -113,7 +113,7 @@ const ContainerOrganize = () => {
>
- {intl.formatMessage(messages.organizeTabCollectionsTitle, { count: collectionsCount })}
+ {intl.formatMessage(messages.manageTabCollectionsTitle, { count: collectionsCount })}
diff --git a/src/library-authoring/containers/UnitInfo.tsx b/src/library-authoring/containers/UnitInfo.tsx
index 164962fcc6..df70791e14 100644
--- a/src/library-authoring/containers/UnitInfo.tsx
+++ b/src/library-authoring/containers/UnitInfo.tsx
@@ -120,7 +120,7 @@ const UnitInfo = () => {
useEffect(() => {
// Show Organize tab if JumpToAddCollections action is set in sidebarComponentInfo
if (jumpToCollections) {
- setSidebarTab(UNIT_INFO_TABS.Organize);
+ setSidebarTab(UNIT_INFO_TABS.Manage);
}
}, [jumpToCollections, setSidebarTab]);
@@ -166,7 +166,7 @@ const UnitInfo = () => {
onSelect={setSidebarTab}
>
{renderTab(UNIT_INFO_TABS.Preview, , intl.formatMessage(messages.previewTabTitle))}
- {renderTab(UNIT_INFO_TABS.Organize, , intl.formatMessage(messages.organizeTabTitle))}
+ {renderTab(UNIT_INFO_TABS.Manage, , intl.formatMessage(messages.manageTabTitle))}
{renderTab(UNIT_INFO_TABS.Settings, 'Unit Settings', intl.formatMessage(messages.settingsTabTitle))}
diff --git a/src/library-authoring/containers/messages.ts b/src/library-authoring/containers/messages.ts
index 9ebae29e1b..fe8e0139ed 100644
--- a/src/library-authoring/containers/messages.ts
+++ b/src/library-authoring/containers/messages.ts
@@ -11,20 +11,20 @@ const messages = defineMessages({
defaultMessage: 'Preview',
description: 'Title for preview tab',
},
- organizeTabTitle: {
- id: 'course-authoring.library-authoring.container-sidebar.organize-tab.title',
- defaultMessage: 'Organize',
- description: 'Title for organize tab',
+ manageTabTitle: {
+ id: 'course-authoring.library-authoring.container-sidebar.manage-tab.title',
+ defaultMessage: 'Manage',
+ description: 'Title for manage tab',
},
- organizeTabTagsTitle: {
- id: 'course-authoring.library-authoring.container-sidebar.organize-tab.tags.title',
+ manageTabTagsTitle: {
+ id: 'course-authoring.library-authoring.container-sidebar.manage-tab.tags.title',
defaultMessage: 'Tags ({count})',
- description: 'Title for tags section in organize tab',
+ description: 'Title for tags section in manage tab',
},
- organizeTabCollectionsTitle: {
- id: 'course-authoring.library-authoring.container-sidebar.organize-tab.collections.title',
+ manageTabCollectionsTitle: {
+ id: 'course-authoring.library-authoring.container-sidebar.manage-tab.collections.title',
defaultMessage: 'Collections ({count})',
- description: 'Title for collections section in organize tab',
+ description: 'Title for collections section in manage tab',
},
publishContainerButton: {
id: 'course-authoring.library-authoring.container-sidebar.publish-button',
diff --git a/src/library-authoring/generic/manage-collections/ManageCollections.test.tsx b/src/library-authoring/generic/manage-collections/ManageCollections.test.tsx
index b73dd0d837..7f7b79d436 100644
--- a/src/library-authoring/generic/manage-collections/ManageCollections.test.tsx
+++ b/src/library-authoring/generic/manage-collections/ManageCollections.test.tsx
@@ -77,7 +77,7 @@ describe('', () => {
await waitFor(() => {
expect(axiosMock.history.patch.length).toEqual(1);
});
- expect(mockShowToast).toHaveBeenCalledWith('Item collections updated');
+ expect(mockShowToast).toHaveBeenCalledWith('Content added to collection.');
expect(JSON.parse(axiosMock.history.patch[0].data)).toEqual({
collection_keys: ['my-first-collection', 'my-second-collection'],
});
@@ -103,7 +103,7 @@ describe('', () => {
await waitFor(() => {
expect(axiosMock.history.patch.length).toEqual(1);
});
- expect(mockShowToast).toHaveBeenCalledWith('Item collections updated');
+ expect(mockShowToast).toHaveBeenCalledWith('Content added to collection.');
expect(JSON.parse(axiosMock.history.patch[0].data)).toEqual({
collection_keys: ['my-first-collection', 'my-second-collection'],
});
@@ -133,7 +133,7 @@ describe('', () => {
expect(JSON.parse(axiosMock.history.patch[0].data)).toEqual({
collection_keys: ['my-second-collection'],
});
- expect(mockShowToast).toHaveBeenCalledWith('Failed to update item collections');
+ expect(mockShowToast).toHaveBeenCalledWith('Failed to add content to collection.');
expect(screen.queryByRole('search')).not.toBeInTheDocument();
});
diff --git a/src/library-authoring/generic/manage-collections/ManageCollections.tsx b/src/library-authoring/generic/manage-collections/ManageCollections.tsx
index 41bc36ce7c..96591b3274 100644
--- a/src/library-authoring/generic/manage-collections/ManageCollections.tsx
+++ b/src/library-authoring/generic/manage-collections/ManageCollections.tsx
@@ -16,6 +16,7 @@ import { ToastContext } from '../../../generic/toast-context';
import { CollectionMetadata } from '../../data/api';
import { useLibraryContext } from '../../common/context/LibraryContext';
import { SidebarActions, useSidebarContext } from '../../common/context/SidebarContext';
+import genericMessages from '../messages';
import messages from './messages';
interface ManageCollectionsProps {
@@ -50,9 +51,9 @@ const CollectionsSelectableBox = ({
const handleConfirmation = () => {
setBtnState('pending');
updateCollectionsMutation.mutateAsync(selectedCollections).then(() => {
- showToast(intl.formatMessage(messages.manageCollectionsToComponentSuccess));
+ showToast(intl.formatMessage(genericMessages.manageCollectionsSuccess));
}).catch(() => {
- showToast(intl.formatMessage(messages.manageCollectionsToComponentFailed));
+ showToast(intl.formatMessage(genericMessages.manageCollectionsFailed));
}).finally(() => {
setBtnState('default');
onClose();
diff --git a/src/library-authoring/generic/manage-collections/messages.ts b/src/library-authoring/generic/manage-collections/messages.ts
index c9b998be47..1afefa4967 100644
--- a/src/library-authoring/generic/manage-collections/messages.ts
+++ b/src/library-authoring/generic/manage-collections/messages.ts
@@ -21,16 +21,6 @@ const messages = defineMessages({
defaultMessage: 'Collection selection',
description: 'Aria label text for collection selection box',
},
- manageCollectionsToComponentSuccess: {
- id: 'course-authoring.library-authoring.manage-collections.add-success',
- defaultMessage: 'Item collections updated',
- description: 'Message to display on updating item collections',
- },
- manageCollectionsToComponentFailed: {
- id: 'course-authoring.library-authoring.manage-collections.add-failed',
- defaultMessage: 'Failed to update item collections',
- description: 'Message to display on failure of updating item collections',
- },
manageCollectionsToComponentConfirmBtn: {
id: 'course-authoring.library-authoring.manage-collections.add-confirm-btn',
defaultMessage: 'Confirm',
diff --git a/src/library-authoring/generic/messages.ts b/src/library-authoring/generic/messages.ts
new file mode 100644
index 0000000000..e1aec050f0
--- /dev/null
+++ b/src/library-authoring/generic/messages.ts
@@ -0,0 +1,16 @@
+import { defineMessages } from '@edx/frontend-platform/i18n';
+
+const messages = defineMessages({
+ manageCollectionsSuccess: {
+ id: 'course-authoring.library-authoring.manage-collections.success',
+ defaultMessage: 'Content added to collection.',
+ description: 'Message to display on updating item collections',
+ },
+ manageCollectionsFailed: {
+ id: 'course-authoring.library-authoring.manage-collections.failed',
+ defaultMessage: 'Failed to add content to collection.',
+ description: 'Message to display on failure of updating item collections',
+ },
+});
+
+export default messages;
diff --git a/src/library-authoring/units/LibraryUnitBlocks.tsx b/src/library-authoring/units/LibraryUnitBlocks.tsx
index 1ef20fa39a..43e985eb8c 100644
--- a/src/library-authoring/units/LibraryUnitBlocks.tsx
+++ b/src/library-authoring/units/LibraryUnitBlocks.tsx
@@ -28,7 +28,7 @@ import {
useUpdateXBlockFields,
} from '../data/apiHooks';
import { LibraryBlock } from '../LibraryBlock';
-import { useLibraryRoutes } from '../routes';
+import { useLibraryRoutes, ContentType } from '../routes';
import messages from './messages';
import { useSidebarContext } from '../common/context/SidebarContext';
import { ToastContext } from '../../generic/toast-context';
@@ -200,8 +200,10 @@ export const LibraryUnitBlocks = ({ preview }: LibraryUnitBlocksProps) => {
);
};
- const renderedBlocks = orderedBlocks?.map((block) => (
-
+ const renderedBlocks = orderedBlocks?.map((block, idx) => (
+ // A container can have multiple instances of the same block
+ // eslint-disable-next-line react/no-array-index-key
+
{
disabled={preview}
>
{hidePreviewFor !== block.id && (
-
-
-
+
+
+
)}
@@ -245,7 +247,7 @@ export const LibraryUnitBlocks = ({ preview }: LibraryUnitBlocksProps) => {
>
{renderedBlocks}
- { !preview && (
+ {!preview && (
diff --git a/src/library-authoring/units/LibraryUnitPage.tsx b/src/library-authoring/units/LibraryUnitPage.tsx
index e362cdb900..a84bed2a9f 100644
--- a/src/library-authoring/units/LibraryUnitPage.tsx
+++ b/src/library-authoring/units/LibraryUnitPage.tsx
@@ -137,7 +137,7 @@ export const LibraryUnitPage = () => {
setDefaultTab({
collection: COLLECTION_INFO_TABS.Details,
component: COMPONENT_INFO_TABS.Manage,
- unit: UNIT_INFO_TABS.Organize,
+ unit: UNIT_INFO_TABS.Manage,
});
setHiddenTabs([COMPONENT_INFO_TABS.Preview, UNIT_INFO_TABS.Preview]);
return () => {
diff --git a/src/search-manager/data/api.ts b/src/search-manager/data/api.ts
index 549054b3fe..e1a6aeaa33 100644
--- a/src/search-manager/data/api.ts
+++ b/src/search-manager/data/api.ts
@@ -50,6 +50,7 @@ export const getContentSearchConfig = async (): Promise<{ url: string, indexName
export interface ContentDetails {
htmlContent?: string;
capaContent?: string;
+ childUsageKeys?: Array;
[k: string]: any;
}
@@ -151,9 +152,10 @@ export interface ContentHit extends BaseContentHit {
* Defined in edx-platform/openedx/core/djangoapps/content/search/documents.py
*/
export interface ContentPublishedData {
- description?: string,
- displayName?: string,
- numChildren?: number,
+ description?: string;
+ displayName?: string;
+ numChildren?: number;
+ content?: ContentDetails;
}
/**
@@ -171,6 +173,9 @@ export interface CollectionHit extends BaseContentHit {
* Information about a single container returned in the search results
* Defined in edx-platform/openedx/core/djangoapps/content/search/documents.py
*/
+interface ContainerHitContent {
+ childUsageKeys?: string[],
+}
export interface ContainerHit extends BaseContentHit {
type: 'library_container';
blockType: 'unit'; // This should be expanded to include other container types
@@ -178,6 +183,7 @@ export interface ContainerHit extends BaseContentHit {
published?: ContentPublishedData;
publishStatus: PublishStatus;
formatted: BaseContentHit['formatted'] & { published?: ContentPublishedData, };
+ content?: ContainerHitContent;
}
export type HitType = ContentHit | CollectionHit | ContainerHit;