Skip to content

Commit

Permalink
feat: upgrade runways to frontend-platform (#6)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: This package now depends upon frontend-platform instead of individual runway packages
  • Loading branch information
Adam Butterworth authored Nov 21, 2019
1 parent e35b9f9 commit 98655c6
Show file tree
Hide file tree
Showing 12 changed files with 1,003 additions and 875 deletions.
16 changes: 16 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
EXAMPLE_VAR=Example Value
ACCESS_TOKEN_COOKIE_NAME=edx-jwt-cookie-header-payload
BASE_URL=localhost:8080
CREDENTIALS_BASE_URL=http://localhost:18150
CSRF_TOKEN_API_PATH=/csrf/api/v1/token
ECOMMERCE_BASE_URL=http://localhost:18130
LANGUAGE_PREFERENCE_COOKIE_NAME=openedx-language-preference
LMS_BASE_URL=http://localhost:18000
LOGIN_URL=http://localhost:18000/login
LOGOUT_URL=http://localhost:18000/login
MARKETING_SITE_BASE_URL=http://localhost:18000
ORDER_HISTORY_URL=localhost:1996/orders
REFRESH_ACCESS_TOKEN_ENDPOINT=http://localhost:18000/login_refresh
SEGMENT_KEY=test
SITE_NAME=Open edX
USER_INFO_COOKIE_NAME=edx-user-info
16 changes: 16 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
EXAMPLE_VAR=Example Value
ACCESS_TOKEN_COOKIE_NAME=edx-jwt-cookie-header-payload
BASE_URL=localhost:8080
CREDENTIALS_BASE_URL=http://localhost:18150
CSRF_TOKEN_API_PATH=/csrf/api/v1/token
ECOMMERCE_BASE_URL=http://localhost:18130
LANGUAGE_PREFERENCE_COOKIE_NAME=openedx-language-preference
LMS_BASE_URL=http://localhost:18000
LOGIN_URL=http://localhost:18000/login
LOGOUT_URL=http://localhost:18000/login
MARKETING_SITE_BASE_URL=http://localhost:18000
ORDER_HISTORY_URL=localhost:1996/orders
REFRESH_ACCESS_TOKEN_ENDPOINT=http://localhost:18000/login_refresh
SEGMENT_KEY=test
SITE_NAME=Open edX
USER_INFO_COOKIE_NAME=edx-user-info
4 changes: 2 additions & 2 deletions example/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { render } from 'react-dom';
import { IntlProvider } from '@edx/frontend-i18n';
import { IntlProvider } from '@edx/frontend-platform/i18n';

import './index.scss';
import Footer from '../src';
Expand All @@ -9,7 +9,7 @@ const App = () => (
<div>
<IntlProvider locale="en">
<Footer
onLanguageSelected={(languageCode) => {}}
onLanguageSelected={() => {}}
supportedLanguages={[
{ label: 'English', value: 'en' },
{ label: 'Español', value: 'es' },
Expand Down
1,777 changes: 937 additions & 840 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 3 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,8 @@
"@commitlint/config-angular": "8.2.0",
"@commitlint/prompt": "8.2.0",
"@commitlint/prompt-cli": "8.2.0",
"@edx/frontend-analytics": "3.0.0",
"@edx/frontend-auth": "^7.0.1",
"@edx/frontend-base": "^4.0.1",
"@edx/frontend-build": "1.1.0",
"@edx/frontend-i18n": "3.0.3",
"@edx/frontend-logging": "3.0.1",
"@edx/frontend-build": "^2.0.1",
"@edx/frontend-platform": "git+https://github.com/edx/frontend-platform.git",
"@edx/paragon": "7.1.5",
"codecov": "3.6.1",
"enzyme": "3.10.0",
Expand All @@ -66,9 +62,7 @@
"@fortawesome/react-fontawesome": "0.1.5"
},
"peerDependencies": {
"@edx/frontend-analytics": "^3.0.0",
"@edx/frontend-i18n": "^3.0.0",
"@edx/frontend-logging": "^3.0.0",
"@edx/frontend-platform": "^1.0.0",
"@edx/paragon": "^7.0.0",
"prop-types": "^15.7.0",
"react": "^16.9.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/AppleAppStoreButton.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { injectIntl, intlShape } from '@edx/frontend-i18n';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import messages from './Footer.messages';

const AppleAppStoreButton = ({ intl, ...props }) => (
Expand Down
14 changes: 8 additions & 6 deletions src/components/Footer.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { sendTrackEvent } from '@edx/frontend-analytics';
import { App, APP_CONFIG_LOADED } from '@edx/frontend-base';
import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-i18n';
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
import { APP_CONFIG_INITIALIZED } from '@edx/frontend-platform/init';
import { subscribe } from '@edx/frontend-platform/pubSub';
import { mergeConfig, getConfig } from '@edx/frontend-platform/config';
import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import PropTypes from 'prop-types';
import React from 'react';

Expand All @@ -20,8 +22,8 @@ const MARKETING_BASE_URL = 'https://edx.org';

// Some MFEs (such as frontend-app-payment) don't want a footer to be shown.
// This lets them hide it.
App.subscribe(APP_CONFIG_LOADED, () => {
App.mergeConfig({
subscribe(APP_CONFIG_INITIALIZED, () => {
mergeConfig({
HIDE_FOOTER: !!process.env.HIDE_FOOTER,
}, 'Footer additional config');
});
Expand Down Expand Up @@ -74,7 +76,7 @@ class Footer extends React.Component {
const showLanguageSelector = supportedLanguages.length > 0 && onLanguageSelected;
const localePrefix = this.getLocalePrefix(intl.locale);

if (App.config.HIDE_FOOTER) {
if (getConfig().HIDE_FOOTER) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/Footer.messages.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineMessages } from '@edx/frontend-i18n';
import { defineMessages } from '@edx/frontend-platform/i18n';

const messages = defineMessages({
'footer.socialLinks.srText.facebook': {
Expand Down
29 changes: 16 additions & 13 deletions src/components/Footer.test.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import React from 'react';
import renderer from 'react-test-renderer';
import { mount } from 'enzyme';
import { IntlProvider } from '@edx/frontend-i18n';
import { sendTrackEvent } from '@edx/frontend-analytics';
import { IntlProvider } from '@edx/frontend-platform/i18n';
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
import { getConfig } from '@edx/frontend-platform/config';

import Footer, { EVENT_NAMES } from './Footer';
import { App } from '@edx/frontend-base';

jest.mock('@edx/frontend-analytics');
jest.mock('@edx/frontend-platform/analytics');
jest.mock('@edx/frontend-platform/config');

getConfig.mockReturnValue({});

describe('<Footer />', () => {
describe('renders correctly', () => {
Expand Down Expand Up @@ -35,24 +38,24 @@ describe('<Footer />', () => {

describe('when hidden', () => {
beforeEach(() => {
App.config.HIDE_FOOTER = true;
getConfig.mockReturnValue({ HIDE_FOOTER: true });
});

afterEach(() => {
App.config.HIDE_FOOTER = false;
getConfig.mockReturnValue({ HIDE_FOOTER: false });
});

it('should hide itself', () => {
const tree = renderer
.create((
<IntlProvider locale="en">
<Footer />
</IntlProvider>
))
.toJSON();
.create((
<IntlProvider locale="en">
<Footer />
</IntlProvider>
))
.toJSON();
expect(tree).toMatchSnapshot();
});
})
});

it('renders with a language selector', () => {
const tree = renderer
Expand Down
2 changes: 1 addition & 1 deletion src/components/GooglePlayStoreButton.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { injectIntl, intlShape } from '@edx/frontend-i18n';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import messages from './Footer.messages';

const GooglePlayStoreButton = ({ intl, ...props }) => (
Expand Down
2 changes: 1 addition & 1 deletion src/components/LanguageSelector.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { injectIntl, intlShape, FormattedMessage } from '@edx/frontend-i18n';
import { injectIntl, intlShape, FormattedMessage } from '@edx/frontend-platform/i18n';
import { faLanguage } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

Expand Down
2 changes: 1 addition & 1 deletion src/components/SocialIconLinks.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { injectIntl, intlShape } from '@edx/frontend-i18n';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import {
faFacebookSquare,
faTwitterSquare,
Expand Down

0 comments on commit 98655c6

Please sign in to comment.