Skip to content

Commit 7f64988

Browse files
author
Ahtesham Quraish
committed
refactor: Replace of injectIntl with useIntl() part 8 #2288
1 parent 0e1550a commit 7f64988

File tree

14 files changed

+141
-168
lines changed

14 files changed

+141
-168
lines changed

src/course-checklist/CourseChecklist.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 { getConfig } from '@edx/frontend-platform';
4-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
4+
import { useIntl } from '@edx/frontend-platform/i18n';
55
import { Helmet } from 'react-helmet';
66
import { useDispatch, useSelector } from 'react-redux';
77
import { Container, Stack } from '@openedx/paragon';
@@ -17,9 +17,8 @@ import ConnectionErrorAlert from '../generic/ConnectionErrorAlert';
1717

1818
const CourseChecklist = ({
1919
courseId,
20-
// injected,
21-
intl,
2220
}) => {
21+
const intl = useIntl();
2322
const dispatch = useDispatch();
2423
const courseDetails = useModel('courseDetails', courseId);
2524
const enableQuality = getConfig().ENABLE_CHECKLIST_QUALITY === 'true';
@@ -97,8 +96,6 @@ const CourseChecklist = ({
9796

9897
CourseChecklist.propTypes = {
9998
courseId: PropTypes.string.isRequired,
100-
// injected
101-
intl: intlShape.isRequired,
10299
};
103100

104-
export default injectIntl(CourseChecklist);
101+
export default CourseChecklist;

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

Lines changed: 3 additions & 5 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 { Form } from '@openedx/paragon';
44
import PropTypes from 'prop-types';
55
import SettingsOption from '../../SettingsOption';
@@ -11,9 +11,8 @@ export const RandomizationCard = ({
1111
randomization,
1212
defaultValue,
1313
updateSettings,
14-
// inject
15-
intl,
1614
}) => {
15+
const intl = useIntl();
1716
const curretRandomization = randomization || defaultValue;
1817
const { summary, handleChange } = useRandomizationSettingStatus({
1918
randomization: curretRandomization,
@@ -56,7 +55,6 @@ RandomizationCard.propTypes = {
5655
defaultValue: PropTypes.string.isRequired,
5756
randomization: PropTypes.string.isRequired,
5857
updateSettings: PropTypes.func.isRequired,
59-
intl: intlShape.isRequired,
6058
};
6159

62-
export default injectIntl(RandomizationCard);
60+
export default RandomizationCard;

src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/Randomization/index.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from 'react';
22
import {
33
render, screen, initializeMocks, fireEvent,
44
} from '@src/testUtils';
5-
import { formatMessage } from '@src/editors/testUtils';
65
import { RandomizationCard } from './index';
76
import * as hooks from './hooks';
87

@@ -11,11 +10,10 @@ describe('RandomizationCard', () => {
1110
randomization: 'per_student',
1211
defaultValue: 'always',
1312
updateSettings: jest.fn().mockName('args.updateSettings'),
14-
intl: { formatMessage },
1513
};
1614

1715
const randomizationCardHooksProps = {
18-
summary: { message: { defaultMessage: 'sUmmary' } },
16+
summary: { message: { id: 'defaultMessage', defaultMessage: 'sUmmary' } },
1917
handleChange: jest.fn().mockName('randomizationCardHooks.handleChange'),
2018
};
2119

src/editors/containers/VideoEditor/components/VideoSettingsModal/components/DurationWidget/index.jsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { connect } from 'react-redux';
33
import PropTypes from 'prop-types';
44

55
import { Col, Form } from '@openedx/paragon';
6-
import { injectIntl, intlShape, FormattedMessage } from '@edx/frontend-platform/i18n';
6+
import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n';
77

88
import { actions, selectors } from '../../../../../../data/redux';
99
import { keyStore } from '../../../../../../utils';
@@ -21,9 +21,8 @@ const DurationWidget = ({
2121
// redux
2222
duration,
2323
updateField,
24-
// injected
25-
intl,
2624
}) => {
25+
const intl = useIntl();
2726
const {
2827
unsavedDuration,
2928
onBlur,
@@ -88,8 +87,6 @@ DurationWidget.propTypes = {
8887
// redux
8988
duration: PropTypes.objectOf(PropTypes.number).isRequired,
9089
updateField: PropTypes.func.isRequired,
91-
// injected
92-
intl: intlShape.isRequired,
9390
};
9491

9592
export const mapStateToProps = (state) => ({
@@ -101,4 +98,4 @@ export const mapDispatchToProps = {
10198
};
10299

103100
export const DurationWidgetInternal = DurationWidget; // For testing only
104-
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(DurationWidget));
101+
export default connect(mapStateToProps, mapDispatchToProps)(DurationWidget);

src/editors/containers/VideoEditor/components/VideoSettingsModal/components/SocialShareWidget/index.jsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { connect } from 'react-redux';
33
import PropTypes from 'prop-types';
44
import {
55
FormattedMessage,
6-
injectIntl,
7-
intlShape,
6+
useIntl,
87
} from '@edx/frontend-platform/i18n';
98
import {
109
Hyperlink,
@@ -20,8 +19,6 @@ import * as hooks from './hooks';
2019
* Collapsible Form widget controlling video thumbnail
2120
*/
2221
const SocialShareWidget = ({
23-
// injected
24-
intl,
2522
// redux
2623
allowVideoSharing,
2724
isLibrary,
@@ -30,6 +27,7 @@ const SocialShareWidget = ({
3027
videoSharingLearnMoreLink,
3128
updateField,
3229
}) => {
30+
const intl = useIntl();
3331
const isSetByCourse = allowVideoSharing.level === 'course';
3432
const videoSharingEnabled = isLibrary ? videoSharingEnabledForAll : videoSharingEnabledForCourse;
3533
const learnMoreLink = videoSharingLearnMoreLink || 'https://docs.openedx.org/en/latest/educators/how-tos/course_development/social_sharing.html';
@@ -90,8 +88,6 @@ SocialShareWidget.defaultProps = {
9088
};
9189

9290
SocialShareWidget.propTypes = {
93-
// injected
94-
intl: intlShape.isRequired,
9591
// redux
9692
allowVideoSharing: PropTypes.shape({
9793
level: PropTypes.string.isRequired,
@@ -117,4 +113,4 @@ export const mapDispatchToProps = (dispatch) => ({
117113
});
118114

119115
export const SocialShareWidgetInternal = SocialShareWidget; // For testing only
120-
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(SocialShareWidget));
116+
export default connect(mapStateToProps, mapDispatchToProps)(SocialShareWidget);

src/editors/sharedComponents/CodeEditor/index.jsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
Button,
66
} from '@openedx/paragon';
77

8-
import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/i18n';
8+
import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n';
99
import messages from './messages';
1010
import './index.scss';
1111

@@ -15,9 +15,8 @@ const CodeEditor = ({
1515
innerRef,
1616
value,
1717
lang,
18-
// injected
19-
intl,
2018
}) => {
19+
const intl = useIntl();
2120
const DOMref = useRef();
2221
const btnRef = useRef();
2322
hooks.createCodeMirrorDomNode({
@@ -49,9 +48,8 @@ CodeEditor.propTypes = {
4948
PropTypes.shape({ current: PropTypes.any }),
5049
]).isRequired,
5150
value: PropTypes.string.isRequired,
52-
intl: intlShape.isRequired,
5351
lang: PropTypes.string.isRequired,
5452
};
5553

5654
export const CodeEditorInternal = CodeEditor; // For testing only
57-
export default injectIntl(CodeEditor);
55+
export default CodeEditor;
Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,45 @@
11
import React from 'react';
2-
import {
3-
injectIntl,
4-
intlShape,
5-
} from '@edx/frontend-platform/i18n';
2+
import { useIntl } from '@edx/frontend-platform/i18n';
63
import { Layout } from '@openedx/paragon';
74

85
import messages from './messages';
96

10-
const ExportFooter = ({ intl }) => (
11-
<footer className="mt-4 small">
12-
<Layout
13-
lg={[{ span: 5 }, { span: 2 }, { span: 5 }]}
14-
md={[{ span: 5 }, { span: 2 }, { span: 5 }]}
15-
sm={[{ span: 5 }, { span: 2 }, { span: 5 }]}
16-
xs={[{ span: 5 }, { span: 2 }, { span: 5 }]}
17-
xl={[{ span: 5 }, { span: 2 }, { span: 5 }]}
18-
>
19-
<Layout.Element>
20-
<h4>{intl.formatMessage(messages.exportedDataTitle)}</h4>
21-
<ul className="export-footer-list">
22-
<li>{intl.formatMessage(messages.exportedDataItem1)}</li>
23-
<li>{intl.formatMessage(messages.exportedDataItem2)}</li>
24-
<li>{intl.formatMessage(messages.exportedDataItem3)}</li>
25-
<li>{intl.formatMessage(messages.exportedDataItem4)}</li>
26-
<li>{intl.formatMessage(messages.exportedDataItem5)}</li>
27-
<li>{intl.formatMessage(messages.exportedDataItem6)}</li>
28-
<li>{intl.formatMessage(messages.exportedDataItem7)}</li>
29-
</ul>
30-
</Layout.Element>
31-
<Layout.Element />
32-
<Layout.Element>
33-
<h4>{intl.formatMessage(messages.notExportedDataTitle)}</h4>
34-
<ul className="export-footer-list">
35-
<li>{intl.formatMessage(messages.notExportedDataItem1)}</li>
36-
<li>{intl.formatMessage(messages.notExportedDataItem2)}</li>
37-
<li>{intl.formatMessage(messages.notExportedDataItem3)}</li>
38-
<li>{intl.formatMessage(messages.notExportedDataItem4)}</li>
39-
</ul>
40-
</Layout.Element>
41-
</Layout>
42-
</footer>
43-
);
44-
45-
ExportFooter.propTypes = {
46-
intl: intlShape.isRequired,
7+
const ExportFooter = () => {
8+
const intl = useIntl();
9+
return (
10+
<footer className="mt-4 small">
11+
<Layout
12+
lg={[{ span: 5 }, { span: 2 }, { span: 5 }]}
13+
md={[{ span: 5 }, { span: 2 }, { span: 5 }]}
14+
sm={[{ span: 5 }, { span: 2 }, { span: 5 }]}
15+
xs={[{ span: 5 }, { span: 2 }, { span: 5 }]}
16+
xl={[{ span: 5 }, { span: 2 }, { span: 5 }]}
17+
>
18+
<Layout.Element>
19+
<h4>{intl.formatMessage(messages.exportedDataTitle)}</h4>
20+
<ul className="export-footer-list">
21+
<li>{intl.formatMessage(messages.exportedDataItem1)}</li>
22+
<li>{intl.formatMessage(messages.exportedDataItem2)}</li>
23+
<li>{intl.formatMessage(messages.exportedDataItem3)}</li>
24+
<li>{intl.formatMessage(messages.exportedDataItem4)}</li>
25+
<li>{intl.formatMessage(messages.exportedDataItem5)}</li>
26+
<li>{intl.formatMessage(messages.exportedDataItem6)}</li>
27+
<li>{intl.formatMessage(messages.exportedDataItem7)}</li>
28+
</ul>
29+
</Layout.Element>
30+
<Layout.Element />
31+
<Layout.Element>
32+
<h4>{intl.formatMessage(messages.notExportedDataTitle)}</h4>
33+
<ul className="export-footer-list">
34+
<li>{intl.formatMessage(messages.notExportedDataItem1)}</li>
35+
<li>{intl.formatMessage(messages.notExportedDataItem2)}</li>
36+
<li>{intl.formatMessage(messages.notExportedDataItem3)}</li>
37+
<li>{intl.formatMessage(messages.notExportedDataItem4)}</li>
38+
</ul>
39+
</Layout.Element>
40+
</Layout>
41+
</footer>
42+
);
4743
};
4844

49-
export default injectIntl(ExportFooter);
45+
export default ExportFooter;

0 commit comments

Comments
 (0)