forked from openedx/frontend-app-authoring
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathInfoModal.jsx
More file actions
130 lines (123 loc) · 3.86 KB
/
InfoModal.jsx
File metadata and controls
130 lines (123 loc) · 3.86 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import {
injectIntl,
intlShape,
FormattedMessage,
} from '@edx/frontend-platform/i18n';
import {
Icon,
ModalDialog,
Stack,
Truncate,
} from '@openedx/paragon';
import { Error } from '@openedx/paragon/icons';
import messages from './messages';
import UsageMetricsMessages from './UsageMetricsMessage';
import FileThumbnail from './ThumbnailPreview';
import { TRANSCRIPT_FAILURE_STATUSES } from '../videos-page/data/constants';
import AlertMessage from '../../generic/alert-message';
const InfoModal = ({
file,
isOpen,
onClose,
thumbnailPreview,
usagePathStatus,
error,
sidebar,
// injected
intl,
}) => {
const [activeTab, setActiveTab] = useState('fileInfo');
const showTranscriptionError = TRANSCRIPT_FAILURE_STATUSES.includes(file?.transcriptionStatus)
&& activeTab !== 'fileInfo';
return (
<ModalDialog
title={file?.displayName}
isOpen={isOpen}
onClose={onClose}
size="lg"
hasCloseButton
data-testid="file-info-modal"
style={{ minHeight: '799px' }}
>
<ModalDialog.Header>
<ModalDialog.Title>
<div style={{ wordBreak: 'break-word' }}>
<Truncate.Deprecated lines={2} className="font-weight-bold small mt-3">
{file?.displayName}
</Truncate.Deprecated>
</div>
</ModalDialog.Title>
</ModalDialog.Header>
<ModalDialog.Body className="pt-0 x-small">
<hr />
{showTranscriptionError && (
<AlertMessage
description={(
<div className="row m-0 align-itmes-center">
<Icon src={Error} className="text-danger-500 mr-2" />
{intl.formatMessage(messages.transcriptionErrorMessage, { error: file.errorDescription })}
</div>
)}
variant="danger"
/>
)}
<div className="row flex-nowrap m-0 mt-4">
<div className="col-7 mr-3">
<Stack gap={5}>
<FileThumbnail
thumbnail={file?.thumbnail}
externalUrl={file?.externalUrl}
displayName={file?.displayName}
wrapperType={file?.wrapperType}
id={file?.id}
status={file?.status}
thumbnailPreview={thumbnailPreview}
imageSize={{ width: '503px', height: '281px' }}
/>
<div>
<div className="row m-0 font-weight-bold">
<FormattedMessage {...messages.usageTitle} />
</div>
<UsageMetricsMessages {...{ usageLocations: file?.usageLocations, usagePathStatus, error }} />
</div>
</Stack>
</div>
<div className="col-5">
{sidebar(file, activeTab, setActiveTab)}
</div>
</div>
</ModalDialog.Body>
</ModalDialog>
);
};
InfoModal.propTypes = {
file: PropTypes.shape({
displayName: PropTypes.string.isRequired,
wrapperType: PropTypes.string.isRequired,
locked: PropTypes.bool,
externalUrl: PropTypes.string,
thumbnail: PropTypes.string,
id: PropTypes.string.isRequired,
portableUrl: PropTypes.string,
dateAdded: PropTypes.string.isRequired,
fileSize: PropTypes.number.isRequired,
usageLocations: PropTypes.arrayOf(PropTypes.string),
status: PropTypes.string,
transcriptionStatus: PropTypes.string,
errorDescription: PropTypes.string,
}),
onClose: PropTypes.func.isRequired,
isOpen: PropTypes.bool.isRequired,
usagePathStatus: PropTypes.string.isRequired,
error: PropTypes.arrayOf(PropTypes.string).isRequired,
thumbnailPreview: PropTypes.func.isRequired,
sidebar: PropTypes.func.isRequired,
// injected
intl: intlShape.isRequired,
};
InfoModal.defaultProps = {
file: null,
};
export default injectIntl(InfoModal);