Skip to content

Commit

Permalink
feat: allow runtime configuration (openedx#786)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoa authored and abdullahwaheed committed Nov 18, 2022
1 parent c4891d9 commit 1f24f81
Show file tree
Hide file tree
Showing 11 changed files with 467 additions and 90 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ SITE_NAME=null
NEW_RELIC_ADMIN_KEY=null
NEW_RELIC_APP_ID=null
NEW_RELIC_LICENSE_KEY=null
APP_ID=''
MFE_CONFIG_API_URL=''
2 changes: 2 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ REFRESH_ACCESS_TOKEN_ENDPOINT='http://localhost:18000/login_refresh'
ACCESS_TOKEN_COOKIE_NAME='edx-jwt-cookie-header-payload'
USER_INFO_COOKIE_NAME='edx-user-info'
SITE_NAME='edX'
APP_ID=''
MFE_CONFIG_API_URL=''
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ LOGO_URL='https://edx-cdn.org/v3/default/logo.svg'
LOGO_TRADEMARK_URL=https://edx-cdn.org/v3/default/logo-trademark.svg
LOGO_WHITE_URL=https://edx-cdn.org/v3/default/logo-white.svg
FAVICON_URL=https://edx-cdn.org/v3/default/favicon.ico
SITE_NAME='edX'
500 changes: 425 additions & 75 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"dependencies": {
"@edx/brand": "npm:@edx/brand-openedx@1.1.0",
"@edx/frontend-component-footer-edx": "3.5.0",
"@edx/frontend-platform": "1.15.6",
"@edx/frontend-platform": "2.5.1",
"@edx/paragon": "19.14.0",
"@edx/tinymce-language-selector": "1.1.0",
"@fortawesome/free-regular-svg-icons": "6.1.1",
Expand Down
28 changes: 24 additions & 4 deletions src/components/CourseTable/__snapshots__/CourseTable.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ exports[`CourseTable displays table and button when not blacklisted 1`] = `
encodeSpecialCharacters={true}
>
<title>
Publisher | undefined
Publisher | edX
</title>
<link
href="https://edx-cdn.org/v3/default/favicon.ico"
rel="shortcut icon"
type="image/x-icon"
/>
</HelmetWrapper>
<div
className="row"
Expand Down Expand Up @@ -168,8 +173,13 @@ exports[`CourseTable displays table and button when user has no orgs 1`] = `
encodeSpecialCharacters={true}
>
<title>
Publisher | undefined
Publisher | edX
</title>
<link
href="https://edx-cdn.org/v3/default/favicon.ico"
rel="shortcut icon"
type="image/x-icon"
/>
</HelmetWrapper>
<div
className="row"
Expand Down Expand Up @@ -326,8 +336,13 @@ exports[`CourseTable hides table and button when blacklisted 1`] = `
encodeSpecialCharacters={true}
>
<title>
Publisher | undefined
Publisher | edX
</title>
<link
href="https://edx-cdn.org/v3/default/favicon.ico"
rel="shortcut icon"
type="image/x-icon"
/>
</HelmetWrapper>
<div
className="row"
Expand Down Expand Up @@ -484,8 +499,13 @@ exports[`CourseTable shows a table 1`] = `
encodeSpecialCharacters={true}
>
<title>
Publisher | undefined
Publisher | edX
</title>
<link
href="https://edx-cdn.org/v3/default/favicon.ico"
rel="shortcut icon"
type="image/x-icon"
/>
</HelmetWrapper>
<div
className="row"
Expand Down
4 changes: 3 additions & 1 deletion src/components/CourseTable/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Link } from 'react-router-dom';
import Select from 'react-select';
import qs from 'query-string';
import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
import { getConfig } from '@edx/frontend-platform';
import { SearchField } from '@edx/paragon';

import TableContainer from '../../containers/TableContainer';
Expand Down Expand Up @@ -228,7 +229,8 @@ class CourseTable extends React.Component {
return (
<PageContainer wide>
<Helmet>
<title>{`Publisher | ${process.env.SITE_NAME}`}</title>
<title>{`Publisher | ${getConfig().SITE_NAME}`}</title>
<link rel="shortcut icon" href={getConfig().FAVICON_URL} type="image/x-icon" />
</Helmet>
{!loading && !error && this.renderTableHeader()}
<TableContainer
Expand Down
3 changes: 2 additions & 1 deletion src/components/EditCoursePage/CollapsibleCourseRun.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import PropTypes from 'prop-types';

import { Field, FieldArray } from 'redux-form';
import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
import { getConfig } from '@edx/frontend-platform';
import { faCopy } from '@fortawesome/free-regular-svg-icons';
import { faCopy as solidCopy } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
Expand Down Expand Up @@ -76,7 +77,7 @@ const formatCourseRunTitle = (courseRun, copied, setCopied) => {
<>
Studio URL -&nbsp;
<Hyperlink
destination={`${process.env.STUDIO_BASE_URL}/course/${courseRun.key}`}
destination={`${getConfig().STUDIO_BASE_URL}/course/${courseRun.key}`}
target="_blank"
>
{courseRun.key}
Expand Down
3 changes: 0 additions & 3 deletions src/components/Header/__snapshots__/Header.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ exports[`Header renders the correct header 1`] = `
alt="edX logo"
height="30"
src="https://edx-cdn.org/v3/default/logo.svg"
width="60"
/>
</a>
</ForwardRef>
Expand Down Expand Up @@ -267,7 +266,6 @@ exports[`Header renders the header correctly when toggling is allowed, and dark
alt="edX logo"
height="30"
src="https://edx-cdn.org/v3/default/logo.svg"
width="60"
/>
</a>
</ForwardRef>
Expand Down Expand Up @@ -514,7 +512,6 @@ exports[`Header renders the header correctly when users pass a querystring param
alt="edX logo"
height="30"
src="https://edx-cdn.org/v3/default/logo.svg"
width="60"
/>
</a>
</ForwardRef>
Expand Down
7 changes: 4 additions & 3 deletions src/components/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { AppContext } from '@edx/frontend-platform/react';
import {
Dropdown, Hyperlink, AvatarButton,
} from '@edx/paragon';
import { getConfig } from '@edx/frontend-platform';

const Header = ({ darkModeOn, location, toggleDarkMode }) => {
const { authenticatedUser } = useContext(AppContext);
Expand All @@ -32,8 +33,8 @@ const Header = ({ darkModeOn, location, toggleDarkMode }) => {
<div className="container">
<div className="row align-items-center">
<div className="col-auto justify-content-start">
<Hyperlink destination={process.env.BASE_URL}>
<img src={process.env.LOGO_URL} alt="edX logo" height="30" width="60" />
<Hyperlink destination={getConfig().BASE_URL}>
<img src={getConfig().LOGO_URL} alt="edX logo" height="30" />
</Hyperlink>
</div>
<div className="col-auto justify-content-start">
Expand Down Expand Up @@ -63,7 +64,7 @@ const Header = ({ darkModeOn, location, toggleDarkMode }) => {

<Dropdown.Menu>
<Dropdown.Item
onClick={() => redirectToLogout(process.env.LMS_BASE_URL)}
onClick={() => redirectToLogout(getConfig().LMS_BASE_URL)}
key="dropdown-logout"
>
Sign Out
Expand Down
5 changes: 3 additions & 2 deletions src/helpText.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { getConfig } from '@edx/frontend-platform';
import { isSafari } from './utils';

/**
Expand Down Expand Up @@ -30,7 +31,7 @@ function dateEditHelp(courseRun) {
</p>
<p>
<a
href={`${process.env.STUDIO_BASE_URL}/settings/details/${courseRun.key}#schedule`}
href={`${getConfig().STUDIO_BASE_URL}/settings/details/${courseRun.key}#schedule`}
target="_blank"
rel="noopener noreferrer"
>
Expand Down Expand Up @@ -80,7 +81,7 @@ function pacingEditHelp(courseRun) {
</p>
<p>
<a
href={`${process.env.STUDIO_BASE_URL}/settings/details/${courseRun.key}`}
href={`${getConfig().STUDIO_BASE_URL}/settings/details/${courseRun.key}`}
target="_blank"
rel="noopener noreferrer"
>
Expand Down

0 comments on commit 1f24f81

Please sign in to comment.