Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
feat: add export library tags menu [FC-0049] (#412)
Browse files Browse the repository at this point in the history
* feat: add export library tags menu

* test: check menu titles instead of count

* fix: remove flag check
  • Loading branch information
rpenido authored Mar 5, 2024
1 parent de8582a commit 4df5d5b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/library-authoring/studio-header-wrapper/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ const messages = defineMessages({
defaultMessage: 'Import',
description: 'Text for the import course in the settings menu.',
},
'library.header.settings.exportTags': {
id: 'library.header.settings.exportTags',
defaultMessage: 'Export Tags',
description: 'Download library content tags as CSV',
},
'library.header.nav.help.title': {
id: 'library.header.nav.help.title',
defaultMessage: 'Online help',
Expand Down
15 changes: 13 additions & 2 deletions src/library-authoring/studio-header-wrapper/specs/utils.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { LOADING_STATUS } from '../../common';
import { getMainMenuDropdown, getOutlineLink } from '../utils';

const intl = {
formatMessage: jest.fn(message => message.defaultMessage),
};

describe('studio header wrapper utils', () => {
describe('getOutlineLink', () => {
it('should return /library/:libraryId', () => {
Expand All @@ -19,11 +23,18 @@ describe('studio header wrapper utils', () => {
});
});
describe('getMainMenuDropdown', () => {
it('should return an array of length 1', () => {
it('should return an array of length 1 and correct items', () => {
const libraryId = 'testId';
const loadingStatus = LOADING_STATUS.LOADED;
const dropdownArray = getMainMenuDropdown(loadingStatus, libraryId, { formatMessage: jest.fn() });
const dropdownArray = getMainMenuDropdown(loadingStatus, libraryId, intl);
expect(dropdownArray).toHaveLength(1);
const subItemTitles = dropdownArray[0].items.map(item => item.title);
expect(subItemTitles).toEqual([
'Details',
'User access',
'Export Tags',
'Import',
]);
});
it('should return an empty array', () => {
const libraryId = 'testId';
Expand Down
5 changes: 5 additions & 0 deletions src/library-authoring/studio-header-wrapper/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getConfig } from '@edx/frontend-platform';
import { LOADING_STATUS, ROUTES } from '../common';
import messages from './messages';

Expand All @@ -23,6 +24,10 @@ export const getMainMenuDropdown = (loadingStatus, libraryId, intl) => {
href: ROUTES.Detail.ACCESS_SLUG(libraryId),
title: intl.formatMessage(messages['library.header.settings.access']),
},
{
href: `${getConfig().STUDIO_BASE_URL}/api/content_tagging/v1/object_tags/${libraryId}/export/`,
title: intl.formatMessage(messages['library.header.settings.exportTags']),
},
{
href: ROUTES.Detail.IMPORT_SLUG(libraryId),
title: intl.formatMessage(messages['library.header.settings.import']),
Expand Down

0 comments on commit 4df5d5b

Please sign in to comment.