refactor: added env variable for progress graph (#190)
* refactor: added env variable for progress graph * refactor: removed API call when progress graph setting is disabled
This commit is contained in:
1
.env
1
.env
@@ -22,3 +22,4 @@ SITE_NAME=''
|
||||
SUPPORT_EMAIL=''
|
||||
SUPPORT_URL=''
|
||||
USER_INFO_COOKIE_NAME=''
|
||||
ENABLE_PROGRESS_GRAPH_SETTINGS=false
|
||||
|
||||
@@ -24,3 +24,4 @@ STUDIO_BASE_URL='http://localhost:18010'
|
||||
SUPPORT_EMAIL='support@example.com'
|
||||
SUPPORT_URL='https://support.edx.org'
|
||||
USER_INFO_COOKIE_NAME='edx-user-info'
|
||||
ENABLE_PROGRESS_GRAPH_SETTINGS=false
|
||||
|
||||
@@ -23,3 +23,4 @@ STUDIO_BASE_URL='http://localhost:18010'
|
||||
SUPPORT_EMAIL='support@example.com'
|
||||
SUPPORT_URL='https://support.edx.org'
|
||||
USER_INFO_COOKIE_NAME='edx-user-info'
|
||||
ENABLE_PROGRESS_GRAPH_SETTINGS=false
|
||||
|
||||
@@ -47,6 +47,7 @@ initialize({
|
||||
SUPPORT_URL: process.env.SUPPORT_URL || null,
|
||||
SUPPORT_EMAIL: process.env.SUPPORT_EMAIL || null,
|
||||
CALCULATOR_HELP_URL: process.env.CALCULATOR_HELP_URL || null,
|
||||
ENABLE_PROGRESS_GRAPH_SETTINGS: process.env.ENABLE_PROGRESS_GRAPH_SETTINGS || 'false',
|
||||
}, 'CourseAuthoringConfig');
|
||||
},
|
||||
},
|
||||
|
||||
@@ -2,7 +2,7 @@ import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import * as Yup from 'yup';
|
||||
|
||||
import { getConfig } from '@edx/frontend-platform';
|
||||
import FormSwitchGroup from '../../generic/FormSwitchGroup';
|
||||
import { useAppSetting } from '../../utils';
|
||||
import AppSettingsModal from '../app-settings-modal/AppSettingsModal';
|
||||
@@ -10,8 +10,11 @@ import messages from './messages';
|
||||
|
||||
function ProgressSettings({ intl, onClose }) {
|
||||
const [disableProgressGraph, saveSetting] = useAppSetting('disableProgressGraph');
|
||||
const showProgressGraphSetting = getConfig().ENABLE_PROGRESS_GRAPH_SETTINGS.toLowerCase() === 'true';
|
||||
|
||||
const handleSettingsSave = (values) => saveSetting(!values.enableProgressGraph);
|
||||
const handleSettingsSave = (values) => {
|
||||
if (showProgressGraphSetting) { saveSetting(!values.enableProgressGraph); }
|
||||
};
|
||||
|
||||
return (
|
||||
<AppSettingsModal
|
||||
@@ -27,6 +30,7 @@ function ProgressSettings({ intl, onClose }) {
|
||||
>
|
||||
{
|
||||
({ handleChange, handleBlur, values }) => (
|
||||
showProgressGraphSetting && (
|
||||
<FormSwitchGroup
|
||||
id="enable-progress-graph"
|
||||
name="enableProgressGraph"
|
||||
@@ -36,6 +40,7 @@ function ProgressSettings({ intl, onClose }) {
|
||||
onBlur={handleBlur}
|
||||
checked={values.enableProgressGraph}
|
||||
/>
|
||||
)
|
||||
)
|
||||
}
|
||||
</AppSettingsModal>
|
||||
|
||||
Reference in New Issue
Block a user