Skip to content

Commit 8ae9dfb

Browse files
authored
feat: customize the certificate link in header (#1223)
* feat: customize the certificate link in header * fix: lint issues * fix: tests
1 parent 3089d0b commit 8ae9dfb

File tree

7 files changed

+56
-28
lines changed

7 files changed

+56
-28
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ ENABLE_UNIT_PAGE=false
3434
ENABLE_ASSETS_PAGE=false
3535
ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN=false
3636
ENABLE_TAGGING_TAXONOMY_PAGES=true
37+
ENABLE_CERTIFICATE_PAGE=true
3738
BBB_LEARN_MORE_URL=''
3839
HOTJAR_APP_ID=''
3940
HOTJAR_VERSION=6

.env.development

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ ENABLE_TEAM_TYPE_SETTING=false
3535
ENABLE_UNIT_PAGE=false
3636
ENABLE_ASSETS_PAGE=false
3737
ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN=true
38+
ENABLE_CERTIFICATE_PAGE=true
3839
ENABLE_NEW_VIDEO_UPLOAD_PAGE=true
3940
ENABLE_TAGGING_TAXONOMY_PAGES=true
4041
BBB_LEARN_MORE_URL=''

.env.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ ENABLE_TEAM_TYPE_SETTING=false
3131
ENABLE_UNIT_PAGE=true
3232
ENABLE_ASSETS_PAGE=false
3333
ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN=true
34+
ENABLE_CERTIFICATE_PAGE=true
3435
ENABLE_TAGGING_TAXONOMY_PAGES=true
3536
BBB_LEARN_MORE_URL=''
3637
INVITE_STUDENTS_EMAIL_TO="[email protected]"

src/CourseAuthoringRoutes.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ const CourseAuthoringRoutes = () => {
124124
/>
125125
<Route
126126
path="certificates"
127-
element={<PageWrap><Certificates courseId={courseId} /></PageWrap>}
127+
element={getConfig().ENABLE_CERTIFICATE_PAGE === 'true' ? <PageWrap><Certificates courseId={courseId} /></PageWrap> : null}
128128
/>
129129
<Route
130130
path="textbooks"

src/header/utils.js

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,37 @@ export const getContentMenuItems = ({ studioBaseUrl, courseId, intl }) => {
3131
return items;
3232
};
3333

34-
export const getSettingMenuItems = ({ studioBaseUrl, courseId, intl }) => ([
35-
{
36-
href: `${studioBaseUrl}/settings/details/${courseId}`,
37-
title: intl.formatMessage(messages['header.links.scheduleAndDetails']),
38-
},
39-
{
40-
href: `${studioBaseUrl}/settings/grading/${courseId}`,
41-
title: intl.formatMessage(messages['header.links.grading']),
42-
},
43-
{
44-
href: `${studioBaseUrl}/course_team/${courseId}`,
45-
title: intl.formatMessage(messages['header.links.courseTeam']),
46-
},
47-
{
48-
href: `${studioBaseUrl}/group_configurations/${courseId}`,
49-
title: intl.formatMessage(messages['header.links.groupConfigurations']),
50-
},
51-
{
52-
href: `${studioBaseUrl}/settings/advanced/${courseId}`,
53-
title: intl.formatMessage(messages['header.links.advancedSettings']),
54-
},
55-
{
56-
href: `${studioBaseUrl}/certificates/${courseId}`,
57-
title: intl.formatMessage(messages['header.links.certificates']),
58-
},
59-
]);
34+
export const getSettingMenuItems = ({ studioBaseUrl, courseId, intl }) => {
35+
const items = [
36+
{
37+
href: `${studioBaseUrl}/settings/details/${courseId}`,
38+
title: intl.formatMessage(messages['header.links.scheduleAndDetails']),
39+
},
40+
{
41+
href: `${studioBaseUrl}/settings/grading/${courseId}`,
42+
title: intl.formatMessage(messages['header.links.grading']),
43+
},
44+
{
45+
href: `${studioBaseUrl}/course_team/${courseId}`,
46+
title: intl.formatMessage(messages['header.links.courseTeam']),
47+
},
48+
{
49+
href: `${studioBaseUrl}/group_configurations/${courseId}`,
50+
title: intl.formatMessage(messages['header.links.groupConfigurations']),
51+
},
52+
{
53+
href: `${studioBaseUrl}/settings/advanced/${courseId}`,
54+
title: intl.formatMessage(messages['header.links.advancedSettings']),
55+
},
56+
];
57+
if (getConfig().ENABLE_CERTIFICATE_PAGE === 'true') {
58+
items.push({
59+
href: `${studioBaseUrl}/certificates/${courseId}`,
60+
title: intl.formatMessage(messages['header.links.certificates']),
61+
});
62+
}
63+
return items;
64+
};
6065

6166
export const getToolsMenuItems = ({ studioBaseUrl, courseId, intl }) => ([
6267
{

src/header/utils.test.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getConfig, setConfig } from '@edx/frontend-platform';
2-
import { getContentMenuItems, getToolsMenuItems } from './utils';
2+
import { getContentMenuItems, getToolsMenuItems, getSettingMenuItems } from './utils';
33

44
const props = {
55
studioBaseUrl: 'UrLSTuiO',
@@ -29,6 +29,25 @@ describe('header utils', () => {
2929
});
3030
});
3131

32+
describe('getSettingsMenuitems', () => {
33+
it('should include certificates option', () => {
34+
setConfig({
35+
...getConfig(),
36+
ENABLE_CERTIFICATE_PAGE: 'true',
37+
});
38+
const actualItems = getSettingMenuItems(props);
39+
expect(actualItems).toHaveLength(6);
40+
});
41+
it('should not include certificates option', () => {
42+
setConfig({
43+
...getConfig(),
44+
ENABLE_CERTIFICATE_PAGE: 'false',
45+
});
46+
const actualItems = getSettingMenuItems(props);
47+
expect(actualItems).toHaveLength(5);
48+
});
49+
});
50+
3251
describe('getToolsMenuItems', () => {
3352
it('should include export tags option', () => {
3453
setConfig({

src/index.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ initialize({
126126
ENABLE_UNIT_PAGE: process.env.ENABLE_UNIT_PAGE || 'false',
127127
ENABLE_ASSETS_PAGE: process.env.ENABLE_ASSETS_PAGE || 'false',
128128
ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN: process.env.ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN || 'false',
129+
ENABLE_CERTIFICATE_PAGE: process.env.ENABLE_CERTIFICATE_PAGE || 'false',
129130
ENABLE_TAGGING_TAXONOMY_PAGES: process.env.ENABLE_TAGGING_TAXONOMY_PAGES || 'false',
130131
ENABLE_HOME_PAGE_COURSE_API_V2: process.env.ENABLE_HOME_PAGE_COURSE_API_V2 === 'true',
131132
ENABLE_CHECKLIST_QUALITY: process.env.ENABLE_CHECKLIST_QUALITY || 'true',

0 commit comments

Comments
 (0)