From 8ae9dfbd8874f87f7d786faebb14a8b892d8497c Mon Sep 17 00:00:00 2001 From: Muhammad Anas <88967643+Anas12091101@users.noreply.github.com> Date: Wed, 21 Aug 2024 19:36:14 +0500 Subject: [PATCH] feat: customize the certificate link in header (#1223) * feat: customize the certificate link in header * fix: lint issues * fix: tests --- .env | 1 + .env.development | 1 + .env.test | 1 + src/CourseAuthoringRoutes.jsx | 2 +- src/header/utils.js | 57 +++++++++++++++++++---------------- src/header/utils.test.js | 21 ++++++++++++- src/index.jsx | 1 + 7 files changed, 56 insertions(+), 28 deletions(-) diff --git a/.env b/.env index 6f871fb94c..ec000feba0 100644 --- a/.env +++ b/.env @@ -34,6 +34,7 @@ ENABLE_UNIT_PAGE=false ENABLE_ASSETS_PAGE=false ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN=false ENABLE_TAGGING_TAXONOMY_PAGES=true +ENABLE_CERTIFICATE_PAGE=true BBB_LEARN_MORE_URL='' HOTJAR_APP_ID='' HOTJAR_VERSION=6 diff --git a/.env.development b/.env.development index 75b4219d0e..1cc8f24da6 100644 --- a/.env.development +++ b/.env.development @@ -35,6 +35,7 @@ ENABLE_TEAM_TYPE_SETTING=false ENABLE_UNIT_PAGE=false ENABLE_ASSETS_PAGE=false ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN=true +ENABLE_CERTIFICATE_PAGE=true ENABLE_NEW_VIDEO_UPLOAD_PAGE=true ENABLE_TAGGING_TAXONOMY_PAGES=true BBB_LEARN_MORE_URL='' diff --git a/.env.test b/.env.test index 0f73517968..7c591ff68e 100644 --- a/.env.test +++ b/.env.test @@ -31,6 +31,7 @@ ENABLE_TEAM_TYPE_SETTING=false ENABLE_UNIT_PAGE=true ENABLE_ASSETS_PAGE=false ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN=true +ENABLE_CERTIFICATE_PAGE=true ENABLE_TAGGING_TAXONOMY_PAGES=true BBB_LEARN_MORE_URL='' INVITE_STUDENTS_EMAIL_TO="someone@domain.com" diff --git a/src/CourseAuthoringRoutes.jsx b/src/CourseAuthoringRoutes.jsx index 8d8d1a6c06..51599317e6 100644 --- a/src/CourseAuthoringRoutes.jsx +++ b/src/CourseAuthoringRoutes.jsx @@ -124,7 +124,7 @@ const CourseAuthoringRoutes = () => { /> } + element={getConfig().ENABLE_CERTIFICATE_PAGE === 'true' ? : null} /> { return items; }; -export const getSettingMenuItems = ({ studioBaseUrl, courseId, intl }) => ([ - { - href: `${studioBaseUrl}/settings/details/${courseId}`, - title: intl.formatMessage(messages['header.links.scheduleAndDetails']), - }, - { - href: `${studioBaseUrl}/settings/grading/${courseId}`, - title: intl.formatMessage(messages['header.links.grading']), - }, - { - href: `${studioBaseUrl}/course_team/${courseId}`, - title: intl.formatMessage(messages['header.links.courseTeam']), - }, - { - href: `${studioBaseUrl}/group_configurations/${courseId}`, - title: intl.formatMessage(messages['header.links.groupConfigurations']), - }, - { - href: `${studioBaseUrl}/settings/advanced/${courseId}`, - title: intl.formatMessage(messages['header.links.advancedSettings']), - }, - { - href: `${studioBaseUrl}/certificates/${courseId}`, - title: intl.formatMessage(messages['header.links.certificates']), - }, -]); +export const getSettingMenuItems = ({ studioBaseUrl, courseId, intl }) => { + const items = [ + { + href: `${studioBaseUrl}/settings/details/${courseId}`, + title: intl.formatMessage(messages['header.links.scheduleAndDetails']), + }, + { + href: `${studioBaseUrl}/settings/grading/${courseId}`, + title: intl.formatMessage(messages['header.links.grading']), + }, + { + href: `${studioBaseUrl}/course_team/${courseId}`, + title: intl.formatMessage(messages['header.links.courseTeam']), + }, + { + href: `${studioBaseUrl}/group_configurations/${courseId}`, + title: intl.formatMessage(messages['header.links.groupConfigurations']), + }, + { + href: `${studioBaseUrl}/settings/advanced/${courseId}`, + title: intl.formatMessage(messages['header.links.advancedSettings']), + }, + ]; + if (getConfig().ENABLE_CERTIFICATE_PAGE === 'true') { + items.push({ + href: `${studioBaseUrl}/certificates/${courseId}`, + title: intl.formatMessage(messages['header.links.certificates']), + }); + } + return items; +}; export const getToolsMenuItems = ({ studioBaseUrl, courseId, intl }) => ([ { diff --git a/src/header/utils.test.js b/src/header/utils.test.js index afcb5da24d..f2c2f3acb5 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, getToolsMenuItems } from './utils'; +import { getContentMenuItems, getToolsMenuItems, getSettingMenuItems } from './utils'; const props = { studioBaseUrl: 'UrLSTuiO', @@ -29,6 +29,25 @@ describe('header utils', () => { }); }); + describe('getSettingsMenuitems', () => { + it('should include certificates option', () => { + setConfig({ + ...getConfig(), + ENABLE_CERTIFICATE_PAGE: 'true', + }); + const actualItems = getSettingMenuItems(props); + expect(actualItems).toHaveLength(6); + }); + it('should not include certificates option', () => { + setConfig({ + ...getConfig(), + ENABLE_CERTIFICATE_PAGE: 'false', + }); + const actualItems = getSettingMenuItems(props); + expect(actualItems).toHaveLength(5); + }); + }); + describe('getToolsMenuItems', () => { it('should include export tags option', () => { setConfig({ diff --git a/src/index.jsx b/src/index.jsx index 9336b9486f..675e927097 100755 --- a/src/index.jsx +++ b/src/index.jsx @@ -126,6 +126,7 @@ initialize({ ENABLE_UNIT_PAGE: process.env.ENABLE_UNIT_PAGE || 'false', ENABLE_ASSETS_PAGE: process.env.ENABLE_ASSETS_PAGE || 'false', ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN: process.env.ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN || 'false', + ENABLE_CERTIFICATE_PAGE: process.env.ENABLE_CERTIFICATE_PAGE || 'false', ENABLE_TAGGING_TAXONOMY_PAGES: process.env.ENABLE_TAGGING_TAXONOMY_PAGES || 'false', ENABLE_HOME_PAGE_COURSE_API_V2: process.env.ENABLE_HOME_PAGE_COURSE_API_V2 === 'true', ENABLE_CHECKLIST_QUALITY: process.env.ENABLE_CHECKLIST_QUALITY || 'true',