From 4df5d5b93e6f9056339ae90d8ba3e51d4a2e3d74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Penido?= Date: Tue, 5 Mar 2024 03:51:15 -0300 Subject: [PATCH] feat: add export library tags menu [FC-0049] (#412) * feat: add export library tags menu * test: check menu titles instead of count * fix: remove flag check --- .../studio-header-wrapper/messages.js | 5 +++++ .../studio-header-wrapper/specs/utils.spec.js | 15 +++++++++++++-- .../studio-header-wrapper/utils.js | 5 +++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/library-authoring/studio-header-wrapper/messages.js b/src/library-authoring/studio-header-wrapper/messages.js index 804a0e12..b702c754 100644 --- a/src/library-authoring/studio-header-wrapper/messages.js +++ b/src/library-authoring/studio-header-wrapper/messages.js @@ -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', diff --git a/src/library-authoring/studio-header-wrapper/specs/utils.spec.js b/src/library-authoring/studio-header-wrapper/specs/utils.spec.js index e02d2972..95f70dad 100644 --- a/src/library-authoring/studio-header-wrapper/specs/utils.spec.js +++ b/src/library-authoring/studio-header-wrapper/specs/utils.spec.js @@ -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', () => { @@ -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'; diff --git a/src/library-authoring/studio-header-wrapper/utils.js b/src/library-authoring/studio-header-wrapper/utils.js index 4535dd11..3cb9f133 100644 --- a/src/library-authoring/studio-header-wrapper/utils.js +++ b/src/library-authoring/studio-header-wrapper/utils.js @@ -1,3 +1,4 @@ +import { getConfig } from '@edx/frontend-platform'; import { LOADING_STATUS, ROUTES } from '../common'; import messages from './messages'; @@ -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']),