Skip to content

Commit 60417a7

Browse files
refactor: replacing injectIntl with useIntl part 2 (#2299)
1 parent cbec650 commit 60417a7

File tree

14 files changed

+38
-64
lines changed

14 files changed

+38
-64
lines changed

src/accessibility-page/AccessibilityForm/AccessibilityForm.jsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import {
4-
injectIntl, FormattedMessage, intlShape, FormattedDate, FormattedTime,
4+
FormattedMessage, FormattedDate, FormattedTime, useIntl,
55
} from '@edx/frontend-platform/i18n';
66
import {
77
ActionRow, Alert, Form, Stack, StatefulButton,
@@ -15,9 +15,8 @@ import messages from './messages';
1515

1616
const AccessibilityForm = ({
1717
accessibilityEmail,
18-
// injected
19-
intl,
2018
}) => {
19+
const intl = useIntl();
2120
const {
2221
errors,
2322
values,
@@ -139,8 +138,6 @@ const AccessibilityForm = ({
139138

140139
AccessibilityForm.propTypes = {
141140
accessibilityEmail: PropTypes.string.isRequired,
142-
// injected
143-
intl: intlShape.isRequired,
144141
};
145142

146-
export default injectIntl(AccessibilityForm);
143+
export default AccessibilityForm;

src/advanced-settings/setting-card/SettingCard.jsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import { InfoOutline, Warning } from '@openedx/paragon/icons';
1212
import PropTypes from 'prop-types';
1313
import { capitalize } from 'lodash';
14-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
14+
import { useIntl } from '@edx/frontend-platform/i18n';
1515
import TextareaAutosize from 'react-textarea-autosize';
1616

1717
import messages from './messages';
@@ -25,9 +25,8 @@ const SettingCard = ({
2525
saveSettingsPrompt,
2626
isEditableState,
2727
setIsEditableState,
28-
// injected
29-
intl,
3028
}) => {
29+
const intl = useIntl();
3130
const { deprecated, help, displayName } = settingData;
3231
const initialValue = JSON.stringify(settingData.value, null, 4);
3332
const [isOpen, open, close] = useToggle(false);
@@ -115,7 +114,6 @@ const SettingCard = ({
115114
};
116115

117116
SettingCard.propTypes = {
118-
intl: intlShape.isRequired,
119117
settingData: PropTypes.shape({
120118
deprecated: PropTypes.bool,
121119
help: PropTypes.string,
@@ -137,4 +135,4 @@ SettingCard.propTypes = {
137135
setIsEditableState: PropTypes.func.isRequired,
138136
};
139137

140-
export default injectIntl(SettingCard);
138+
export default SettingCard;

src/advanced-settings/setting-card/SettingCard.test.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ jest.mock('react-textarea-autosize', () => jest.fn((props) => (
2929
const RootWrapper = () => (
3030
<IntlProvider locale="en">
3131
<SettingCard
32-
intl={{}}
3332
isOn
3433
name="settingName"
3534
setEdited={setEdited}
@@ -58,7 +57,6 @@ describe('<SettingCard />', () => {
5857
const { getByText } = render(
5958
<IntlProvider locale="en">
6059
<SettingCard
61-
intl={{}}
6260
isOn
6361
name="settingName"
6462
setEdited={setEdited}

src/course-outline/drag-helper/SortableItem.jsx

Lines changed: 3 additions & 6 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 { intlShape, injectIntl } from '@edx/frontend-platform/i18n';
3+
import { useIntl } from '@edx/frontend-platform/i18n';
44
import { useSortable } from '@dnd-kit/sortable';
55
import { CSS } from '@dnd-kit/utilities';
66
import {
@@ -17,9 +17,8 @@ const SortableItem = ({
1717
isDroppable,
1818
componentStyle,
1919
children,
20-
// injected
21-
intl,
2220
}) => {
21+
const intl = useIntl();
2322
const {
2423
attributes,
2524
listeners,
@@ -94,8 +93,6 @@ SortableItem.propTypes = {
9493
isDraggable: PropTypes.bool,
9594
children: PropTypes.node.isRequired,
9695
componentStyle: PropTypes.shape({}),
97-
// injected
98-
intl: intlShape.isRequired,
9996
};
10097

101-
export default injectIntl(SortableItem);
98+
export default SortableItem;

src/export-page/export-stepper/ExportStepper.jsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import React, { useEffect } from 'react';
2-
import {
3-
FormattedDate,
4-
injectIntl,
5-
intlShape,
6-
} from '@edx/frontend-platform/i18n';
2+
import { FormattedDate, useIntl } from '@edx/frontend-platform/i18n';
73
import PropTypes from 'prop-types';
84
import { useDispatch, useSelector } from 'react-redux';
95
import { Button } from '@openedx/paragon';
@@ -17,7 +13,8 @@ import { EXPORT_STAGES } from '../data/constants';
1713
import { RequestStatus } from '../../data/constants';
1814
import messages from './messages';
1915

20-
const ExportStepper = ({ intl, courseId }) => {
16+
const ExportStepper = ({ courseId }) => {
17+
const intl = useIntl();
2118
const currentStage = useSelector(getCurrentStage);
2219
const downloadPath = useSelector(getDownloadPath);
2320
const successDate = useSelector(getSuccessDate);
@@ -96,8 +93,7 @@ const ExportStepper = ({ intl, courseId }) => {
9693
};
9794

9895
ExportStepper.propTypes = {
99-
intl: intlShape.isRequired,
10096
courseId: PropTypes.string.isRequired,
10197
};
10298

103-
export default injectIntl(ExportStepper);
99+
export default ExportStepper;

src/export-page/export-stepper/ExportStepper.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let store;
1414
const RootWrapper = () => (
1515
<AppProvider store={store}>
1616
<IntlProvider locale="en" messages={{}}>
17-
<ExportStepper intl={{ formatMessage: jest.fn() }} courseId={courseId} />
17+
<ExportStepper courseId={courseId} />
1818
</IntlProvider>
1919
</AppProvider>
2020
);

src/files-and-videos/generic/FileTable.jsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useState } from 'react';
22
import { useSelector } from 'react-redux';
33
import PropTypes from 'prop-types';
44
import isEmpty from 'lodash/isEmpty';
5-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
5+
import { useIntl } from '@edx/frontend-platform/i18n';
66
import {
77
CardView,
88
DataTable,
@@ -42,9 +42,8 @@ const FileTable = ({
4242
maxFileSize,
4343
thumbnailPreview,
4444
infoModalSidebar,
45-
// injected
46-
intl,
4745
}) => {
46+
const intl = useIntl();
4847
const pageCount = Math.ceil(files.length / 50);
4948
const columnSizes = {
5049
xs: 12,
@@ -327,13 +326,11 @@ FileTable.propTypes = {
327326
maxFileSize: PropTypes.number.isRequired,
328327
thumbnailPreview: PropTypes.func.isRequired,
329328
infoModalSidebar: PropTypes.func.isRequired,
330-
// injected
331-
intl: intlShape.isRequired,
332329
};
333330

334331
FileTable.defaultProps = {
335332
files: null,
336333
handleLockFile: () => {},
337334
};
338335

339-
export default injectIntl(FileTable);
336+
export default FileTable;

src/files-and-videos/generic/InfoModal.jsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import React, { useState } from 'react';
22
import PropTypes from 'prop-types';
33

4-
import {
5-
injectIntl,
6-
intlShape,
7-
FormattedMessage,
8-
} from '@edx/frontend-platform/i18n';
4+
import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n';
95
import {
106
Icon,
117
ModalDialog,
@@ -28,9 +24,8 @@ const InfoModal = ({
2824
usagePathStatus,
2925
error,
3026
sidebar,
31-
// injected
32-
intl,
3327
}) => {
28+
const intl = useIntl();
3429
const [activeTab, setActiveTab] = useState('fileInfo');
3530
const showTranscriptionError = TRANSCRIPT_FAILURE_STATUSES.includes(file?.transcriptionStatus)
3631
&& activeTab !== 'fileInfo';
@@ -119,12 +114,10 @@ InfoModal.propTypes = {
119114
error: PropTypes.arrayOf(PropTypes.string).isRequired,
120115
thumbnailPreview: PropTypes.func.isRequired,
121116
sidebar: PropTypes.func.isRequired,
122-
// injected
123-
intl: intlShape.isRequired,
124117
};
125118

126119
InfoModal.defaultProps = {
127120
file: null,
128121
};
129122

130-
export default injectIntl(InfoModal);
123+
export default InfoModal;

src/files-and-videos/generic/table-components/table-custom-columns/ActiveColumn.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import { PropTypes } from 'prop-types';
33
import { isNil } from 'lodash';
4-
import { injectIntl } from '@edx/frontend-platform/i18n';
54
import { Icon } from '@openedx/paragon';
65
import { Check } from '@openedx/paragon/icons';
76
import { RequestStatus } from '../../../../data/constants';
@@ -25,4 +24,4 @@ ActiveColumn.propTypes = {
2524
pageLoadStatus: PropTypes.string.isRequired,
2625
};
2726

28-
export default injectIntl(ActiveColumn);
27+
export default ActiveColumn;

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState } 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
import { VideoFile } from '@openedx/paragon/icons';
55
import {
66
Badge,
@@ -22,9 +22,8 @@ const VideoThumbnail = ({
2222
videoImageSettings,
2323
status,
2424
pageLoadStatus,
25-
// injected
26-
intl,
2725
}) => {
26+
const intl = useIntl();
2827
const fileInputControl = useFileInput({
2928
onAddFile: (files) => {
3029
const [file] = files;
@@ -119,12 +118,10 @@ VideoThumbnail.propTypes = {
119118
}).isRequired,
120119
status: PropTypes.string.isRequired,
121120
pageLoadStatus: PropTypes.string.isRequired,
122-
// injected
123-
intl: intlShape.isRequired,
124121
};
125122

126123
VideoThumbnail.defaultProps = {
127124
thumbnail: null,
128125
};
129126

130-
export default injectIntl(VideoThumbnail);
127+
export default VideoThumbnail;

0 commit comments

Comments
 (0)