Skip to content

Commit

Permalink
feat: Get learn more links from the backend instead of hard-coding it…
Browse files Browse the repository at this point in the history
… in the frontend (openedx#173)

This updates the app settings page to use a link returned by the backend instead
of using a hard-coded link in the frontend.
  • Loading branch information
xitij2000 authored Aug 5, 2021
1 parent eeb9ceb commit 0a33523
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ function AppSettingsModal({
onSettingsSave,
enableAppLabel,
enableAppHelp,
learnMoreURL,
learnMoreText,
}) {
const { courseId } = useContext(PagesAndResourcesContext);
Expand All @@ -86,10 +85,10 @@ function AppSettingsModal({
}
};

const learnMoreLink = (
const learnMoreLink = appInfo.documentationLinks?.learnMoreConfiguration && (
<Hyperlink
className="text-primary-500"
destination={learnMoreURL}
destination={appInfo.documentationLinks.learnMoreConfiguration}
target="_blank"
rel="noreferrer noopener"
>
Expand Down Expand Up @@ -210,7 +209,6 @@ AppSettingsModal.propTypes = {
onClose: PropTypes.func.isRequired,
enableAppLabel: PropTypes.string.isRequired,
enableAppHelp: PropTypes.string.isRequired,
learnMoreURL: PropTypes.string.isRequired,
learnMoreText: PropTypes.string.isRequired,
};

Expand Down
11 changes: 3 additions & 8 deletions src/pages-and-resources/calculator/Settings.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
import { getConfig } from '@edx/frontend-platform';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import PropTypes from 'prop-types';
import React from 'react';
import AppSettingsModal from '../app-settings-modal/AppSettingsModal';

import messages from './messages';

const CALCULATOR_HELP_URL = getConfig().CALCULATOR_HELP_URL
|| 'https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/exercises_tools/calculator.html';

function CalculatorSettings({ intl, onClose }) {
return (
<AppSettingsModal
appId="calculator"
title={intl.formatMessage(messages.heading)}
enableAppHelp={intl.formatMessage(messages.enableProgressHelp)}
enableAppLabel={intl.formatMessage(messages.enableProgressLabel)}
learnMoreText={intl.formatMessage(messages.enableProgressLink)}
learnMoreURL={CALCULATOR_HELP_URL}
enableAppHelp={intl.formatMessage(messages.enableCalculatorHelp)}
enableAppLabel={intl.formatMessage(messages.enableCalculatorLabel)}
learnMoreText={intl.formatMessage(messages.enableCalculatorLink)}
onClose={onClose}
/>
);
Expand Down
6 changes: 3 additions & 3 deletions src/pages-and-resources/calculator/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ const messages = defineMessages({
id: 'course-authoring.pages-resources.calculator.heading',
defaultMessage: 'Configure calculator',
},
enableProgressLabel: {
enableCalculatorLabel: {
id: 'course-authoring.pages-resources.calculator.enable-calculator.label',
defaultMessage: 'Calculator',
},
enableProgressHelp: {
enableCalculatorHelp: {
id: 'course-authoring.pages-resources.calculator.enable-calculator.help',
defaultMessage: `The calculator supports numbers, operators, constants,
functions, and other mathematical concepts. When enabled, an icon to
access the calculator appears on all pages in the body of your course.`,
},
enableProgressLink: {
enableCalculatorLink: {
id: 'course-authoring.pages-resources.calculator.enable-calculator.link',
defaultMessage: 'Learn more about the calculator',
},
Expand Down

0 comments on commit 0a33523

Please sign in to comment.