diff --git a/.env b/.env index 40c4e09b..dd38ba31 100644 --- a/.env +++ b/.env @@ -41,3 +41,4 @@ ACCOUNT_PROFILE_URL='' ENABLE_NOTICES='' CAREER_LINK_URL='' ENABLE_EDX_PERSONAL_DASHBOARD=false +ENABLE_PROGRAMS=false diff --git a/.env.development b/.env.development index 86014958..6685c05a 100644 --- a/.env.development +++ b/.env.development @@ -20,7 +20,7 @@ LMS_CLIENT_ID='login-service-client-id' SEGMENT_KEY='' FEATURE_FLAGS={} MARKETING_SITE_BASE_URL='http://localhost:18000' -SUPPORT_URL='http://localhost:18000/support' +SUPPORT_URL='' CONTACT_URL='http://localhost:18000/contact' OPEN_SOURCE_URL='http://localhost:18000/openedx' TERMS_OF_SERVICE_URL='http://localhost:18000/terms-of-service' @@ -47,3 +47,4 @@ ACCOUNT_PROFILE_URL='http://localhost:1995' ENABLE_NOTICES='' CAREER_LINK_URL='' ENABLE_EDX_PERSONAL_DASHBOARD=false +ENABLE_PROGRAMS=false diff --git a/.env.test b/.env.test index 705a9889..0769651a 100644 --- a/.env.test +++ b/.env.test @@ -20,7 +20,7 @@ LMS_CLIENT_ID='login-service-client-id' SEGMENT_KEY='' FEATURE_FLAGS={} MARKETING_SITE_BASE_URL='http://localhost:18000' -SUPPORT_URL='http://localhost:18000/support' +SUPPORT_URL='' CONTACT_URL='http://localhost:18000/contact' OPEN_SOURCE_URL='http://localhost:18000/openedx' TERMS_OF_SERVICE_URL='http://localhost:18000/terms-of-service' @@ -46,3 +46,4 @@ ACCOUNT_PROFILE_URL='http://account-profile-url.test' ENABLE_NOTICES='' CAREER_LINK_URL='' ENABLE_EDX_PERSONAL_DASHBOARD=true +ENABLE_PROGRAMS=false diff --git a/src/config/index.js b/src/config/index.js index a2e2a566..e1bacea8 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -19,6 +19,7 @@ const configuration = { LOGO_URL: process.env.LOGO_URL, 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', }; const features = {}; diff --git a/src/containers/LearnerDashboardHeader/LearnerDashboardMenu.jsx b/src/containers/LearnerDashboardHeader/LearnerDashboardMenu.jsx index 9dcecc3a..165d4866 100644 --- a/src/containers/LearnerDashboardHeader/LearnerDashboardMenu.jsx +++ b/src/containers/LearnerDashboardHeader/LearnerDashboardMenu.jsx @@ -17,11 +17,11 @@ const getLearnerHeaderMenu = ( content: formatMessage(messages.course), isActive: true, }, - { + ...(getConfig().ENABLE_PROGRAMS ? [{ type: 'item', href: `${urls.programsUrl()}`, content: formatMessage(messages.program), - }, + }] : []), { type: 'item', href: `${urls.baseAppUrl(courseSearchUrl)}`, @@ -32,11 +32,11 @@ const getLearnerHeaderMenu = ( }, ], secondaryMenu: [ - { + ...(getConfig().SUPPORT_URL ? [{ type: 'item', href: `${getConfig().SUPPORT_URL}`, content: formatMessage(messages.help), - }, + }] : []), ], userMenu: [ { @@ -70,6 +70,7 @@ const getLearnerHeaderMenu = ( ], }, ], -}); +} +); export default getLearnerHeaderMenu; diff --git a/src/containers/LearnerDashboardHeader/__snapshots__/index.test.jsx.snap b/src/containers/LearnerDashboardHeader/__snapshots__/index.test.jsx.snap index a1f0a9e7..34bcdc1f 100644 --- a/src/containers/LearnerDashboardHeader/__snapshots__/index.test.jsx.snap +++ b/src/containers/LearnerDashboardHeader/__snapshots__/index.test.jsx.snap @@ -12,11 +12,6 @@ exports[`LearnerDashboardHeader render 1`] = ` "isActive": true, "type": "item", }, - { - "content": "Programs", - "href": "http://localhost:18000/dashboard/programs", - "type": "item", - }, { "content": "Discover New", "href": "http://localhost:18000/course-search-url", @@ -25,15 +20,7 @@ exports[`LearnerDashboardHeader render 1`] = ` }, ] } - secondaryMenuItems={ - [ - { - "content": "Help", - "href": "http://localhost:18000/support", - "type": "item", - }, - ] - } + secondaryMenuItems={[]} userMenuItems={ [ { diff --git a/src/containers/LearnerDashboardHeader/hooks.test.js b/src/containers/LearnerDashboardHeader/hooks.test.js index c9bac080..54b84cf5 100644 --- a/src/containers/LearnerDashboardHeader/hooks.test.js +++ b/src/containers/LearnerDashboardHeader/hooks.test.js @@ -56,7 +56,7 @@ describe('LearnerDashboardHeader hooks', () => { username: 'test', }; const learnerHomeHeaderMenu = useLearnerDashboardHeaderMenu({ courseSearchUrl, authenticatedUser }); - expect(learnerHomeHeaderMenu.mainMenu.length).toBe(3); + expect(learnerHomeHeaderMenu.mainMenu.length).toBe(2); }); }); diff --git a/src/containers/LearnerDashboardHeader/index.test.jsx b/src/containers/LearnerDashboardHeader/index.test.jsx index e07fbda4..86eb1acf 100644 --- a/src/containers/LearnerDashboardHeader/index.test.jsx +++ b/src/containers/LearnerDashboardHeader/index.test.jsx @@ -29,7 +29,19 @@ describe('LearnerDashboardHeader', () => { expect(wrapper.instance.findByType('ConfirmEmailBanner')).toHaveLength(1); expect(wrapper.instance.findByType('MasqueradeBar')).toHaveLength(1); expect(wrapper.instance.findByType(Header)).toHaveLength(1); - wrapper.instance.findByType(Header)[0].props.mainMenuItems[2].onClick(); + wrapper.instance.findByType(Header)[0].props.mainMenuItems[1].onClick(); expect(findCoursesNavClicked).toHaveBeenCalledWith(urls.baseAppUrl('/course-search-url')); + expect(wrapper.instance.findByType(Header)[0].props.secondaryMenuItems.length).toBe(0); + }); + + test('should display Help link if SUPPORT_URL is set', () => { + mergeConfig({ SUPPORT_URL: 'http://localhost:18000/support' }); + const wrapper = shallow(); + expect(wrapper.instance.findByType(Header)[0].props.secondaryMenuItems.length).toBe(1); + }); + test('should display Programs link if it is enabled by configuration', () => { + mergeConfig({ ENABLE_PROGRAMS: true }); + const wrapper = shallow(); + expect(wrapper.instance.findByType(Header)[0].props.mainMenuItems.length).toBe(3); }); });