diff --git a/contentcuration/contentcuration/frontend/shared/utils/__tests__/colors.spec.js b/contentcuration/contentcuration/frontend/shared/utils/__tests__/colors.spec.js
new file mode 100644
index 0000000000..551962a5b2
--- /dev/null
+++ b/contentcuration/contentcuration/frontend/shared/utils/__tests__/colors.spec.js
@@ -0,0 +1,25 @@
+import { themePalette, themeTokens } from 'kolibri-design-system/lib/styles/theme';
+import { getContentKindColor } from '../colors';
+
+describe('getContentKindColor', () => {
+ const tokens = themeTokens();
+ const palette = themePalette();
+
+ it.each([
+ ['video', tokens.watch],
+ ['audio', tokens.listen],
+ ['document', tokens.read],
+ ['slideshow', tokens.read],
+ ['exercise', tokens.practice],
+ ['html5', tokens.explore],
+ ['h5p', tokens.explore],
+ ['zim', tokens.explore],
+ ['topic', palette.grey.v_400],
+ ])('returns the KDS color for %s', (kind, expected) => {
+ expect(getContentKindColor(kind)).toBe(expected);
+ });
+
+ it.each(['unsupported', undefined, null, ''])('falls back to grey for %s', kind => {
+ expect(getContentKindColor(kind)).toBe(palette.grey.v_400);
+ });
+});
diff --git a/contentcuration/contentcuration/frontend/shared/utils/__tests__/icons.spec.js b/contentcuration/contentcuration/frontend/shared/utils/__tests__/icons.spec.js
new file mode 100644
index 0000000000..12d3f7b753
--- /dev/null
+++ b/contentcuration/contentcuration/frontend/shared/utils/__tests__/icons.spec.js
@@ -0,0 +1,27 @@
+import { getContentKindIcon } from '../icons';
+
+describe('getContentKindIcon', () => {
+ it.each([
+ ['topic', 'topic'],
+ ['video', 'video'],
+ ['audio', 'audio'],
+ ['slideshow', 'slideshow'],
+ ['exercise', 'exercise'],
+ ['document', 'document'],
+ ['html5', 'html5'],
+ ['h5p', 'html5'],
+ ['zim', 'html5'],
+ ['unsupported', 'error'],
+ ])('maps %s to %s', (kind, icon) => {
+ expect(getContentKindIcon(kind)).toBe(icon);
+ });
+
+ it('uses the empty-topic icon only when a topic is empty', () => {
+ expect(getContentKindIcon('topic', true)).toBe('emptyTopic');
+ expect(getContentKindIcon('h5p', true)).toBe('html5');
+ });
+
+ it('throws when a kind has no mapping', () => {
+ expect(() => getContentKindIcon('missing')).toThrow('Icon not found for content kind: missing');
+ });
+});
diff --git a/contentcuration/contentcuration/frontend/shared/utils/colors.js b/contentcuration/contentcuration/frontend/shared/utils/colors.js
new file mode 100644
index 0000000000..9df21bf388
--- /dev/null
+++ b/contentcuration/contentcuration/frontend/shared/utils/colors.js
@@ -0,0 +1,19 @@
+import { themePalette, themeTokens } from 'kolibri-design-system/lib/styles/theme';
+import { ContentKindsNames } from 'shared/leUtils/ContentKinds';
+
+export function getContentKindColor(kind) {
+ const palette = themePalette();
+ const tokens = themeTokens();
+ const colors = {
+ [ContentKindsNames.TOPIC]: palette.grey.v_400,
+ [ContentKindsNames.VIDEO]: tokens.watch,
+ [ContentKindsNames.AUDIO]: tokens.listen,
+ [ContentKindsNames.DOCUMENT]: tokens.read,
+ [ContentKindsNames.SLIDESHOW]: tokens.read,
+ [ContentKindsNames.EXERCISE]: tokens.practice,
+ [ContentKindsNames.H5P]: tokens.explore,
+ [ContentKindsNames.HTML5]: tokens.explore,
+ [ContentKindsNames.ZIM]: tokens.explore,
+ };
+ return colors[kind] || palette.grey.v_400;
+}
diff --git a/contentcuration/contentcuration/frontend/shared/utils/icons.js b/contentcuration/contentcuration/frontend/shared/utils/icons.js
index cd07955e3c..508d193098 100644
--- a/contentcuration/contentcuration/frontend/shared/utils/icons.js
+++ b/contentcuration/contentcuration/frontend/shared/utils/icons.js
@@ -9,8 +9,12 @@ const CONTENT_KIND_ICONS = {
[ContentKindsNames.SLIDESHOW]: 'slideshow',
[ContentKindsNames.EXERCISE]: 'exercise',
[ContentKindsNames.DOCUMENT]: 'document',
+ [ContentKindsNames.H5P]: 'html5',
[ContentKindsNames.HTML5]: 'html5',
[ContentKindsNames.ZIM]: 'html5',
+ // Not a content kind. Base Vuetify uses error_outline; KDS has no such token.
+ // Unknown kinds still throw below.
+ unsupported: 'error',
};
export function getContentKindIcon(kind, isEmpty = false) {
diff --git a/contentcuration/contentcuration/frontend/shared/views/StudioContentNodeIcon.vue b/contentcuration/contentcuration/frontend/shared/views/StudioContentNodeIcon.vue
new file mode 100644
index 0000000000..21add31e2c
--- /dev/null
+++ b/contentcuration/contentcuration/frontend/shared/views/StudioContentNodeIcon.vue
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/contentcuration/contentcuration/frontend/shared/views/__tests__/StudioContentNodeIcon.spec.js b/contentcuration/contentcuration/frontend/shared/views/__tests__/StudioContentNodeIcon.spec.js
new file mode 100644
index 0000000000..ea42e17b6c
--- /dev/null
+++ b/contentcuration/contentcuration/frontend/shared/views/__tests__/StudioContentNodeIcon.spec.js
@@ -0,0 +1,70 @@
+import { render } from '@testing-library/vue';
+import Vue from 'vue';
+import VueRouter from 'vue-router';
+import KIcon from 'kolibri-design-system/lib/KIcon';
+import StudioContentNodeIcon from '../StudioContentNodeIcon.vue';
+import { getContentKindColor } from 'shared/utils/colors';
+import { getContentKindIcon } from 'shared/utils/icons';
+
+const renderComponent = (props = {}) =>
+ render(StudioContentNodeIcon, { props, routes: new VueRouter() });
+
+const renderIcon = icon => render(KIcon, { props: { icon }, routes: new VueRouter() });
+
+function iconShape(container) {
+ const paths = [...container.querySelectorAll('svg path')].map(path => path.getAttribute('d'));
+ expect(paths.length).toBeGreaterThan(0);
+ return paths.join('|');
+}
+
+describe('StudioContentNodeIcon', () => {
+ it.each(['topic', 'video', 'audio', 'exercise', 'document', 'slideshow', 'html5', 'h5p', 'zim'])(
+ 'renders the %s icon on its content-kind background',
+ kind => {
+ const { container } = renderComponent({ kind });
+ const chip = container.querySelector('.studio-content-node-icon');
+
+ expect(chip).toHaveStyle({ backgroundColor: getContentKindColor(kind) });
+ expect(iconShape(container)).toBe(iconShape(renderIcon(getContentKindIcon(kind)).container));
+ },
+ );
+
+ it('uses the html5 glyph for h5p', () => {
+ const h5p = iconShape(renderComponent({ kind: 'h5p' }).container);
+ const html5 = iconShape(renderComponent({ kind: 'html5' }).container);
+ const video = iconShape(renderComponent({ kind: 'video' }).container);
+
+ expect(h5p).toBe(html5);
+ expect(h5p).not.toBe(video);
+ });
+
+ it('renders the error icon for an unsupported kind', () => {
+ const { container } = renderComponent({ kind: 'unsupported' });
+ const chip = container.querySelector('.studio-content-node-icon');
+
+ expect(chip).toHaveStyle({ backgroundColor: getContentKindColor('unsupported') });
+ expect(iconShape(container)).toBe(iconShape(renderIcon('error').container));
+ });
+
+ it('does not swallow a missing icon mapping', () => {
+ const errorHandler = jest.fn();
+ const previous = Vue.config.errorHandler;
+ Vue.config.errorHandler = errorHandler;
+
+ try {
+ renderComponent({ kind: 'missing' });
+
+ expect(errorHandler).toHaveBeenCalled();
+ expect(errorHandler.mock.calls[0][0]).toEqual(
+ expect.objectContaining({ message: 'Icon not found for content kind: missing' }),
+ );
+ } finally {
+ Vue.config.errorHandler = previous;
+ }
+ });
+
+ it('is marked to be captured as an image in PDF exports', () => {
+ const { container } = renderComponent({ kind: 'video' });
+ expect(container.querySelector('[capture-as-image]')).toBeInTheDocument();
+ });
+});
diff --git a/contentcuration/contentcuration/frontend/shared/views/__tests__/StudioDetailsPanel.spec.js b/contentcuration/contentcuration/frontend/shared/views/__tests__/StudioDetailsPanel.spec.js
index 9c03e95b26..282232f950 100644
--- a/contentcuration/contentcuration/frontend/shared/views/__tests__/StudioDetailsPanel.spec.js
+++ b/contentcuration/contentcuration/frontend/shared/views/__tests__/StudioDetailsPanel.spec.js
@@ -1,4 +1,4 @@
-import { render, screen } from '@testing-library/vue';
+import { render, screen, within } from '@testing-library/vue';
import VueRouter from 'vue-router';
import ContentLevels from 'kolibri-constants/labels/Levels';
import Categories from 'kolibri-constants/labels/Subjects';
@@ -115,4 +115,30 @@ describe('StudioDetailsPanel', () => {
expect(placeholders.length).toBeGreaterThan(0);
});
});
+ describe('total resources', () => {
+ it('lists each content kind with its translated label and count', () => {
+ renderComponent({
+ details: {
+ ...fullChannel,
+ kind_count: [
+ { kind_id: 'video', count: 30 },
+ { kind_id: 'exercise', count: 12 },
+ { kind_id: 'h5p', count: 7 },
+ ],
+ },
+ loading: false,
+ });
+
+ [
+ ['Video', '30'],
+ ['Exercise', '12'],
+ ['H5P App', '7'],
+ ].forEach(([label, count]) => {
+ const row = screen.getByText(label).closest('.resource-item');
+ expect(row).not.toBeNull();
+ expect(within(row).getByText(count)).toBeInTheDocument();
+ expect(row.querySelector('.studio-content-node-icon svg')).toBeInTheDocument();
+ });
+ });
+ });
});
diff --git a/contentcuration/contentcuration/frontend/shared/views/details/StudioDetailsPanel.vue b/contentcuration/contentcuration/frontend/shared/views/details/StudioDetailsPanel.vue
index 2ea3acd384..fc7eb1c94d 100644
--- a/contentcuration/contentcuration/frontend/shared/views/details/StudioDetailsPanel.vue
+++ b/contentcuration/contentcuration/frontend/shared/views/details/StudioDetailsPanel.vue
@@ -106,7 +106,7 @@
>
-
@@ -445,7 +445,7 @@
metadataTranslationMixin,
} from '../../mixins';
import { CategoriesLookup, LevelsLookup } from '../../constants';
- import ContentNodeIcon from '../ContentNodeIcon';
+ import StudioContentNodeIcon from '../StudioContentNodeIcon';
import ExpandableList from '../ExpandableList';
import StudioChip from '../StudioChip';
import StudioLargeLoader from '../StudioLargeLoader';
@@ -495,7 +495,7 @@
name: 'StudioDetailsPanel',
components: {
StudioLargeLoader,
- ContentNodeIcon,
+ StudioContentNodeIcon,
ExpandableList,
StudioCopyToken,
StudioDetailsRow,