|
4 | 4 | */ |
5 | 5 |
|
6 | 6 | import React from 'react'; |
7 | | -import { injectIntl } from 'react-intl'; |
| 7 | +import { FormattedMessage, injectIntl } from 'react-intl'; |
8 | 8 | import type { InjectIntlProvidedProps } from 'react-intl'; |
9 | 9 | import IconCheck from '../../icons/general/IconCheck'; |
10 | 10 | import IconClose from '../../icons/general/IconClose'; |
11 | 11 | import IconInProgress from './IconInProgress'; |
12 | 12 | import IconRetry from '../../icons/general/IconRetry'; |
13 | 13 | import LoadingIndicator from '../../components/loading-indicator'; |
14 | 14 | import PlainButton from '../../components/plain-button/PlainButton'; |
| 15 | +import PrimaryButton from '../../components/primary-button/PrimaryButton'; |
15 | 16 | import Tooltip from '../../components/tooltip'; |
16 | 17 | import messages from '../common/messages'; |
17 | | -import { STATUS_PENDING, STATUS_IN_PROGRESS, STATUS_STAGED, STATUS_COMPLETE, STATUS_ERROR } from '../../constants'; |
| 18 | +import { |
| 19 | + ERROR_CODE_UPLOAD_FILE_SIZE_LIMIT_EXCEEDED, |
| 20 | + STATUS_PENDING, |
| 21 | + STATUS_IN_PROGRESS, |
| 22 | + STATUS_STAGED, |
| 23 | + STATUS_COMPLETE, |
| 24 | + STATUS_ERROR, |
| 25 | +} from '../../constants'; |
18 | 26 | import type { UploadStatus } from '../../common/types/upload'; |
19 | 27 |
|
20 | 28 | import './ItemAction.scss'; |
21 | 29 |
|
22 | 30 | const ICON_CHECK_COLOR = '#26C281'; |
23 | 31 |
|
24 | 32 | type Props = { |
| 33 | + error?: Object, |
25 | 34 | isFolder?: boolean, |
26 | 35 | isResumableUploadsEnabled: boolean, |
27 | 36 | onClick: Function, |
| 37 | + onUpgradeCTAClick?: Function, |
28 | 38 | status: UploadStatus, |
29 | 39 | } & InjectIntlProvidedProps; |
30 | 40 |
|
31 | | -const ItemAction = ({ status, onClick, intl, isResumableUploadsEnabled, isFolder = false }: Props) => { |
| 41 | +const ItemAction = ({ |
| 42 | + error = {}, |
| 43 | + intl, |
| 44 | + isFolder = false, |
| 45 | + isResumableUploadsEnabled, |
| 46 | + onClick, |
| 47 | + onUpgradeCTAClick, |
| 48 | + status, |
| 49 | +}: Props) => { |
32 | 50 | let icon = <IconClose />; |
33 | 51 | let tooltip; |
| 52 | + const { code } = error; |
34 | 53 |
|
35 | 54 | if (isFolder && status !== STATUS_PENDING) { |
36 | 55 | return null; |
@@ -66,6 +85,18 @@ const ItemAction = ({ status, onClick, intl, isResumableUploadsEnabled, isFolder |
66 | 85 | break; |
67 | 86 | } |
68 | 87 |
|
| 88 | + if (status === STATUS_ERROR && code === ERROR_CODE_UPLOAD_FILE_SIZE_LIMIT_EXCEEDED && !!onUpgradeCTAClick) { |
| 89 | + return ( |
| 90 | + <PrimaryButton |
| 91 | + onClick={onUpgradeCTAClick} |
| 92 | + data-resin-target="large_version_error_inline_upgrade_cta" |
| 93 | + type="button" |
| 94 | + > |
| 95 | + <FormattedMessage {...messages.uploadsFileSizeLimitExceededUpgradeMessageForUpgradeCta} /> |
| 96 | + </PrimaryButton> |
| 97 | + ); |
| 98 | + } |
| 99 | + |
69 | 100 | return ( |
70 | 101 | <div className="bcu-item-action"> |
71 | 102 | {tooltip ? ( |
|
0 commit comments