Skip to content

Commit 2ae594f

Browse files
refactor: replacing injectIntl with useIntl part 4 (#2301)
1 parent 8e3ea89 commit 2ae594f

File tree

14 files changed

+39
-78
lines changed

14 files changed

+39
-78
lines changed

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ import {
1111
ActionRow,
1212
} from '@openedx/paragon';
1313
import { FileUpload, MoreHoriz } from '@openedx/paragon/icons';
14-
import {
15-
FormattedMessage,
16-
injectIntl,
17-
intlShape,
18-
} from '@edx/frontend-platform/i18n';
14+
import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n';
1915

2016
import { actions, selectors } from '../../../../../../data/redux';
2117
import * as hooks from './hooks';
@@ -32,15 +28,14 @@ import { RequestKeys } from '../../../../../../data/constants/requests';
3228
* Collapsible Form widget controlling video handouts
3329
*/
3430
const HandoutWidget = ({
35-
// injected
36-
intl,
3731
// redux
3832
isLibrary,
3933
handout,
4034
getHandoutDownloadUrl,
4135
updateField,
4236
isUploadError,
4337
}) => {
38+
const intl = useIntl();
4439
const [error] = React.useContext(ErrorContext).handout;
4540
const { fileSizeError } = hooks.fileSizeError();
4641
const fileInput = hooks.fileInput({ fileSizeError });
@@ -114,8 +109,6 @@ const HandoutWidget = ({
114109
};
115110

116111
HandoutWidget.propTypes = {
117-
// injected
118-
intl: intlShape.isRequired,
119112
// redux
120113
isLibrary: PropTypes.bool.isRequired,
121114
handout: PropTypes.shape({}).isRequired,
@@ -135,4 +128,4 @@ export const mapDispatchToProps = (dispatch) => ({
135128
});
136129

137130
export const HandoutWidgetInternal = HandoutWidget; // For testing only
138-
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(HandoutWidget));
131+
export default connect(mapStateToProps, mapDispatchToProps)(HandoutWidget);

src/editors/containers/VideoEditor/components/VideoSettingsModal/components/HandoutWidget/index.test.tsx

Lines changed: 0 additions & 2 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 '@src/editors/testUtils';
43
import { HandoutWidgetInternal as HandoutWidget } from '.';
54

65
jest.mock('@src/editors/data/redux', () => ({
@@ -25,7 +24,6 @@ jest.mock('@src/editors/data/redux', () => ({
2524

2625
describe('HandoutWidget', () => {
2726
const props = {
28-
intl: { formatMessage },
2927
isLibrary: false,
3028
handout: '',
3129
isUploadError: false,

src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/Transcript.jsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ import {
1212
} from '@openedx/paragon';
1313
import { DeleteOutline } from '@openedx/paragon/icons';
1414

15-
import {
16-
FormattedMessage,
17-
injectIntl,
18-
} from '@edx/frontend-platform/i18n';
15+
import { FormattedMessage } from '@edx/frontend-platform/i18n';
1916
import { thunkActions } from '../../../../../../data/redux';
2017

2118
import TranscriptActionMenu from './TranscriptActionMenu';
@@ -125,4 +122,4 @@ export const mapDispatchToProps = {
125122
};
126123

127124
export const TranscriptInternal = Transcript; // For testing only
128-
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(Transcript));
125+
export default connect(mapStateToProps, mapDispatchToProps)(Transcript);

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

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

4-
import {
5-
injectIntl,
6-
FormattedMessage,
7-
FormattedDate,
8-
intlShape,
9-
} from '@edx/frontend-platform/i18n';
4+
import { FormattedMessage, FormattedDate, useIntl } from '@edx/frontend-platform/i18n';
105
import {
116
Stack,
127
IconButton,
@@ -24,9 +19,8 @@ import messages from './messages';
2419
const FileInfoModalSidebar = ({
2520
asset,
2621
handleLockedAsset,
27-
// injected
28-
intl,
2922
}) => {
23+
const intl = useIntl();
3024
const [lockedState, setLockedState] = useState(asset?.locked);
3125
const handleLock = (e) => {
3226
const locked = e.target.checked;
@@ -123,8 +117,6 @@ FileInfoModalSidebar.propTypes = {
123117
usageLocations: PropTypes.arrayOf(PropTypes.string),
124118
}).isRequired,
125119
handleLockedAsset: PropTypes.func.isRequired,
126-
// injected
127-
intl: intlShape.isRequired,
128120
};
129121

130-
export default injectIntl(FileInfoModalSidebar);
122+
export default FileInfoModalSidebar;
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import React, { useContext } from 'react';
2-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
2+
import { useIntl } from '@edx/frontend-platform/i18n';
33
import { DataTableContext } from '@openedx/paragon';
44
import { getCurrentViewRange } from './utils';
55

6-
const RowStatus = ({
7-
// injected
8-
intl,
9-
}) => {
6+
const RowStatus = () => {
7+
const intl = useIntl();
108
const { filteredRows, page, initialRows } = useContext(DataTableContext);
119

1210
return (
@@ -23,8 +21,4 @@ const RowStatus = ({
2321
);
2422
};
2523

26-
RowStatus.propTypes = {
27-
intl: intlShape.isRequired,
28-
};
29-
30-
export default injectIntl(RowStatus);
24+
export default RowStatus;

src/files-and-videos/generic/table-components/TableActions.jsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useContext, useEffect } from 'react';
22
import { isEmpty } from 'lodash';
33
import { PropTypes } from 'prop-types';
4-
import { injectIntl, intlShape, FormattedMessage } from '@edx/frontend-platform/i18n';
4+
import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n';
55
import { getConfig } from '@edx/frontend-platform';
66
import {
77
Button,
@@ -22,9 +22,8 @@ const TableActions = ({
2222
encodingsDownloadUrl,
2323
fileType,
2424
setInitialState,
25-
// injected
26-
intl,
2725
}) => {
26+
const intl = useIntl();
2827
const [isSortOpen, openSort, closeSort] = useToggle(false);
2928
const { state, clearSelection } = useContext(DataTableContext);
3029

@@ -110,11 +109,10 @@ TableActions.propTypes = {
110109
handleSort: PropTypes.func.isRequired,
111110
fileType: PropTypes.string.isRequired,
112111
setInitialState: PropTypes.func.isRequired,
113-
intl: intlShape.isRequired,
114112
};
115113

116114
TableActions.defaultProps = {
117115
encodingsDownloadUrl: null,
118116
};
119117

120-
export default injectIntl(TableActions);
118+
export default TableActions;

src/files-and-videos/generic/table-components/TableActions.test.jsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ const defaultProps = {
1414
handleSort: jest.fn(),
1515
fileType: 'video',
1616
setInitialState: jest.fn(),
17-
intl: {
18-
formatMessage: (msg, values) => msg.defaultMessage.replace('{fileType}', values?.fileType ?? ''),
19-
},
2017
};
2118

2219
const mockColumns = [

src/files-and-videos/generic/table-components/table-custom-columns/TranscriptColumn.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 { Icon } from '@openedx/paragon';
55
import { Info } from '@openedx/paragon/icons';
66
import { TRANSCRIPT_FAILURE_STATUSES } from '../../../videos-page/data/constants';
@@ -34,4 +34,4 @@ TranscriptColumn.propTypes = {
3434
}.isRequired,
3535
};
3636

37-
export default injectIntl(TranscriptColumn);
37+
export default TranscriptColumn;

src/files-and-videos/videos-page/info-sidebar/TranscriptTab.jsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useDispatch, useSelector } from 'react-redux';
44
import { isEmpty } from 'lodash';
55
import { Button, Stack } from '@openedx/paragon';
66
import { Add } from '@openedx/paragon/icons';
7-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
7+
import { useIntl } from '@edx/frontend-platform/i18n';
88

99
import ErrorAlert from '../../../editors/sharedComponents/ErrorAlerts/ErrorAlert';
1010
import { getLanguages, getSortedTranscripts } from '../data/utils';
@@ -20,9 +20,8 @@ import messages from './messages';
2020

2121
const TranscriptTab = ({
2222
video,
23-
// injected
24-
intl,
2523
}) => {
24+
const intl = useIntl();
2625
const dispatch = useDispatch();
2726
const divRef = useRef(null);
2827
const { transcriptStatus, errors } = useSelector(state => state.videos);
@@ -145,8 +144,6 @@ TranscriptTab.propTypes = {
145144
id: PropTypes.string.isRequired,
146145
displayName: PropTypes.string.isRequired,
147146
}).isRequired,
148-
// injected
149-
intl: intlShape.isRequired,
150147
};
151148

152-
export default injectIntl(TranscriptTab);
149+
export default TranscriptTab;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
22
import PropTypes from 'prop-types';
33
import { isEmpty } from 'lodash';
44
import { useDispatch, useSelector } from 'react-redux';
5-
import { injectIntl, FormattedMessage } from '@edx/frontend-platform/i18n';
5+
import { FormattedMessage } from '@edx/frontend-platform/i18n';
66
import {
77
ActionRow,
88
Collapsible,
@@ -136,4 +136,4 @@ TranscriptSettings.propTypes = {
136136
courseId: PropTypes.string.isRequired,
137137
};
138138

139-
export default injectIntl(TranscriptSettings);
139+
export default TranscriptSettings;

0 commit comments

Comments
 (0)