forked from openedx/frontend-app-authoring
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUploadProgressList.jsx
More file actions
55 lines (51 loc) · 1.58 KB
/
UploadProgressList.jsx
File metadata and controls
55 lines (51 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import React from 'react';
import PropTypes from 'prop-types';
import { Stack, Truncate } from '@openedx/paragon';
import UploadStatusIcon from './UploadStatusIcon';
import { RequestStatus } from '../../../data/constants';
const getVideoStatus = (status) => {
switch (status) {
case RequestStatus.IN_PROGRESS:
return 'UPLOADING';
case RequestStatus.PENDING:
return 'QUEUED';
case RequestStatus.SUCCESSFUL:
return '';
default:
return status.toUpperCase();
}
};
const UploadProgressList = ({ videosList }) => (
<div role="list" className="text-primary-500">
{videosList.map(([id, video], index) => {
const bulletNumber = `${index + 1}. `;
return (
<Stack role="listitem" gap={2} direction="horizontal" className="mb-3 small" key={id}>
<span>{bulletNumber}</span>
<div className="col-5 pl-0">
<Truncate.Deprecated>
{video.name}
</Truncate.Deprecated>
</div>
<div className="col-6 p-0">
<span className="row m-0 justify-content-end font-weight-bold">
{getVideoStatus(video.status)}
</span>
</div>
<UploadStatusIcon status={video.status} />
</Stack>
);
})}
</div>
);
UploadProgressList.propTypes = {
videosList: PropTypes.arrayOf(PropTypes.shape({
name: PropTypes.string.isRequired,
status: PropTypes.string.isRequired,
uploadPercentage: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
]).isRequired,
})).isRequired,
};
export default UploadProgressList;