From db898a8bc4624cac626b63ad614623c3cb2b1976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Penido?= Date: Fri, 9 Feb 2024 18:07:44 -0300 Subject: [PATCH 1/6] feat: add export course tags menu --- src/header/messages.js | 7 ++++++- src/header/utils.js | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/header/messages.js b/src/header/messages.js index f9877c75ec..075e264857 100644 --- a/src/header/messages.js +++ b/src/header/messages.js @@ -93,9 +93,14 @@ const messages = defineMessages({ }, 'header.links.export': { id: 'header.links.export', - defaultMessage: 'Export', + 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', diff --git a/src/header/utils.js b/src/header/utils.js index e019b32147..7e62a95cf4 100644 --- a/src/header/utils.js +++ b/src/header/utils.js @@ -66,7 +66,12 @@ export const getToolsMenuItems = ({ studioBaseUrl, courseId, intl }) => ([ { 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}/checklists/${courseId}`, title: intl.formatMessage(messages['header.links.checklists']), }, 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 2/6] 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); + }); + }); }); From c4c7daa87706b4593539ba25da7e725192ef4f3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Penido?= Date: Thu, 15 Feb 2024 10:23:56 -0300 Subject: [PATCH 3/6] style: fix eslint --- src/header/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/header/utils.js b/src/header/utils.js index ede6bfbe4b..96055461cd 100644 --- a/src/header/utils.js +++ b/src/header/utils.js @@ -68,7 +68,7 @@ export const getToolsMenuItems = ({ studioBaseUrl, courseId, intl }) => ([ title: intl.formatMessage( getConfig().ENABLE_TAGGING_TAXONOMY_PAGES === 'true' ? messages['header.links.exportCourse'] - : messages['header.links.export'] + : messages['header.links.export'], ), }, ...(getConfig().ENABLE_TAGGING_TAXONOMY_PAGES === 'true' From effca983e2c8798eb00a1c67d4e510ee4bffcd31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Penido?= Date: Fri, 16 Feb 2024 10:34:58 -0300 Subject: [PATCH 4/6] test: check menu titles instead of count --- src/header/utils.test.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/header/utils.test.js b/src/header/utils.test.js index 5642522793..a5451c8288 100644 --- a/src/header/utils.test.js +++ b/src/header/utils.test.js @@ -5,7 +5,7 @@ const props = { studioBaseUrl: 'UrLSTuiO', courseId: '123', intl: { - formatMessage: jest.fn(), + formatMessage: jest.fn(message => message.defaultMessage), }, }; @@ -28,22 +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 actualItems = getToolsMenuItems(props); - expect(actualItems).toHaveLength(4); + 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 actualItems = getToolsMenuItems(props); - expect(actualItems).toHaveLength(3); + const actualItemsTitle = getToolsMenuItems(props).map((item) => item.title); + expect(actualItemsTitle).toEqual([ + 'Import', + 'Export', + 'Checklists', + ]); }); }); }); From 20727dccdf5d85fef4f3788050e878218714f7e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Penido?= Date: Fri, 16 Feb 2024 15:33:52 -0300 Subject: [PATCH 5/6] fix: using only one string for Export Course --- src/header/messages.js | 5 ----- src/header/utils.js | 6 +----- src/header/utils.test.js | 2 +- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/header/messages.js b/src/header/messages.js index 37da407941..794d83743a 100644 --- a/src/header/messages.js +++ b/src/header/messages.js @@ -91,11 +91,6 @@ const messages = defineMessages({ defaultMessage: 'Import', description: 'Link to Studio Import page', }, - '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', diff --git a/src/header/utils.js b/src/header/utils.js index 96055461cd..d6c73d161b 100644 --- a/src/header/utils.js +++ b/src/header/utils.js @@ -65,11 +65,7 @@ export const getToolsMenuItems = ({ studioBaseUrl, courseId, intl }) => ([ }, { href: `${studioBaseUrl}/import/${courseId}`, - title: intl.formatMessage( - getConfig().ENABLE_TAGGING_TAXONOMY_PAGES === 'true' - ? messages['header.links.exportCourse'] - : messages['header.links.export'], - ), + title: intl.formatMessage(messages['header.links.exportCourse']), }, ...(getConfig().ENABLE_TAGGING_TAXONOMY_PAGES === 'true' ? [{ diff --git a/src/header/utils.test.js b/src/header/utils.test.js index a5451c8288..afcb5da24d 100644 --- a/src/header/utils.test.js +++ b/src/header/utils.test.js @@ -51,7 +51,7 @@ describe('header utils', () => { const actualItemsTitle = getToolsMenuItems(props).map((item) => item.title); expect(actualItemsTitle).toEqual([ 'Import', - 'Export', + 'Export Course', 'Checklists', ]); }); From d0b1bec109f6c6e266653c3a2f42d74611b05124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Penido?= Date: Tue, 20 Feb 2024 10:02:57 -0300 Subject: [PATCH 6/6] fix: wrong link --- src/header/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/header/utils.js b/src/header/utils.js index d6c73d161b..c1de7e0923 100644 --- a/src/header/utils.js +++ b/src/header/utils.js @@ -64,7 +64,7 @@ export const getToolsMenuItems = ({ studioBaseUrl, courseId, intl }) => ([ title: intl.formatMessage(messages['header.links.import']), }, { - href: `${studioBaseUrl}/import/${courseId}`, + href: `${studioBaseUrl}/export/${courseId}`, title: intl.formatMessage(messages['header.links.exportCourse']), }, ...(getConfig().ENABLE_TAGGING_TAXONOMY_PAGES === 'true'