From 873b90237967514a664680d4f0475b64a8f2ea1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Penido?= Date: Thu, 15 Feb 2024 10:11:46 -0300 Subject: [PATCH] fix: check taggng flag and add tests --- src/header/messages.js | 5 +++++ src/header/utils.js | 18 ++++++++++++------ src/header/utils.test.js | 20 +++++++++++++++++++- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/header/messages.js b/src/header/messages.js index 075e264857..37da407941 100644 --- a/src/header/messages.js +++ b/src/header/messages.js @@ -93,6 +93,11 @@ const messages = defineMessages({ }, 'header.links.export': { id: 'header.links.export', + defaultMessage: 'Export', + description: 'Link to Studio Export page', + }, + 'header.links.exportCourse': { + id: 'header.links.exportCourse', defaultMessage: 'Export Course', description: 'Link to Studio Export page', }, diff --git a/src/header/utils.js b/src/header/utils.js index 7e62a95cf4..ede6bfbe4b 100644 --- a/src/header/utils.js +++ b/src/header/utils.js @@ -64,13 +64,19 @@ export const getToolsMenuItems = ({ studioBaseUrl, courseId, intl }) => ([ title: intl.formatMessage(messages['header.links.import']), }, { - href: `${studioBaseUrl}/export/${courseId}`, - title: intl.formatMessage(messages['header.links.export']), - }, - { - href: `${studioBaseUrl}/api/content_tagging/v1/object_tags/${courseId}/export/`, - title: intl.formatMessage(messages['header.links.exportTags']), + href: `${studioBaseUrl}/import/${courseId}`, + title: intl.formatMessage( + getConfig().ENABLE_TAGGING_TAXONOMY_PAGES === 'true' + ? messages['header.links.exportCourse'] + : messages['header.links.export'] + ), }, + ...(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']), diff --git a/src/header/utils.test.js b/src/header/utils.test.js index 35072db885..5642522793 100644 --- a/src/header/utils.test.js +++ b/src/header/utils.test.js @@ -1,5 +1,5 @@ import { getConfig, setConfig } from '@edx/frontend-platform'; -import { getContentMenuItems } from './utils'; +import { getContentMenuItems, getToolsMenuItems } from './utils'; const props = { studioBaseUrl: 'UrLSTuiO', @@ -28,4 +28,22 @@ describe('header utils', () => { expect(actualItems).toHaveLength(4); }); }); + describe('getToolsMenuItems', () => { + it('should include export tags option', () => { + setConfig({ + ...getConfig(), + ENABLE_TAGGING_TAXONOMY_PAGES: 'true', + }); + const actualItems = getToolsMenuItems(props); + expect(actualItems).toHaveLength(4); + }); + it('should not include export tags option', () => { + setConfig({ + ...getConfig(), + ENABLE_TAGGING_TAXONOMY_PAGES: 'false', + }); + const actualItems = getToolsMenuItems(props); + expect(actualItems).toHaveLength(3); + }); + }); });