fix: video status badge translation (#438)
This commit is contained in:
@@ -52,8 +52,6 @@ export const filterListByStatus = ({ statusFilter, videoList }) => {
|
||||
if (statusFilter === filterKeys.anyStatus) {
|
||||
return videoList;
|
||||
}
|
||||
// TODO deal with translation mismatch because the video status is
|
||||
// already translated in the backend
|
||||
return videoList.filter(({ status }) => filterKeys[statusFilter] === status);
|
||||
};
|
||||
|
||||
@@ -166,8 +164,9 @@ export const buildVideos = ({ rawVideos }) => {
|
||||
dateAdded: new Date(video.created),
|
||||
locked: false,
|
||||
thumbnail: video.course_video_image_url,
|
||||
status: video.status,
|
||||
statusBadgeVariant: module.getstatusBadgeVariant({ status: video.status }),
|
||||
status: video.status_nontranslated,
|
||||
statusBadgeVariant: module.getstatusBadgeVariant({ status: video.status_nontranslated }),
|
||||
statusMessage: module.getStatusMessage({ status: video.status_nontranslated }),
|
||||
duration: video.duration,
|
||||
transcripts: video.transcripts,
|
||||
}));
|
||||
@@ -177,7 +176,6 @@ export const buildVideos = ({ rawVideos }) => {
|
||||
|
||||
export const getstatusBadgeVariant = ({ status }) => {
|
||||
switch (status) {
|
||||
// TODO deal with translation mismatch
|
||||
case filterKeys.failed:
|
||||
return 'danger';
|
||||
case filterKeys.uploading:
|
||||
@@ -188,6 +186,8 @@ export const getstatusBadgeVariant = ({ status }) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const getStatusMessage = ({ status }) => Object.values(filterMessages).find((m) => m.defaultMessage === status);
|
||||
|
||||
export const useVideoProps = ({ videos }) => {
|
||||
const searchSortProps = useSearchAndSortProps();
|
||||
const videoList = useVideoListProps({
|
||||
|
||||
@@ -22,6 +22,7 @@ const initialVideos = [
|
||||
course_video_image_url: 'course_video_image_url_1',
|
||||
created: '2022-09-07T04:56:58.726Z',
|
||||
status: 'Uploading',
|
||||
status_nontranslated: 'Uploading',
|
||||
duration: 3,
|
||||
transcripts: [],
|
||||
},
|
||||
@@ -31,6 +32,7 @@ const initialVideos = [
|
||||
course_video_image_url: 'course_video_image_url_2',
|
||||
created: '2022-11-07T04:56:58.726Z',
|
||||
status: 'In Progress',
|
||||
status_nontranslated: 'In Progress',
|
||||
duration: 2,
|
||||
transcripts: [],
|
||||
}, {
|
||||
@@ -39,6 +41,7 @@ const initialVideos = [
|
||||
course_video_image_url: 'course_video_image_url_3',
|
||||
created: '2022-01-07T04:56:58.726Z',
|
||||
status: 'Ready',
|
||||
status_nontranslated: 'Ready',
|
||||
duration: 4,
|
||||
transcripts: [],
|
||||
},
|
||||
@@ -146,7 +149,7 @@ describe('VideoGallery', () => {
|
||||
});
|
||||
it.each([
|
||||
['Uploading', 1, [1]],
|
||||
['Processing', 1, [2]],
|
||||
['In Progress', 1, [2]],
|
||||
['Ready', 1, [3]],
|
||||
['Failed', 1, [4]],
|
||||
])('videos can be filtered by status %s', async (filterBy, length, items) => {
|
||||
@@ -158,6 +161,7 @@ describe('VideoGallery', () => {
|
||||
course_video_image_url: 'course_video_image_url_4',
|
||||
created: '2022-01-07T04:56:58.726Z',
|
||||
status: 'Failed',
|
||||
status_nontranslated: 'Failed',
|
||||
duration: 4,
|
||||
transcripts: [],
|
||||
}],
|
||||
|
||||
@@ -54,31 +54,31 @@ export const messages = {
|
||||
description: 'Dropdown label for sorting by duration (longest)',
|
||||
},
|
||||
|
||||
// Filter Dropdown
|
||||
filterByVideoStatusAny: {
|
||||
id: 'authoring.selectvideomodal.filter.videostatusnone.label',
|
||||
// Video status labels
|
||||
videoStatusAny: {
|
||||
id: 'authoring.selectvideomodal.videostatusnone.label',
|
||||
defaultMessage: 'Any status',
|
||||
description: 'Dropdown label for no filter (any status)',
|
||||
description: 'Label for video status (any status)',
|
||||
},
|
||||
filterByVideoStatusUploading: {
|
||||
id: 'authoring.selectvideomodal.filter.videostatusuploading.label',
|
||||
videoStatusUploading: {
|
||||
id: 'authoring.selectvideomodal.videostatusuploading.label',
|
||||
defaultMessage: 'Uploading',
|
||||
description: 'Dropdown label for filter by video status (uploading)',
|
||||
description: 'Label for video status (uploading)',
|
||||
},
|
||||
filterByVideoStatusProcessing: {
|
||||
id: 'authoring.selectvideomodal.filter.videostatusprocessing.label',
|
||||
defaultMessage: 'Processing',
|
||||
description: 'Dropdown label for filter by video status (processing)',
|
||||
videoStatusProcessing: {
|
||||
id: 'authoring.selectvideomodal.videostatusprocessing.label',
|
||||
defaultMessage: 'In Progress',
|
||||
description: 'Label for video status (processing)',
|
||||
},
|
||||
filterByVideoStatusReady: {
|
||||
id: 'authoring.selectvideomodal.filter.videostatusready.label',
|
||||
videoStatusReady: {
|
||||
id: 'authoring.selectvideomodal.videostatusready.label',
|
||||
defaultMessage: 'Ready',
|
||||
description: 'Dropdown label for filter by video status (ready)',
|
||||
description: 'Label for video status (ready)',
|
||||
},
|
||||
filterByVideoStatusFailed: {
|
||||
id: 'authoring.selectvideomodal.filter.videostatusfailed.label',
|
||||
videoStatusFailed: {
|
||||
id: 'authoring.selectvideomodal.videostatusfailed.label',
|
||||
defaultMessage: 'Failed',
|
||||
description: 'Dropdown label for filter by video status (failed)',
|
||||
description: 'Label for video status (failed)',
|
||||
},
|
||||
|
||||
// Hide switch
|
||||
|
||||
@@ -30,11 +30,11 @@ export const filterKeys = StrictDict({
|
||||
});
|
||||
|
||||
export const filterMessages = StrictDict({
|
||||
anyStatus: messages[messageKeys.filterByVideoStatusAny],
|
||||
uploading: messages[messageKeys.filterByVideoStatusUploading],
|
||||
processing: messages[messageKeys.filterByVideoStatusProcessing],
|
||||
ready: messages[messageKeys.filterByVideoStatusReady],
|
||||
failed: messages[messageKeys.filterByVideoStatusFailed],
|
||||
anyStatus: messages[messageKeys.videoStatusAny],
|
||||
uploading: messages[messageKeys.videoStatusUploading],
|
||||
processing: messages[messageKeys.videoStatusProcessing],
|
||||
ready: messages[messageKeys.videoStatusReady],
|
||||
failed: messages[messageKeys.videoStatusFailed],
|
||||
});
|
||||
|
||||
export const sortFunctions = StrictDict({
|
||||
|
||||
@@ -44,9 +44,9 @@ export const GalleryCard = ({
|
||||
onError={thumbnailFallback && (() => setThumbnailError(true))}
|
||||
/>
|
||||
)}
|
||||
{ asset.status && asset.statusBadgeVariant && (
|
||||
{ asset.statusMessage && asset.statusBadgeVariant && (
|
||||
<Badge variant={asset.statusBadgeVariant} style={{ position: 'absolute', left: '6px', top: '6px' }}>
|
||||
{asset.status}
|
||||
<FormattedMessage {...asset.statusMessage} />
|
||||
</Badge>
|
||||
)}
|
||||
{ asset.duration >= 0 && (
|
||||
@@ -103,6 +103,7 @@ GalleryCard.propTypes = {
|
||||
url: PropTypes.string,
|
||||
duration: PropTypes.number,
|
||||
status: PropTypes.string,
|
||||
statusMessage: PropTypes.objectOf(PropTypes.string),
|
||||
statusBadgeVariant: PropTypes.string,
|
||||
transcripts: PropTypes.arrayOf(PropTypes.string),
|
||||
}).isRequired,
|
||||
|
||||
@@ -216,18 +216,6 @@ exports[`GalleryCard component snapshot with status badge 1`] = `
|
||||
}
|
||||
}
|
||||
/>
|
||||
<Badge
|
||||
style={
|
||||
Object {
|
||||
"left": "6px",
|
||||
"position": "absolute",
|
||||
"top": "6px",
|
||||
}
|
||||
}
|
||||
variant="danger"
|
||||
>
|
||||
failed
|
||||
</Badge>
|
||||
</div>
|
||||
<div
|
||||
className="card-text px-3 py-2"
|
||||
|
||||
Reference in New Issue
Block a user