feat: show children count in collection card (#1298)
This commit is contained in:
@@ -17,6 +17,7 @@ const CollectionHitSample: CollectionHit = {
|
||||
},
|
||||
created: 1722434322294,
|
||||
modified: 1722434322294,
|
||||
numChildren: 2,
|
||||
tags: {},
|
||||
};
|
||||
|
||||
@@ -32,7 +33,8 @@ describe('<CollectionCard />', () => {
|
||||
it('should render the card with title and description', () => {
|
||||
render(<CollectionCard collectionHit={CollectionHitSample} />);
|
||||
|
||||
expect(screen.getByText('Collection Display Formated Name')).toBeInTheDocument();
|
||||
expect(screen.getByText('Collection description')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Collection Display Formated Name')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Collection description')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Collection (2)')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,8 +21,13 @@ const CollectionCard = ({ collectionHit } : CollectionCardProps) => {
|
||||
type,
|
||||
formatted,
|
||||
tags,
|
||||
numChildren,
|
||||
} = collectionHit;
|
||||
const { displayName = '', description = '' } = formatted;
|
||||
const blockTypeDisplayName = numChildren ? intl.formatMessage(
|
||||
messages.collectionTypeWithCount,
|
||||
{ numChildren },
|
||||
) : intl.formatMessage(messages.collectionType);
|
||||
|
||||
return (
|
||||
<BaseComponentCard
|
||||
@@ -40,7 +45,7 @@ const CollectionCard = ({ collectionHit } : CollectionCardProps) => {
|
||||
/>
|
||||
</ActionRow>
|
||||
)}
|
||||
blockTypeDisplayName={intl.formatMessage(messages.collectionType)}
|
||||
blockTypeDisplayName={blockTypeDisplayName}
|
||||
openInfoSidebar={() => {}}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -16,6 +16,11 @@ const messages = defineMessages({
|
||||
defaultMessage: 'Collection',
|
||||
description: 'Collection type text',
|
||||
},
|
||||
collectionTypeWithCount: {
|
||||
id: 'course-authoring.library-authoring.collection.type-with-count',
|
||||
defaultMessage: 'Collection ({numChildren})',
|
||||
description: 'Collection type text with children count',
|
||||
},
|
||||
menuEdit: {
|
||||
id: 'course-authoring.library-authoring.component.menu.edit',
|
||||
defaultMessage: 'Edit',
|
||||
|
||||
@@ -135,7 +135,7 @@ export interface ContentHit extends BaseContentHit {
|
||||
*/
|
||||
export interface CollectionHit extends BaseContentHit {
|
||||
description: string;
|
||||
componentCount?: number;
|
||||
numChildren?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user