Skip to content

Commit 4f3904e

Browse files
refactor: replacing injectIntl with useIntl part 3 (#2300)
1 parent 215f728 commit 4f3904e

File tree

14 files changed

+73
-99
lines changed

14 files changed

+73
-99
lines changed
Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
2+
import { useIntl } from '@edx/frontend-platform/i18n';
33
import { Helmet } from 'react-helmet';
44
import { Container } from '@openedx/paragon';
55
import { StudioFooterSlot } from '@edx/frontend-component-footer';
@@ -11,32 +11,29 @@ import AccessibilityForm from './AccessibilityForm';
1111

1212
import { COMMUNITY_ACCESSIBILITY_LINK, ACCESSIBILITY_EMAIL } from './constants';
1313

14-
const AccessibilityPage = ({
15-
// injected
16-
intl,
17-
}) => (
18-
<>
19-
<Helmet>
20-
<title>
21-
{intl.formatMessage(messages.pageTitle, {
22-
siteName: process.env.SITE_NAME,
23-
})}
24-
</title>
25-
</Helmet>
26-
<Header isHiddenMainMenu />
27-
<Container size="xl" classNamae="px-4">
28-
<AccessibilityBody
29-
{...{ email: ACCESSIBILITY_EMAIL, communityAccessibilityLink: COMMUNITY_ACCESSIBILITY_LINK }}
30-
/>
31-
<AccessibilityForm accessibilityEmail={ACCESSIBILITY_EMAIL} />
32-
</Container>
33-
<StudioFooterSlot />
34-
</>
35-
);
36-
37-
AccessibilityPage.propTypes = {
38-
// injected
39-
intl: intlShape.isRequired,
14+
const AccessibilityPage = () => {
15+
const intl = useIntl();
16+
return (
17+
<>
18+
<Helmet>
19+
<title>
20+
{intl.formatMessage(messages.pageTitle, {
21+
siteName: process.env.SITE_NAME,
22+
})}
23+
</title>
24+
</Helmet>
25+
<Header isHiddenMainMenu />
26+
<Container size="xl" classNamae="px-4">
27+
<AccessibilityBody
28+
{...{ email: ACCESSIBILITY_EMAIL, communityAccessibilityLink: COMMUNITY_ACCESSIBILITY_LINK }}
29+
/>
30+
<AccessibilityForm accessibilityEmail={ACCESSIBILITY_EMAIL} />
31+
</Container>
32+
<StudioFooterSlot />
33+
</>
34+
);
4035
};
4136

42-
export default injectIntl(AccessibilityPage);
37+
AccessibilityPage.propTypes = {};
38+
39+
export default AccessibilityPage;

src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/components/Feedback/FeedbackBox.jsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
3+
import { useIntl } from '@edx/frontend-platform/i18n';
44

55
import { answerOptionProps } from '../../../../../../../data/services/cms/types';
66
import FeedbackControl from './FeedbackControl';
@@ -15,9 +15,8 @@ export const FeedbackBox = ({
1515
images,
1616
isLibrary,
1717
learningContextId,
18-
// injected
19-
intl,
2018
}) => {
19+
const intl = useIntl();
2120
const props = {
2221
answer,
2322
intl,
@@ -70,7 +69,6 @@ FeedbackBox.propTypes = {
7069
images: PropTypes.shape({}).isRequired,
7170
learningContextId: PropTypes.string.isRequired,
7271
isLibrary: PropTypes.bool.isRequired,
73-
intl: intlShape.isRequired,
7472
};
7573

76-
export default injectIntl(FeedbackBox);
74+
export default FeedbackBox;

src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import { injectIntl, FormattedMessage } from '@edx/frontend-platform/i18n';
3+
import { FormattedMessage } from '@edx/frontend-platform/i18n';
44
import { connect } from 'react-redux';
55
import {
66
Button, Collapsible,
@@ -228,4 +228,4 @@ export const mapDispatchToProps = {
228228
};
229229

230230
export const SettingsWidgetInternal = SettingsWidget; // For testing only
231-
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(SettingsWidget));
231+
export default connect(mapStateToProps, mapDispatchToProps)(SettingsWidget);

src/editors/containers/TextEditor/index.jsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
Spinner,
77
Toast,
88
} from '@openedx/paragon';
9-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
9+
import { useIntl } from '@edx/frontend-platform/i18n';
1010

1111
import { getConfig } from '@edx/frontend-platform';
1212
import { actions, selectors } from '../../data/redux';
@@ -32,9 +32,8 @@ const TextEditor = ({
3232
learningContextId,
3333
images,
3434
isLibrary,
35-
// inject
36-
intl,
3735
}) => {
36+
const intl = useIntl();
3837
const { editorRef, refReady, setEditorRef } = prepareEditorRef();
3938
const initialContent = blockValue ? blockValue.data.data : '';
4039
const newContent = replaceStaticWithAsset({
@@ -123,8 +122,6 @@ TextEditor.propTypes = {
123122
learningContextId: PropTypes.string, // This should be required but is NULL when the store is in initial state :/
124123
images: PropTypes.shape({}).isRequired,
125124
isLibrary: PropTypes.bool.isRequired,
126-
// inject
127-
intl: intlShape.isRequired,
128125
};
129126

130127
export const mapStateToProps = (state) => ({
@@ -144,4 +141,4 @@ export const mapDispatchToProps = {
144141
};
145142

146143
export const TextEditorInternal = TextEditor; // For testing only
147-
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(TextEditor));
144+
export default connect(mapStateToProps, mapDispatchToProps)(TextEditor);

src/editors/containers/TextEditor/index.test.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import { render, screen, initializeMocks } from '@src/testUtils';
3-
import { formatMessage } from '../../testUtils';
43
import { actions, selectors } from '../../data/redux';
54
import { RequestKeys } from '../../data/constants/requests';
65
import { TextEditorInternal as TextEditor, mapStateToProps, mapDispatchToProps } from '.';
@@ -53,8 +52,6 @@ describe('TextEditor', () => {
5352
learningContextId: 'course+org+run',
5453
images: {},
5554
isLibrary: false,
56-
// inject
57-
intl: { formatMessage },
5855
};
5956

6057
afterAll(() => jest.restoreAllMocks());

src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoPreviewWidget/LanguageNamesWidget.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
1+
import { useIntl } from '@edx/frontend-platform/i18n';
22
import { Icon } from '@openedx/paragon';
33
import { ClosedCaptionOff, ClosedCaption } from '@openedx/paragon/icons';
44
import PropTypes from 'prop-types';
55
import React from 'react';
66
import messages from '../messages';
77
import { hooks as transcriptHooks } from '../TranscriptWidget';
88

9-
const LanguageNamesWidget = ({ transcripts, intl }) => {
9+
const LanguageNamesWidget = ({ transcripts }) => {
10+
const intl = useIntl();
1011
let icon = ClosedCaptionOff;
1112
const hasTranscripts = transcriptHooks.hasTranscripts(transcripts);
1213
let message = intl.formatMessage(messages.noTranscriptsAdded);
@@ -25,8 +26,7 @@ const LanguageNamesWidget = ({ transcripts, intl }) => {
2526
};
2627

2728
LanguageNamesWidget.propTypes = {
28-
intl: intlShape.isRequired,
2929
transcripts: PropTypes.arrayOf(PropTypes.string).isRequired,
3030
};
3131

32-
export default injectIntl(LanguageNamesWidget);
32+
export default LanguageNamesWidget;

src/export-page/export-modal-error/ExportModalError.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
2+
import { useIntl } from '@edx/frontend-platform/i18n';
33
import { useDispatch, useSelector } from 'react-redux';
44
import { getConfig } from '@edx/frontend-platform';
55
import PropTypes from 'prop-types';
@@ -11,9 +11,9 @@ import { updateIsErrorModalOpen } from '../data/slice';
1111
import messages from './messages';
1212

1313
const ExportModalError = ({
14-
intl,
1514
courseId,
1615
}) => {
16+
const intl = useIntl();
1717
const dispatch = useDispatch();
1818
const isErrorModalOpen = useSelector(getIsErrorModalOpen);
1919
const { msg: errorMessage, unitUrl: unitErrorUrl } = useSelector(getError);
@@ -47,10 +47,9 @@ const ExportModalError = ({
4747
};
4848

4949
ExportModalError.propTypes = {
50-
intl: intlShape.isRequired,
5150
courseId: PropTypes.string.isRequired,
5251
};
5352

5453
ExportModalError.defaultProps = {};
5554

56-
export default injectIntl(ExportModalError);
55+
export default ExportModalError;

src/files-and-videos/files-page/FileValidationModal.jsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useEffect } from 'react';
22
import PropTypes from 'prop-types';
33
import { useSelector } from 'react-redux';
4-
import { injectIntl, FormattedMessage, intlShape } from '@edx/frontend-platform/i18n';
4+
import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n';
55
import {
66
ActionRow,
77
Button,
@@ -14,9 +14,8 @@ import messages from './messages';
1414

1515
const FileValidationModal = ({
1616
handleFileOverwrite,
17-
// injected
18-
intl,
1917
}) => {
18+
const intl = useIntl();
2019
const [isOpen, open, close] = useToggle();
2120

2221
const { duplicateFiles } = useSelector(state => state.assets);
@@ -61,8 +60,6 @@ const FileValidationModal = ({
6160

6261
FileValidationModal.propTypes = {
6362
handleFileOverwrite: PropTypes.func.isRequired,
64-
// injected
65-
intl: intlShape.isRequired,
6663
};
6764

68-
export default injectIntl(FileValidationModal);
65+
export default FileValidationModal;

src/files-and-videos/files-page/FilesPage.jsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useEffect } from 'react';
22
import PropTypes from 'prop-types';
33
import { useDispatch, useSelector } from 'react-redux';
4-
import { injectIntl, FormattedMessage, intlShape } from '@edx/frontend-platform/i18n';
4+
import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n';
55
import { CheckboxFilter, Container } from '@openedx/paragon';
66
import Placeholder from '../../editors/Placeholder';
77

@@ -36,9 +36,8 @@ import './FilesPage.scss';
3636

3737
const FilesPage = ({
3838
courseId,
39-
// injected
40-
intl,
4139
}) => {
40+
const intl = useIntl();
4241
const dispatch = useDispatch();
4342
const courseDetails = useModel('courseDetails', courseId);
4443
document.title = getPageHeadTitle(courseDetails?.name, intl.formatMessage(messages.heading));
@@ -222,8 +221,6 @@ const FilesPage = ({
222221

223222
FilesPage.propTypes = {
224223
courseId: PropTypes.string.isRequired,
225-
// injected
226-
intl: intlShape.isRequired,
227224
};
228225

229-
export default injectIntl(FilesPage);
226+
export default FilesPage;

src/files-and-videos/videos-page/transcript-settings/OrderTranscriptForm.jsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import React, { useEffect, useState } from 'react';
22
import PropTypes from 'prop-types';
3-
import {
4-
FormattedMessage,
5-
FormattedDate,
6-
injectIntl,
7-
intlShape,
8-
} from '@edx/frontend-platform/i18n';
3+
import { FormattedMessage, FormattedDate, useIntl } from '@edx/frontend-platform/i18n';
94
import { Button, Stack } from '@openedx/paragon';
105
import ErrorAlert from '../../../editors/sharedComponents/ErrorAlerts/ErrorAlert';
116
import SelectableBox from '../../../editors/sharedComponents/SelectableBox';
@@ -25,9 +20,8 @@ const OrderTranscriptForm = ({
2520
transcriptionPlans,
2621
errorMessages,
2722
transcriptStatus,
28-
// injected
29-
intl,
3023
}) => {
24+
const intl = useIntl();
3125
const [data, setData] = useState(activeTranscriptPreferences || { videoSourceLanguage: '' });
3226

3327
const [validCieloTranscriptionPlan, validThreePlayTranscriptionPlan] = checkTranscriptionPlans(transcriptionPlans);
@@ -200,12 +194,10 @@ OrderTranscriptForm.propTypes = {
200194
languages: PropTypes.shape({}),
201195
}).isRequired,
202196
}).isRequired,
203-
// injected
204-
intl: intlShape.isRequired,
205197
};
206198

207199
OrderTranscriptForm.defaultProps = {
208200
activeTranscriptPreferences: null,
209201
};
210202

211-
export default injectIntl(OrderTranscriptForm);
203+
export default OrderTranscriptForm;

0 commit comments

Comments
 (0)