Skip to content

Commit 0fc0ce0

Browse files
authored
feat: add export course tags menu (#830)
This change adds an item in the Tools menu to export the course tags to a CSV file.
1 parent 16d2f38 commit 0fc0ce0

File tree

3 files changed

+47
-7
lines changed

3 files changed

+47
-7
lines changed

src/header/messages.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,16 @@ const messages = defineMessages({
9191
defaultMessage: 'Import',
9292
description: 'Link to Studio Import page',
9393
},
94-
'header.links.export': {
95-
id: 'header.links.export',
96-
defaultMessage: 'Export',
94+
'header.links.exportCourse': {
95+
id: 'header.links.exportCourse',
96+
defaultMessage: 'Export Course',
9797
description: 'Link to Studio Export page',
9898
},
99+
'header.links.exportTags': {
100+
id: 'header.links.exportTags',
101+
defaultMessage: 'Export Tags',
102+
description: 'Download course content tags as CSV',
103+
},
99104
'header.links.checklists': {
100105
id: 'header.links.checklists',
101106
defaultMessage: 'Checklists',

src/header/utils.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,15 @@ export const getToolsMenuItems = ({ studioBaseUrl, courseId, intl }) => ([
6565
},
6666
{
6767
href: `${studioBaseUrl}/export/${courseId}`,
68-
title: intl.formatMessage(messages['header.links.export']),
69-
}, {
68+
title: intl.formatMessage(messages['header.links.exportCourse']),
69+
},
70+
...(getConfig().ENABLE_TAGGING_TAXONOMY_PAGES === 'true'
71+
? [{
72+
href: `${studioBaseUrl}/api/content_tagging/v1/object_tags/${courseId}/export/`,
73+
title: intl.formatMessage(messages['header.links.exportTags']),
74+
}] : []
75+
),
76+
{
7077
href: `${studioBaseUrl}/checklists/${courseId}`,
7178
title: intl.formatMessage(messages['header.links.checklists']),
7279
},

src/header/utils.test.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { getConfig, setConfig } from '@edx/frontend-platform';
2-
import { getContentMenuItems } from './utils';
2+
import { getContentMenuItems, getToolsMenuItems } from './utils';
33

44
const props = {
55
studioBaseUrl: 'UrLSTuiO',
66
courseId: '123',
77
intl: {
8-
formatMessage: jest.fn(),
8+
formatMessage: jest.fn(message => message.defaultMessage),
99
},
1010
};
1111

@@ -28,4 +28,32 @@ describe('header utils', () => {
2828
expect(actualItems).toHaveLength(4);
2929
});
3030
});
31+
32+
describe('getToolsMenuItems', () => {
33+
it('should include export tags option', () => {
34+
setConfig({
35+
...getConfig(),
36+
ENABLE_TAGGING_TAXONOMY_PAGES: 'true',
37+
});
38+
const actualItemsTitle = getToolsMenuItems(props).map((item) => item.title);
39+
expect(actualItemsTitle).toEqual([
40+
'Import',
41+
'Export Course',
42+
'Export Tags',
43+
'Checklists',
44+
]);
45+
});
46+
it('should not include export tags option', () => {
47+
setConfig({
48+
...getConfig(),
49+
ENABLE_TAGGING_TAXONOMY_PAGES: 'false',
50+
});
51+
const actualItemsTitle = getToolsMenuItems(props).map((item) => item.title);
52+
expect(actualItemsTitle).toEqual([
53+
'Import',
54+
'Export Course',
55+
'Checklists',
56+
]);
57+
});
58+
});
3159
});

0 commit comments

Comments
 (0)