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.
This commit is contained in:
@@ -91,11 +91,16 @@ const messages = defineMessages({
|
||||
defaultMessage: 'Import',
|
||||
description: 'Link to Studio Import page',
|
||||
},
|
||||
'header.links.export': {
|
||||
id: 'header.links.export',
|
||||
defaultMessage: 'Export',
|
||||
'header.links.exportCourse': {
|
||||
id: 'header.links.exportCourse',
|
||||
defaultMessage: 'Export Course',
|
||||
description: 'Link to Studio Export page',
|
||||
},
|
||||
'header.links.exportTags': {
|
||||
id: 'header.links.exportTags',
|
||||
defaultMessage: 'Export Tags',
|
||||
description: 'Download course content tags as CSV',
|
||||
},
|
||||
'header.links.checklists': {
|
||||
id: 'header.links.checklists',
|
||||
defaultMessage: 'Checklists',
|
||||
|
||||
@@ -65,8 +65,15 @@ export const getToolsMenuItems = ({ studioBaseUrl, courseId, intl }) => ([
|
||||
},
|
||||
{
|
||||
href: `${studioBaseUrl}/export/${courseId}`,
|
||||
title: intl.formatMessage(messages['header.links.export']),
|
||||
}, {
|
||||
title: intl.formatMessage(messages['header.links.exportCourse']),
|
||||
},
|
||||
...(getConfig().ENABLE_TAGGING_TAXONOMY_PAGES === 'true'
|
||||
? [{
|
||||
href: `${studioBaseUrl}/api/content_tagging/v1/object_tags/${courseId}/export/`,
|
||||
title: intl.formatMessage(messages['header.links.exportTags']),
|
||||
}] : []
|
||||
),
|
||||
{
|
||||
href: `${studioBaseUrl}/checklists/${courseId}`,
|
||||
title: intl.formatMessage(messages['header.links.checklists']),
|
||||
},
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { getConfig, setConfig } from '@edx/frontend-platform';
|
||||
import { getContentMenuItems } from './utils';
|
||||
import { getContentMenuItems, getToolsMenuItems } from './utils';
|
||||
|
||||
const props = {
|
||||
studioBaseUrl: 'UrLSTuiO',
|
||||
courseId: '123',
|
||||
intl: {
|
||||
formatMessage: jest.fn(),
|
||||
formatMessage: jest.fn(message => message.defaultMessage),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -28,4 +28,32 @@ describe('header utils', () => {
|
||||
expect(actualItems).toHaveLength(4);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getToolsMenuItems', () => {
|
||||
it('should include export tags option', () => {
|
||||
setConfig({
|
||||
...getConfig(),
|
||||
ENABLE_TAGGING_TAXONOMY_PAGES: 'true',
|
||||
});
|
||||
const actualItemsTitle = getToolsMenuItems(props).map((item) => item.title);
|
||||
expect(actualItemsTitle).toEqual([
|
||||
'Import',
|
||||
'Export Course',
|
||||
'Export Tags',
|
||||
'Checklists',
|
||||
]);
|
||||
});
|
||||
it('should not include export tags option', () => {
|
||||
setConfig({
|
||||
...getConfig(),
|
||||
ENABLE_TAGGING_TAXONOMY_PAGES: 'false',
|
||||
});
|
||||
const actualItemsTitle = getToolsMenuItems(props).map((item) => item.title);
|
||||
expect(actualItemsTitle).toEqual([
|
||||
'Import',
|
||||
'Export Course',
|
||||
'Checklists',
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user