From dcab4f1b757c9d98ee6f46ffd1bdfacc0f23a502 Mon Sep 17 00:00:00 2001 From: diana-villalvazo-wgu Date: Wed, 21 May 2025 11:21:31 -0600 Subject: [PATCH] feat: add NON_BROWSABLE_COURSES to MFE config (#620) --- .env | 1 + .env.development | 1 + .env.test | 1 + src/config/index.js | 1 + .../LearnerDashboardHeader/LearnerDashboardMenu.jsx | 5 +++-- src/containers/LearnerDashboardHeader/index.test.jsx | 5 +++++ 6 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.env b/.env index 68ac3ab..aaacfc1 100644 --- a/.env +++ b/.env @@ -41,3 +41,4 @@ ENABLE_NOTICES='' CAREER_LINK_URL='' ENABLE_EDX_PERSONAL_DASHBOARD=false ENABLE_PROGRAMS=false +NON_BROWSABLE_COURSES=false diff --git a/.env.development b/.env.development index db34121..0672147 100644 --- a/.env.development +++ b/.env.development @@ -47,3 +47,4 @@ ENABLE_NOTICES='' CAREER_LINK_URL='' ENABLE_EDX_PERSONAL_DASHBOARD=false ENABLE_PROGRAMS=false +NON_BROWSABLE_COURSES=false diff --git a/.env.test b/.env.test index 0d27001..0b22f2a 100644 --- a/.env.test +++ b/.env.test @@ -46,3 +46,4 @@ ENABLE_NOTICES='' CAREER_LINK_URL='' ENABLE_EDX_PERSONAL_DASHBOARD=true ENABLE_PROGRAMS=false +NON_BROWSABLE_COURSES=false diff --git a/src/config/index.js b/src/config/index.js index 32fc614..8133329 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -19,6 +19,7 @@ const configuration = { ENABLE_EDX_PERSONAL_DASHBOARD: process.env.ENABLE_EDX_PERSONAL_DASHBOARD === 'true', SEARCH_CATALOG_URL: process.env.SEARCH_CATALOG_URL || null, ENABLE_PROGRAMS: process.env.ENABLE_PROGRAMS === 'true', + NON_BROWSABLE_COURSES: process.env.NON_BROWSABLE_COURSES === 'true', }; const features = {}; diff --git a/src/containers/LearnerDashboardHeader/LearnerDashboardMenu.jsx b/src/containers/LearnerDashboardHeader/LearnerDashboardMenu.jsx index 165d486..f13177f 100644 --- a/src/containers/LearnerDashboardHeader/LearnerDashboardMenu.jsx +++ b/src/containers/LearnerDashboardHeader/LearnerDashboardMenu.jsx @@ -22,14 +22,15 @@ const getLearnerHeaderMenu = ( href: `${urls.programsUrl()}`, content: formatMessage(messages.program), }] : []), - { + ...(!getConfig().NON_BROWSABLE_COURSES ? [{ type: 'item', href: `${urls.baseAppUrl(courseSearchUrl)}`, content: formatMessage(messages.discoverNew), onClick: (e) => { exploreCoursesClick(e); }, - }, + }] + : []), ], secondaryMenu: [ ...(getConfig().SUPPORT_URL ? [{ diff --git a/src/containers/LearnerDashboardHeader/index.test.jsx b/src/containers/LearnerDashboardHeader/index.test.jsx index 86eb1ac..6c1e281 100644 --- a/src/containers/LearnerDashboardHeader/index.test.jsx +++ b/src/containers/LearnerDashboardHeader/index.test.jsx @@ -44,4 +44,9 @@ describe('LearnerDashboardHeader', () => { const wrapper = shallow(); expect(wrapper.instance.findByType(Header)[0].props.mainMenuItems.length).toBe(3); }); + test('should not display Discover New tab if it is disabled by configuration', () => { + mergeConfig({ NON_BROWSABLE_COURSES: true }); + const wrapper = shallow(); + expect(wrapper.instance.findByType(Header)[0].props.mainMenuItems.length).toBe(2); + }); });