fix: Runtime config support for feature flags

This makes sure the following feature flags work with dynamic runtime
configuration:

* ENABLE_NEW_EDITOR_PAGES
* ENABLE_UNIT_PAGE
* ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN
* ENABLE_TAGGING_TAXONOMY_PAGES

We also remove flags from the `.env*` files that are no longer in use.
This commit is contained in:
Adolfo R. Brandes
2024-02-06 14:28:24 -03:00
committed by Adolfo R. Brandes
parent 815ddbe94e
commit 4850302175
8 changed files with 32 additions and 22 deletions

View File

@@ -1,3 +1,4 @@
import { getConfig } from '@edx/frontend-platform';
import { getPagePath } from '../utils';
import messages from './messages';
@@ -20,7 +21,7 @@ export const getContentMenuItems = ({ studioBaseUrl, courseId, intl }) => {
title: intl.formatMessage(messages['header.links.filesAndUploads']),
},
];
if (process.env.ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN === 'true') {
if (getConfig().ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN === 'true') {
items.push({
href: `${studioBaseUrl}/videos/${courseId}`,
title: intl.formatMessage(messages['header.links.videoUploads']),

View File

@@ -1,3 +1,4 @@
import { getConfig, setConfig } from '@edx/frontend-platform';
import { getContentMenuItems } from './utils';
const props = {
@@ -11,11 +12,18 @@ const props = {
describe('header utils', () => {
describe('getContentMenuItems', () => {
it('should include Video Uploads option', () => {
setConfig({
...getConfig(),
ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN: 'true',
});
const actualItems = getContentMenuItems(props);
expect(actualItems).toHaveLength(5);
});
it('should not include Video Uploads option', () => {
process.env.ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN = 'false';
setConfig({
...getConfig(),
ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN: 'false',
});
const actualItems = getContentMenuItems(props);
expect(actualItems).toHaveLength(4);
});