Skip to content

Commit 3315205

Browse files
authored
fix: video status badge translation (#438)
1 parent e0b70f2 commit 3315205

File tree

7 files changed

+36
-43
lines changed

7 files changed

+36
-43
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This guide presumes you have a functioning devstack.
1111

1212
1. Enable Studio to use an editor for your xblock using waffle flags
1313
1. Add the string name of your editor e.g. `html` to the flag check in the [edx-platform repo.](https://github.com/openedx/edx-platform/blob/369e5af85ab58c51a4bf4baf249d5cb36c1961fe/cms/static/js/views/pages/container.js#L190)
14-
2. In devstack + venv, run `$ make dev.provision.lms+studio+frontend-app-course-authoring` to make up the required services. Minimum services required are lms, studio and frontend-app-course-authoring.
14+
2. In devstack + venv, run `$ make dev.provision.lms+cms+frontend-app-course-authoring` to make up the required services. Minimum services required are lms, studio and frontend-app-course-authoring.
1515
4. In [Studio Django Admin](http://localhost:18000/admin/waffle/flag/) turn on `new_core_editors.use_new_text_editor` flag for HTML editor, `new_core_editors.use_new_video_editor` flag for new video editor, and `new_core_editors.use_new_problem_editor` flag for problems. The list of supported flags is in [toggles.py. ](https://github.com/openedx/edx-platform/blob/master/cms/djangoapps/contentstore/toggles.py). you might have to add a flag for your xblock of choice.
1616
2. Clone this repo into the [`${DEVSTACK_WORKSPACE}/src` directory](https://edx.readthedocs.io/projects/open-edx-devstack/en/latest/readme.html?highlight=DEVSTACK_WORKSPACE#id9) the sibling repo of your edx devstack `/src`.
1717
3. In the course authoring app, follow the guide to use your [local verison of frontend-lib-content-components. ](https://github.com/openedx/frontend-build#local-module-configuration-for-webpack) The module.config.js in the frontend-app-course-authoring repo will be:

src/editors/containers/VideoGallery/hooks.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ export const filterListByStatus = ({ statusFilter, videoList }) => {
5252
if (statusFilter === filterKeys.anyStatus) {
5353
return videoList;
5454
}
55-
// TODO deal with translation mismatch because the video status is
56-
// already translated in the backend
5755
return videoList.filter(({ status }) => filterKeys[statusFilter] === status);
5856
};
5957

@@ -166,8 +164,9 @@ export const buildVideos = ({ rawVideos }) => {
166164
dateAdded: new Date(video.created),
167165
locked: false,
168166
thumbnail: video.course_video_image_url,
169-
status: video.status,
170-
statusBadgeVariant: module.getstatusBadgeVariant({ status: video.status }),
167+
status: video.status_nontranslated,
168+
statusBadgeVariant: module.getstatusBadgeVariant({ status: video.status_nontranslated }),
169+
statusMessage: module.getStatusMessage({ status: video.status_nontranslated }),
171170
duration: video.duration,
172171
transcripts: video.transcripts,
173172
}));
@@ -177,7 +176,6 @@ export const buildVideos = ({ rawVideos }) => {
177176

178177
export const getstatusBadgeVariant = ({ status }) => {
179178
switch (status) {
180-
// TODO deal with translation mismatch
181179
case filterKeys.failed:
182180
return 'danger';
183181
case filterKeys.uploading:
@@ -188,6 +186,8 @@ export const getstatusBadgeVariant = ({ status }) => {
188186
}
189187
};
190188

189+
export const getStatusMessage = ({ status }) => Object.values(filterMessages).find((m) => m.defaultMessage === status);
190+
191191
export const useVideoProps = ({ videos }) => {
192192
const searchSortProps = useSearchAndSortProps();
193193
const videoList = useVideoListProps({

src/editors/containers/VideoGallery/index.test.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const initialVideos = [
2222
course_video_image_url: 'course_video_image_url_1',
2323
created: '2022-09-07T04:56:58.726Z',
2424
status: 'Uploading',
25+
status_nontranslated: 'Uploading',
2526
duration: 3,
2627
transcripts: [],
2728
},
@@ -31,6 +32,7 @@ const initialVideos = [
3132
course_video_image_url: 'course_video_image_url_2',
3233
created: '2022-11-07T04:56:58.726Z',
3334
status: 'In Progress',
35+
status_nontranslated: 'In Progress',
3436
duration: 2,
3537
transcripts: [],
3638
}, {
@@ -39,6 +41,7 @@ const initialVideos = [
3941
course_video_image_url: 'course_video_image_url_3',
4042
created: '2022-01-07T04:56:58.726Z',
4143
status: 'Ready',
44+
status_nontranslated: 'Ready',
4245
duration: 4,
4346
transcripts: [],
4447
},
@@ -146,7 +149,7 @@ describe('VideoGallery', () => {
146149
});
147150
it.each([
148151
['Uploading', 1, [1]],
149-
['Processing', 1, [2]],
152+
['In Progress', 1, [2]],
150153
['Ready', 1, [3]],
151154
['Failed', 1, [4]],
152155
])('videos can be filtered by status %s', async (filterBy, length, items) => {
@@ -158,6 +161,7 @@ describe('VideoGallery', () => {
158161
course_video_image_url: 'course_video_image_url_4',
159162
created: '2022-01-07T04:56:58.726Z',
160163
status: 'Failed',
164+
status_nontranslated: 'Failed',
161165
duration: 4,
162166
transcripts: [],
163167
}],

src/editors/containers/VideoGallery/messages.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,31 +54,31 @@ export const messages = {
5454
description: 'Dropdown label for sorting by duration (longest)',
5555
},
5656

57-
// Filter Dropdown
58-
filterByVideoStatusAny: {
59-
id: 'authoring.selectvideomodal.filter.videostatusnone.label',
57+
// Video status labels
58+
videoStatusAny: {
59+
id: 'authoring.selectvideomodal.videostatusnone.label',
6060
defaultMessage: 'Any status',
61-
description: 'Dropdown label for no filter (any status)',
61+
description: 'Label for video status (any status)',
6262
},
63-
filterByVideoStatusUploading: {
64-
id: 'authoring.selectvideomodal.filter.videostatusuploading.label',
63+
videoStatusUploading: {
64+
id: 'authoring.selectvideomodal.videostatusuploading.label',
6565
defaultMessage: 'Uploading',
66-
description: 'Dropdown label for filter by video status (uploading)',
66+
description: 'Label for video status (uploading)',
6767
},
68-
filterByVideoStatusProcessing: {
69-
id: 'authoring.selectvideomodal.filter.videostatusprocessing.label',
70-
defaultMessage: 'Processing',
71-
description: 'Dropdown label for filter by video status (processing)',
68+
videoStatusProcessing: {
69+
id: 'authoring.selectvideomodal.videostatusprocessing.label',
70+
defaultMessage: 'In Progress',
71+
description: 'Label for video status (processing)',
7272
},
73-
filterByVideoStatusReady: {
74-
id: 'authoring.selectvideomodal.filter.videostatusready.label',
73+
videoStatusReady: {
74+
id: 'authoring.selectvideomodal.videostatusready.label',
7575
defaultMessage: 'Ready',
76-
description: 'Dropdown label for filter by video status (ready)',
76+
description: 'Label for video status (ready)',
7777
},
78-
filterByVideoStatusFailed: {
79-
id: 'authoring.selectvideomodal.filter.videostatusfailed.label',
78+
videoStatusFailed: {
79+
id: 'authoring.selectvideomodal.videostatusfailed.label',
8080
defaultMessage: 'Failed',
81-
description: 'Dropdown label for filter by video status (failed)',
81+
description: 'Label for video status (failed)',
8282
},
8383

8484
// Hide switch

src/editors/containers/VideoGallery/utils.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ export const filterKeys = StrictDict({
3030
});
3131

3232
export const filterMessages = StrictDict({
33-
anyStatus: messages[messageKeys.filterByVideoStatusAny],
34-
uploading: messages[messageKeys.filterByVideoStatusUploading],
35-
processing: messages[messageKeys.filterByVideoStatusProcessing],
36-
ready: messages[messageKeys.filterByVideoStatusReady],
37-
failed: messages[messageKeys.filterByVideoStatusFailed],
33+
anyStatus: messages[messageKeys.videoStatusAny],
34+
uploading: messages[messageKeys.videoStatusUploading],
35+
processing: messages[messageKeys.videoStatusProcessing],
36+
ready: messages[messageKeys.videoStatusReady],
37+
failed: messages[messageKeys.videoStatusFailed],
3838
});
3939

4040
export const sortFunctions = StrictDict({

src/editors/sharedComponents/SelectionModal/GalleryCard.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ export const GalleryCard = ({
4444
onError={thumbnailFallback && (() => setThumbnailError(true))}
4545
/>
4646
)}
47-
{ asset.status && asset.statusBadgeVariant && (
47+
{ asset.statusMessage && asset.statusBadgeVariant && (
4848
<Badge variant={asset.statusBadgeVariant} style={{ position: 'absolute', left: '6px', top: '6px' }}>
49-
{asset.status}
49+
<FormattedMessage {...asset.statusMessage} />
5050
</Badge>
5151
)}
5252
{ asset.duration >= 0 && (
@@ -103,6 +103,7 @@ GalleryCard.propTypes = {
103103
url: PropTypes.string,
104104
duration: PropTypes.number,
105105
status: PropTypes.string,
106+
statusMessage: PropTypes.objectOf(PropTypes.string),
106107
statusBadgeVariant: PropTypes.string,
107108
transcripts: PropTypes.arrayOf(PropTypes.string),
108109
}).isRequired,

src/editors/sharedComponents/SelectionModal/__snapshots__/GalleryCard.test.jsx.snap

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,18 +216,6 @@ exports[`GalleryCard component snapshot with status badge 1`] = `
216216
}
217217
}
218218
/>
219-
<Badge
220-
style={
221-
Object {
222-
"left": "6px",
223-
"position": "absolute",
224-
"top": "6px",
225-
}
226-
}
227-
variant="danger"
228-
>
229-
failed
230-
</Badge>
231219
</div>
232220
<div
233221
className="card-text px-3 py-2"

0 commit comments

Comments
 (0)