{
- data.slice(0, showMaxChildren).map(({ id, blockType, displayName }, idx) => {
+ childUsageKeys.slice(0, showMaxChildren).map((usageKey, idx) => {
+ const blockType = getBlockType(usageKey);
let blockPreview: ReactNode;
let classNames;
@@ -133,7 +130,7 @@ const ContainerCardPreview = ({ containerId, showMaxChildren = 5 }: ContainerCar
);
} else {
@@ -149,7 +146,7 @@ const ContainerCardPreview = ({ containerId, showMaxChildren = 5 }: ContainerCar
{blockPreview}
@@ -178,6 +175,7 @@ const ContainerCard = ({ hit } : ContainerCardProps) => {
published,
publishStatus,
usageKey: unitId,
+ content,
} = hit;
const numChildrenCount = showOnlyPublished ? (
@@ -188,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(() => {
@@ -202,7 +204,7 @@ const ContainerCard = ({ hit } : ContainerCardProps) => {
}
+ preview={}
tags={tags}
numChildren={numChildrenCount}
actions={(
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;